Panda3D
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Public Attributes | List of all members
ProgramBase Class Reference

This is intended to be the base class for most general-purpose utility programs in the PANDATOOL tree. More...

#include "programBase.h"

Inheritance diagram for ProgramBase:
BamInfo BinToC CVSCopy DXFPoints EggBase FltInfo FltTrans ImageBase ImageInfo ImageTransformColors LwoScan PfmBba PfmTrans PtsToBam TextStats VRMLTrans XFileTrans

Public Types

typedef pdeque< std::string > Args
 

Public Member Functions

 ProgramBase (const std::string &name=std::string())
 
std::string get_exec_command () const
 Returns the command that invoked this program, as a shell-friendly string, suitable for pasting into the comments of output files.
 
virtual void parse_command_line (int argc, char **argv)
 Dispatches on each of the options on the command line, and passes the remaining parameters to handle_args().
 
void show_description ()
 Writes the program description to stderr.
 
void show_options ()
 Describes each of the available options to stderr.
 
void show_text (const std::string &prefix, int indent_width, std::string text)
 Formats the indicated text and its prefix for output to stderr with the known _terminal_width.
 
void show_text (const std::string &text)
 Formats the indicated text to stderr with the known _terminal_width.
 
void show_usage ()
 Writes the usage line(s) to stderr.
 
void write_man_page (std::ostream &out)
 Generates a man page in nroff syntax based on the description and options.
 

Public Attributes

Args _program_args
 
Filename _program_name
 

Detailed Description

This is intended to be the base class for most general-purpose utility programs in the PANDATOOL tree.

It automatically handles things like command-line arguments in a portable way.

Definition at line 34 of file programBase.h.

Member Typedef Documentation

◆ Args

typedef pdeque<std::string> ProgramBase::Args

Definition at line 52 of file programBase.h.

Constructor & Destructor Documentation

◆ ProgramBase()

ProgramBase::ProgramBase ( const std::string & name = std::string())

Definition at line 84 of file programBase.cxx.

◆ ~ProgramBase()

ProgramBase::~ProgramBase ( )
virtual

Definition at line 118 of file programBase.cxx.

Member Function Documentation

◆ get_exec_command()

string ProgramBase::get_exec_command ( ) const

Returns the command that invoked this program, as a shell-friendly string, suitable for pasting into the comments of output files.

Definition at line 466 of file programBase.cxx.

References Filename::get_basename_wo_extension().

◆ parse_command_line()

void ProgramBase::parse_command_line ( int argc,
char ** argv )
virtual

Dispatches on each of the options on the command line, and passes the remaining parameters to handle_args().

If an error on the command line is detected, will automatically call show_usage() and exit(1).

Definition at line 285 of file programBase.cxx.

References Filename::get_basename_wo_extension(), preprocess_argv(), show_usage(), and write_man_page().

Referenced by MayaToEggServer::poll().

◆ show_description()

void ProgramBase::show_description ( )

Writes the program description to stderr.

Definition at line 128 of file programBase.cxx.

◆ show_options()

void ProgramBase::show_options ( )

Describes each of the available options to stderr.

Definition at line 151 of file programBase.cxx.

References show_text().

◆ show_text() [1/2]

void ProgramBase::show_text ( const std::string & prefix,
int indent_width,
std::string text )

Formats the indicated text and its prefix for output to stderr with the known _terminal_width.

Definition at line 173 of file programBase.cxx.

◆ show_text() [2/2]

void ProgramBase::show_text ( const std::string & text)
inline

Formats the indicated text to stderr with the known _terminal_width.

Definition at line 17 of file programBase.I.

References show_text().

Referenced by show_options(), show_text(), and show_usage().

◆ show_usage()

void ProgramBase::show_usage ( )

Writes the usage line(s) to stderr.

Definition at line 136 of file programBase.cxx.

References Filename::get_basename_wo_extension(), and show_text().

Referenced by parse_command_line().

◆ write_man_page()

void ProgramBase::write_man_page ( std::ostream & out)

Generates a man page in nroff syntax based on the description and options.

This is useful when creating a man page for this utility.

Definition at line 188 of file programBase.cxx.

References Filename::get_basename_wo_extension(), and PandaSystem::get_version_string.

Referenced by parse_command_line().

Member Data Documentation

◆ _program_args

Args ProgramBase::_program_args

Definition at line 54 of file programBase.h.

◆ _program_name

Filename ProgramBase::_program_name

Definition at line 53 of file programBase.h.


The documentation for this class was generated from the following files: