TRF Language Model
wb::Option Class Reference

Get the option from command line or command files. More...

#include <wb-option.h>

Public Member Functions

 Option ()
 constructor More...
 
 ~Option ()
 destructor More...
 
void Add (ValueType t, const char *pLabel, void *pAddress, const char *pDocMsg=NULL)
 Add a option. More...
 
void PrintUsage ()
 output usage More...
 
void Print (ValueType type, void *pAddress)
 output a value More...
 
void PrintValue ()
 output values More...
 
void Parse (const char *plabel, const char *pvalue)
 parse a single option, "pvalue" can be NULL More...
 
int Parse (int argc, char **argv)
 get the options from command line More...
 
int Parse (const char *optfile)
 

Public Attributes

Array< Opt_Structm_opts
 all the options More...
 
string m_strOtherHelp
 extra help information, which will be output in PrintUsage More...
 
bool m_bOutputValues
 if output value after get options from the command line or file More...
 
bool m_bMustCommand
 setting 'true' means that, report error when no option input. More...
 
Array< char * > m_allocedBufs
 if read from file, we may need to allocate memory for string. More...
 

Detailed Description

Get the option from command line or command files.

Author
WangBin
Date
2016-05-05

Definition at line 54 of file wb-option.h.

Constructor & Destructor Documentation

§ Option()

wb::Option::Option ( )

constructor

Definition at line 22 of file wb-option.cpp.

§ ~Option()

wb::Option::~Option ( )

destructor

Definition at line 28 of file wb-option.cpp.

Member Function Documentation

§ Add()

void wb::Option::Add ( ValueType  t,
const char *  pLabel,
void *  pAddress,
const char *  pDocMsg = NULL 
)

Add a option.

Definition at line 35 of file wb-option.cpp.

§ Parse() [1/3]

void wb::Option::Parse ( const char *  plabel,
const char *  pvalue 
)

parse a single option, "pvalue" can be NULL

Definition at line 80 of file wb-option.cpp.

§ Parse() [2/3]

int wb::Option::Parse ( int  argc,
char **  argv 
)

get the options from command line

Parameters
[in]argccommand line count
[in]argvcommand line strings
[in]pOtherHelpif parse fails, output the help information
[in]bOutValueif set true, then output the values
[in]bMustCommandif set true, then report error when there are on command inputs
Returns
the option numberget the options from a file. the file format is: [label] = [values] in each line.

Definition at line 146 of file wb-option.cpp.

§ Parse() [3/3]

int wb::Option::Parse ( const char *  optfile)
Parameters
[in]optfilethe option file name
[in]pOtherHelpif parse fails, output the help information
[in]bOutValueif set true, then output the values
[in]bMustCommandif set true, then report error when there are on command inputs
Returns
the option number

Definition at line 186 of file wb-option.cpp.

§ Print()

void wb::Option::Print ( ValueType  type,
void *  pAddress 
)

output a value

Definition at line 50 of file wb-option.cpp.

§ PrintUsage()

void wb::Option::PrintUsage ( )

output usage

Definition at line 39 of file wb-option.cpp.

§ PrintValue()

void wb::Option::PrintValue ( )

output values

Definition at line 71 of file wb-option.cpp.

Member Data Documentation

§ m_allocedBufs

Array<char*> wb::Option::m_allocedBufs

if read from file, we may need to allocate memory for string.

Definition at line 62 of file wb-option.h.

§ m_bMustCommand

bool wb::Option::m_bMustCommand

setting 'true' means that, report error when no option input.

Definition at line 60 of file wb-option.h.

§ m_bOutputValues

bool wb::Option::m_bOutputValues

if output value after get options from the command line or file

Definition at line 59 of file wb-option.h.

§ m_opts

Array<Opt_Struct> wb::Option::m_opts

all the options

Definition at line 57 of file wb-option.h.

§ m_strOtherHelp

string wb::Option::m_strOtherHelp

extra help information, which will be output in PrintUsage

Definition at line 58 of file wb-option.h.


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