Panda3D
Classes | 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 SoftCVS TextStats VRMLTrans XFileTrans

Public Types

typedef pdeque< string > Args
 

Public Member Functions

 ProgramBase (const string &name=string())
 
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. More...
 
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(). More...
 
void show_description ()
 Writes the program description to stderr. More...
 
void show_options ()
 Describes each of the available options to stderr. More...
 
void show_text (const string &text)
 Formats the indicated text to stderr with the known _terminal_width. More...
 
void show_text (const string &prefix, int indent_width, string text)
 Formats the indicated text and its prefix for output to stderr with the known _terminal_width. More...
 
void show_usage ()
 Writes the usage line(s) to stderr. More...
 
void write_man_page (ostream &out)
 Generates a man page in nroff syntax based on the description and options. More...
 

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 37 of file programBase.h.

Member Function Documentation

◆ get_exec_command()

string ProgramBase::get_exec_command ( ) const

◆ 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 290 of file programBase.cxx.

References Filename::from_os_specific(), Filename::get_basename_wo_extension(), get_exec_command(), show_usage(), and write_man_page().

Referenced by PfmTrans::add_transform_options(), EggTopstrip::adjust_transform(), DXFPoints::done_entity(), EggPalettize::handle_args(), MayaToEggServer::poll(), EggCrop::post_command_line(), PfmBba::process_pfm(), EggRetargetAnim::retarget_anim(), and write_man_page().

◆ show_description()

void ProgramBase::show_description ( )

Writes the program description to stderr.

Definition at line 132 of file programBase.cxx.

References show_usage().

Referenced by get_exec_command().

◆ show_options()

void ProgramBase::show_options ( )

Describes each of the available options to stderr.

Definition at line 159 of file programBase.cxx.

References show_text().

Referenced by get_exec_command(), and show_usage().

◆ show_text() [1/2]

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

Formats the indicated text to stderr with the known _terminal_width.

Definition at line 23 of file programBase.I.

Referenced by show_options(), and show_usage().

◆ show_text() [2/2]

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

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

Definition at line 183 of file programBase.cxx.

References write_man_page().

◆ show_usage()

void ProgramBase::show_usage ( )

Writes the usage line(s) to stderr.

Definition at line 142 of file programBase.cxx.

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

Referenced by get_exec_command(), parse_command_line(), and show_description().

◆ write_man_page()

void ProgramBase::write_man_page ( 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 201 of file programBase.cxx.

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

Referenced by parse_command_line(), and show_text().


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