#include <CmdLineOpts.h>
Public Types | |
enum | type_t { string_t = 0, int_t, uint_t, long_t, ulong_t, double_t, float_t, flag_t, func_t, func_one_t, none_t } |
Option type. More... | |
Private Member Functions | |
Option () | |
Private default constructor. | |
Option (char shopt_, const string &lopt_, type_t type_, void *val_) | |
Private constructor. | |
void | dump () const |
Write object state to the log file. | |
const char * | type_c_str () |
Return the type of the Option object. | |
Private Attributes | |
char | m_short_name |
One-letter option name. | |
string | m_long_name |
Long option name. | |
type_t | m_type |
Option type. | |
void * | m_val |
Pointer to the option value. | |
Friends | |
class | CmdLineOpts |
This class is a helper class of CmdLineOpts class. It is not used by any other class and cannot be instantiated.
Definition at line 39 of file CmdLineOpts.h.
|
Option type. Each option, except for flags has a value following it on the command line. Following types are supported:
Definition at line 47 of file CmdLineOpts.h. 00047 { 00048 string_t=0, 00049 int_t, 00050 uint_t, 00051 long_t, 00052 ulong_t, 00053 double_t, 00054 float_t, 00055 flag_t, 00056 func_t, 00057 func_one_t, 00058 none_t 00059 };
|
|
Private default constructor.
Definition at line 89 of file CmdLineOpts.h. 00089 : 00090 m_short_name (' '), m_long_name (""), m_type (none_t), m_val (NULL) 00091 { 00092 /* empty */ 00093 }
|
|
Private constructor.
Definition at line 96 of file CmdLineOpts.h. References ASSA::CMDLINEOPTS, and trace_with_mask. 00096 : 00097 m_short_name (shopt_), m_long_name (lopt_), 00098 m_type (type_), m_val (val_) 00099 { 00100 trace_with_mask("Option::Option", CMDLINEOPTS); 00101 }
|
|
Write object state to the log file.
Definition at line 30 of file CmdLineOpts.cpp. References m_long_name, and m_short_name. 00031 { 00032 std::ostringstream msg; 00033 00034 if (m_short_name != 0) { 00035 msg << "-" << m_short_name << ", "; 00036 } 00037 else { 00038 msg << " "; 00039 } 00040 00041 if (m_long_name.size ()) { 00042 msg << "--" << std::setiosflags (std::ios::left) 00043 << std::setw(14) << m_long_name.c_str () << ' '; 00044 } 00045 else { 00046 msg << std::setiosflags (std::ios::left) << std::setw (14) << " "; 00047 } 00048 msg << '['; 00049 00050 switch (m_type) 00051 { 00052 case Option::string_t: 00053 msg << std::setiosflags (std::ios::left) << std::setw(7) << "string"; 00054 msg << "] = '" << *(string*) m_val << "'"; 00055 break; 00056 00057 case Option::int_t: 00058 msg << std::setiosflags(std::ios::left) << std::setw(7) << "int"; 00059 msg << "] = " << *(int*) m_val; 00060 break; 00061 00062 case Option::uint_t: 00063 msg << std::setiosflags(std::ios::left) << std::setw(7) << "u_int"; 00064 msg << "] = " << *(int*) m_val; 00065 break; 00066 00067 case Option::long_t: 00068 msg << std::setiosflags(std::ios::left) << std::setw(7) << "long"; 00069 msg << "] = " << *(long*) m_val; 00070 break; 00071 00072 case Option::ulong_t: 00073 msg << std::setiosflags(std::ios::left) << std::setw(7) << "u_long"; 00074 msg << "] = " << *(long*) m_val; 00075 break; 00076 00077 case Option::double_t: 00078 msg << std::setiosflags(std::ios::left) << std::setw(7) << "double"; 00079 msg << "] = " << *(double*) m_val; 00080 break; 00081 00082 case Option::float_t: 00083 msg << std::setiosflags(std::ios::left) << std::setw(7) << "float"; 00084 msg << "] = " << *(float*) m_val; 00085 break; 00086 00087 case Option::flag_t: 00088 msg << std::setiosflags(std::ios::left) << std::setw(7) << "bool"; 00089 msg << "] = " << *(bool*) m_val ? "true" : "false"; 00090 break; 00091 00092 case Option::func_t: 00093 msg << std::setiosflags(std::ios::left) 00094 << std::setw(7) << "function ()"; 00095 msg << ']'; 00096 break; 00097 00098 case Option::func_one_t: 00099 msg << std::setiosflags(std::ios::left) 00100 << std::setw(7) << "function (opt)"; 00101 msg << ']'; 00102 break; 00103 00104 case Option::none_t: 00105 msg << std::setiosflags(std::ios::left) << std::setw(7) << "none"; 00106 msg << ']'; 00107 break; 00108 00109 default: 00110 msg << std::setiosflags(std::ios::left) 00111 << std::setw(7) << "--undef--"; 00112 msg << ']'; 00113 } 00114 msg << std::ends; 00115 DL((CMDLINEOPTS,"%s\n", msg.str ().c_str ())); 00116 }
|
|
Return the type of the Option object.
Definition at line 120 of file CmdLineOpts.cpp. References double_t, flag_t, float_t, func_one_t, func_t, int_t, long_t, m_type, none_t, string_t, uint_t, and ulong_t. Referenced by ASSA::CmdLineOpts::assign(). 00121 { 00122 const char* ret; 00123 00124 switch (m_type) 00125 { 00126 case Option::string_t: ret = "string"; break; 00127 case Option::int_t: ret = "int"; break; 00128 case Option::uint_t: ret = "u_int"; break; 00129 case Option::long_t: ret = "long"; break; 00130 case Option::ulong_t: ret = "u_long"; break; 00131 case Option::double_t: ret = "double"; break; 00132 case Option::float_t: ret = "float"; break; 00133 case Option::flag_t: ret = "bool"; break; 00134 case Option::func_t: ret = "func()"; break; 00135 case Option::func_one_t: ret = "func(opt)"; break; 00136 case Option::none_t: ret = "none"; break; 00137 default: ret = "--undef--"; 00138 } 00139 return (ret); 00140 }
|
|
Definition at line 41 of file CmdLineOpts.h. |
|
Long option name.
Definition at line 79 of file CmdLineOpts.h. Referenced by ASSA::CmdLineOpts::assign(), and dump(). |
|
One-letter option name.
Definition at line 76 of file CmdLineOpts.h. Referenced by ASSA::CmdLineOpts::assign(), and dump(). |
|
Option type.
Definition at line 82 of file CmdLineOpts.h. Referenced by ASSA::CmdLineOpts::assign(), and type_c_str(). |
|
Pointer to the option value.
Definition at line 85 of file CmdLineOpts.h. Referenced by ASSA::CmdLineOpts::assign(). |