ap_Argument Class Reference
[Parser for config files; validation]

#include <ap.h>

List of all members.


Detailed Description

Definition at line 61 of file ap.h.


Public Member Functions

 ap_Argument ()
 default constructor prepare object for exclusive command group
 ap_Argument (ap_ArgType_e a_argType, ap_Presence_e a_presence=pr_OPTIONAL, const char *a_long="", const char *a_short="", bool a_exclusive=false)
 constructor for parameters, non eclusive groups, any other argument
 ap_Argument (ivd_CliCommand_e a_cliCommand, const char *a_long, const char *a_short, bool a_exclusive=false)
 constructor for cli command
 ap_Argument (const char *a_long)
 constructor for cli
 ap_Argument (const string &a_long)
 ap_Argument (const ap_Argument &a_arg)
void Parse (UInt32_t a_argc, char *a_argv[], pf_ValueList &a_parsed) const
 owner name is passed by groupParse method if group has exclusive attribut set.
void GroupDump (ostream &a_os) const
void GroupList (ostream &a_os) const
ap_Argumentoperator<< (const ap_Argument &a_arg_p) const
ap_Argumentoperator= (const ap_Argument &a_arg)
ap_Argumentoperator<< (bool a_hidden) const

Public Attributes

string m_long
const char * m_short
ivd_CliCommand_e m_cliCommand

Private Member Functions

bool ArgParse (UInt32_t &a_idx, UInt32_t a_argc, char *a_argv[], pf_ValueList &a_parsed, int &a_shortOptIdx, bool a_necessary, const char *a_ownerName="", bool a_allHasShort=false) const
bool GroupParse (UInt32_t &a_idx, UInt32_t a_argc, char *a_argv[], pf_ValueList &a_parsed, bool a_necessary) const

Private Attributes

ap_ArgType_e m_argType
 argument type
ap_Presence_e m_presence
bool m_exclusive
bool m_allHasShort
ap_Argument_p_v_t m_group_v
vector< UInt8_tm_mandatoryEl_v
bool m_hidden

Friends

IVD_PARSER_DECL_d ostream & operator<< (ostream &a_os, const ap_Argument &a_grp)

Constructor & Destructor Documentation

ap_Argument::ap_Argument (  ) 

default constructor prepare object for exclusive command group

Definition at line 47 of file ap.cpp.

00048         :
00049         m_argType(at_GROUP),
00050         m_presence(pr_MANDATORY),
00051         m_long(ap_valCmdName),
00052         m_short(""),
00053         m_cliCommand(cc_SENTINEL),
00054         m_exclusive(true),
00055         m_allHasShort(true), // when passed arg that hasn't short opt became false
00056         m_hidden(false)
00057 {
00058     // empty
00059 }
//============================================================================//

ap_Argument::ap_Argument ( ap_ArgType_e  a_argType,
ap_Presence_e  a_presence = pr_OPTIONAL,
const char *  a_long = "",
const char *  a_short = "",
bool  a_exclusive = false 
)

constructor for parameters, non eclusive groups, any other argument

Parameters:
a_short  long command/option name
a_exclusive  short command/option name

Definition at line 63 of file ap.cpp.

00069         :
00070         m_argType(a_argType),
00071         m_presence(a_presence),
00072         m_long(a_long),
00073         m_short(a_short),
00074         m_cliCommand(cc_SENTINEL),
00075         m_exclusive(a_exclusive),
00076         m_allHasShort(true), // when passed arg that hasn't short opt became false
00077         m_hidden(false)
00078 {
00079     // empty
00080 }
//============================================================================//

ap_Argument::ap_Argument ( ivd_CliCommand_e  a_cliCommand,
const char *  a_long,
const char *  a_short,
bool  a_exclusive = false 
)

constructor for cli command

Parameters:
a_short  long command/option name
a_exclusive  short command/option name

Definition at line 84 of file ap.cpp.

00089         :
00090         m_argType(at_COMMAND),
00091         m_presence(pr_MANDATORY),
00092         m_long(a_long),
00093         m_short(a_short),
00094         m_cliCommand(a_cliCommand),
00095         m_exclusive(a_exclusive),
00096         m_allHasShort(true), // when passed arg that hasn't short opt became false
00097         m_hidden(false)
00098 {
00099     // empty
00100 }
//============================================================================//

ap_Argument::ap_Argument ( const char *  a_long  ) 

constructor for cli

Definition at line 104 of file ap.cpp.

00105         :
00106         m_argType(at_CLI),
00107         m_presence(pr_ELEMENTSPEC),
00108         m_long(a_long),
00109         m_short(""),
00110         m_cliCommand(cc_SENTINEL),
00111         m_exclusive(false),
00112         m_allHasShort(true), // when passed arg that hasn't short opt became false
00113         m_hidden(false)
00114 {
00115     // empty
00116 }
//============================================================================//

ap_Argument::ap_Argument ( const string &  a_long  ) 

Definition at line 120 of file ap.cpp.

00121         :
00122         m_argType(at_CLI),
00123         m_presence(pr_ELEMENTSPEC),
00124         m_long(a_long),
00125         m_short(""),
00126         m_cliCommand(cc_SENTINEL),
00127         m_exclusive(false),
00128         m_allHasShort(true), // when passed arg that hasn't short opt became false
00129         m_hidden(false)
00130 {
00131     // empty
00132 }
//============================================================================//

ap_Argument::ap_Argument ( const ap_Argument a_arg  )  [inline]

Definition at line 85 of file ap.h.

00085                                           {
00086         *this = a_arg;
00087     };


Member Function Documentation

void ap_Argument::Parse ( UInt32_t  a_argc,
char *  a_argv[],
pf_ValueList a_parsed 
) const

owner name is passed by groupParse method if group has exclusive attribut set.

This name is used to evaluate it with choised option

Definition at line 157 of file ap.cpp.

References pf_ValueList::Add(), ap_valArg0Name, at_CLI, ivd_BaseException::GetContext(), ivd_BaseException::GetError(), GroupParse(), ie_AP_INVGROUPTYPE, ie_AP_SYNERR, ivd_Error, m_argType, m_long, and pr_MANDATORY.

Referenced by cfg_Cli_fsc::cfg_Cli_fsc(), cfg_Cli_hsm::cfg_Cli_hsm(), cfg_CliBak::cfg_CliBak(), cfg_CliCheck::cfg_CliCheck(), cfg_CliCreateFile::cfg_CliCreateFile(), cfg_CliDD::cfg_CliDD(), cfg_CliDrive::cfg_CliDrive(), cfg_CliFile::cfg_CliFile(), cfg_CliFsTest::cfg_CliFsTest(), cfg_CliJob::cfg_CliJob(), cfg_CliLibrary::cfg_CliLibrary(), cfg_CliMedium::cfg_CliMedium(), cfg_CliPartition::cfg_CliPartition(), cfg_CliPool::cfg_CliPool(), cfg_CliRecover::cfg_CliRecover(), cfg_CliSystem::cfg_CliSystem(), and cfg_ivddbg::cfg_ivddbg().

00159                                                       {
00160 
00161     UInt32_t argIdx = 1;
00162 
00163     if (m_argType == at_CLI) {
00164         a_parsed.Add(pf_Value(ap_valArg0Name, a_argv[0], 0));
00165         pf_ValueList parsed;
00166         try {
00167             GroupParse(argIdx, a_argc, a_argv, a_parsed, pr_MANDATORY);
00168             // all argument must be parsed before exit
00169             if (argIdx < a_argc) {
00170                 throw ivd_Error(ie_AP_SYNERR, string(a_argv[argIdx]));
00171             }
00172         }
00173         catch (ivd_Error &e) {
00174             ostringstream msg;
00175             msg << e.GetContext() << endl
00176                 << "Run '" << m_long << " --help' for more information.";
00177             throw ivd_Error(e.GetError(), msg.str());
00178         }
00179     }
00180     else {
00181         throw ivd_Error(ie_AP_INVGROUPTYPE,
00182                         "Initial argument must be at_CLI type.");
00183     }
00184 }

Here is the call graph for this function:

Here is the caller graph for this function:

void ap_Argument::GroupDump ( ostream &  a_os  )  const

Definition at line 548 of file ap.cpp.

References ap_argLevel_g, ap_cmdName, ap_sizeUpTo3rdLevel_g, ap_valCmdName, at_COMMAND, m_exclusive, m_group_v, m_long, m_presence, and pr_OPTIONAL.

Referenced by operator<<().

00548                                                {
00549     if (m_group_v.size() == 0) {
00550         return;
00551     }
00552     ap_argLevel_g++;
00553 
00554     bool excl = m_exclusive;
00555     bool opt  = m_presence == pr_OPTIONAL;
00556 
00557     int leve3WriteOffset = 0;
00558     if (excl && !opt && m_long != ap_valCmdName) {
00559         a_os << '{';
00560         if (ap_argLevel_g < 3) {
00561             ap_sizeUpTo3rdLevel_g += 1;
00562         }
00563         else if(ap_argLevel_g == 3) {
00564             leve3WriteOffset = ap_sizeUpTo3rdLevel_g;
00565         }
00566     }
00567 
00568     ap_Argument_p_v_i iter          = m_group_v.begin();
00569     ap_Argument_p_v_i oneBeforeLast = m_group_v.end();
00570     oneBeforeLast--;
00571 
00572     for (; iter != oneBeforeLast; ++iter) {
00573         if (ap_argLevel_g == 2) {
00574             ap_sizeUpTo3rdLevel_g = 0;
00575 //            a_os << " R ";
00576         }
00577 //        a_os << "L:" << ap_argLevel_g << " S: " << ap_sizeUpTo3rdLevel_g << " ";
00578         if ((**iter).m_argType == at_COMMAND) {
00579             a_os << "  " << ap_cmdName << " ";
00580             if (ap_argLevel_g < 3) {
00581                 ap_sizeUpTo3rdLevel_g += 3 + string(ap_cmdName).length();
00582 //                a_os << "S: " << ap_sizeUpTo3rdLevel_g << " ";
00583             }
00584         }
00585         a_os << **iter;
00586         if ((**iter).m_argType == at_COMMAND) { // new line after command
00587             a_os << endl;
00588         }
00589         else {
00590             a_os << " ";
00591             if (ap_argLevel_g < 3) {
00592                 ap_sizeUpTo3rdLevel_g += 1;
00593 //                a_os << "S: " << ap_sizeUpTo3rdLevel_g << " ";
00594             }
00595 
00596             if (excl) {
00597                 if (ap_argLevel_g == 3) {
00598                     a_os << endl << string(leve3WriteOffset, ' ');
00599                 }
00600                 a_os << "| ";
00601                 if (ap_argLevel_g < 3) {
00602                     ap_sizeUpTo3rdLevel_g += 1;
00603 //                    a_os << "S: " << ap_sizeUpTo3rdLevel_g << " ";
00604                 }
00605             }
00606         }
00607 
00608     }
00609     if ((**oneBeforeLast).m_argType == at_COMMAND) {
00610         a_os << "  " << ap_cmdName << " ";
00611     }
00612     a_os << **oneBeforeLast;
00613     if ((**oneBeforeLast).m_argType == at_COMMAND) {
00614         a_os << endl << endl << "Common options:" << endl;
00615     }
00616 
00617     if (excl && !opt && m_long != ap_valCmdName) {
00618         a_os << '}';
00619         if (ap_argLevel_g < 3) {
00620             ap_sizeUpTo3rdLevel_g += 1;
00621 //            a_os << "S: " << ap_sizeUpTo3rdLevel_g << " ";
00622         }
00623     }
00624     ap_argLevel_g--;
00625 }

Here is the caller graph for this function:

void ap_Argument::GroupList ( ostream &  a_os  )  const

Definition at line 629 of file ap.cpp.

References m_group_v.

00629                                                {
00630     ap_Argument_p_v_i iter          = m_group_v.begin();
00631     ap_Argument_p_v_i oneBeforeLast = m_group_v.end();
00632     oneBeforeLast--;
00633     for (; iter != oneBeforeLast; ++iter) {
00634         a_os << (**iter).m_long << ", ";
00635     }
00636     a_os << (**oneBeforeLast).m_long;
00637 }

ap_Argument & ap_Argument::operator<< ( const ap_Argument a_arg_p  )  const

Definition at line 424 of file ap.cpp.

References ie_AP_ALREADYEXIST, ivd_Error, m_allHasShort, m_exclusive, m_group_v, m_long, m_mandatoryEl_v, m_presence, m_short, and pr_MANDATORY.

00424                                                                    {
00425     if (m_allHasShort && m_exclusive) {
00426         if (*a_arg.m_short == '\0') {
00427             m_allHasShort = false;
00428         }
00429         else { // check if arg short opt isn't already in group
00430             ap_Argument_p_v_i iter = m_group_v.begin();
00431             for (; iter != m_group_v.end(); ++iter) {
00432                 if ((**iter).m_short ==  a_arg.m_short) {
00433                     throw ivd_Error(ie_AP_ALREADYEXIST, string(m_long));
00434                 }
00435             }
00436         }
00437     }
00438     m_group_v.push_back(const_cast<ap_Argument*>(&a_arg));
00439     m_mandatoryEl_v.push_back((a_arg.m_presence == pr_MANDATORY));
00440     return *const_cast<ap_Argument*>(this);
00441 }

ap_Argument & ap_Argument::operator= ( const ap_Argument a_arg  ) 

Definition at line 136 of file ap.cpp.

References m_allHasShort, m_argType, m_cliCommand, m_exclusive, m_group_v, m_hidden, m_long, m_mandatoryEl_v, m_presence, and m_short.

00136                                                             {
00137 
00138     if (this == const_cast<ap_Argument*>(&a_arg)) {
00139         return *this;
00140     }
00141 
00142         m_argType       = a_arg.m_argType ;
00143         m_presence      = a_arg.m_presence;
00144         m_long          = a_arg.m_long    ;
00145         m_short         = a_arg.m_short   ;
00146         m_cliCommand    = a_arg.m_cliCommand;
00147         m_exclusive     = a_arg.m_exclusive;
00148         m_allHasShort   = a_arg.m_allHasShort;
00149         m_group_v       = a_arg.m_group_v;
00150         m_mandatoryEl_v = a_arg.m_mandatoryEl_v;
00151         m_hidden        = a_arg.m_hidden;
00152         return *this;
00153 }

ap_Argument & ap_Argument::operator<< ( bool  a_hidden  )  const

Definition at line 444 of file ap.cpp.

References m_hidden.

00444                                                         {
00445     m_hidden = true;
00446     return *const_cast<ap_Argument*>(this);
00447 }

bool ap_Argument::ArgParse ( UInt32_t a_idx,
UInt32_t  a_argc,
char *  a_argv[],
pf_ValueList a_parsed,
int &  a_shortOptIdx,
bool  a_necessary,
const char *  a_ownerName = "",
bool  a_allHasShort = false 
) const [private]

Definition at line 188 of file ap.cpp.

References pf_List::Add(), pf_ValueList::Add(), at_COMMAND, at_GROUP, at_MULTIPAR, at_OPTION, at_PARAMETER, cc_DEFAULT, cmn_Num2Str(), GroupParse(), ie_AP_INVARGTYPE, ie_AP_SYNERR, ivd_Error, m_argType, m_cliCommand, m_long, and m_short.

00196 {
00197     if (a_idx >= a_argc) { // no more arguments
00198         return false;
00199     }
00200     const char *arg = a_argv[a_idx];
00201 //    cout << " parse arg " << arg
00202 //         << " check with " << m_long
00203 //         << " presence = " << m_presence
00204 //         << endl;
00205 
00206     if (   m_argType    == at_GROUP
00207         || m_cliCommand == cc_DEFAULT) { // it's a group go directly there
00208         // if group parsed some argument then return true
00209         return GroupParse(a_idx, a_argc, a_argv, a_parsed, a_necessary);
00210     }
00211 
00212     if (*arg == '-') {
00213         if (arg[1] == '-') { // long command/option
00214            if (strcmp((const char*)(&arg[2]), (const char*)(m_long.c_str()) ) != 0) {
00215                return false;
00216            }
00217            a_idx++; // next arg to parse
00218         }
00219         else if (arg[1] != '\0') { // short command/option
00220            if (arg[a_shortOptIdx] != *m_short) {
00221                return false;
00222            }
00223            a_shortOptIdx++;
00224            if (arg[a_shortOptIdx] == '\0') { // no more short option in arg
00225                a_idx++; // next arg to parse
00226                a_shortOptIdx = 1;
00227            }
00228         }
00229         else { //
00230             throw ivd_Error(ie_AP_SYNERR, "single '-' option not supported.");
00231         }
00232         // Use a_ownername instead ap_valCmdName only for command.
00233         // Every exclusive group is evaluate by its name
00234         // and it is used short opt if all have it.
00235         if (m_argType == at_COMMAND) { // always long for command
00236             a_parsed.Add(pf_Value(a_ownerName, cmn_Num2Str(m_cliCommand), 0));
00237         }
00238         else if (*a_ownerName != '\0') {
00239             if (   a_allHasShort ) {
00240                 a_parsed.Add(pf_Value(a_ownerName, m_short, 0));
00241             }
00242             else {
00243                 a_parsed.Add(pf_Value(a_ownerName, m_long, 0));
00244             }
00245         }
00246         else if (m_argType == at_OPTION) {
00247             a_parsed.Add(pf_Value(m_long, "true", 0));
00248         }
00249         else { // this should not happened at customer
00250                // whong argument parameters in ap.cpp file
00251             throw ivd_Error(ie_AP_INVARGTYPE, string(m_long));
00252         }
00253     }
00254     else { // if (*arg = '-')
00255         if (m_argType == at_PARAMETER ) {
00256             a_parsed.Add(pf_Value(m_long, arg, 0));
00257             a_idx++; // next arg to parse
00258         }
00259         else if (m_argType == at_MULTIPAR) {
00260             pf_List list(0);
00261 
00262             do {
00263                 list.Add(pf_Elem(arg, 0));
00264                 a_idx++;
00265                 if (a_idx >= a_argc) {
00266                     break;
00267                 }
00268                 arg = a_argv[a_idx];
00269             } while (*arg != '-');
00270 
00271             a_parsed.Add(pf_Value(m_long, list, 0));
00272         }
00273         else { // nothing match, so skip group parse too
00274 //            cout << "Nothing match, so skip group parse too. arg " << arg
00275 //                 << "  group " << m_long << endl;
00276             return false;
00277         }
00278     } // if (*arg = '-')
00279 
00280     // merged short options can't have group
00281     if (a_shortOptIdx == 1) {
00282         // necessary argument is allways passed as true
00283         // argument is parsed, so its options need to be parsed too
00284         GroupParse(a_idx, a_argc, a_argv, a_parsed, true);
00285     }
00286 //    cout << "return from group " << m_long << endl;
00287     return true;
00288 }

Here is the call graph for this function:

bool ap_Argument::GroupParse ( UInt32_t a_idx,
UInt32_t  a_argc,
char *  a_argv[],
pf_ValueList a_parsed,
bool  a_necessary 
) const [private]

Definition at line 292 of file ap.cpp.

References alloca(), cc_DEFAULT, ie_AP_NOOPTION, ie_AP_NOTENOUGH, ie_AP_SYNERR, ivd_Error, m_allHasShort, m_exclusive, m_group_v, m_long, m_mandatoryEl_v, m_presence, pr_MANDATORY, pr_OPTIONAL, and size.

Referenced by ArgParse(), and Parse().

00297                                             {
00298 
00299     int size = m_group_v.size();
00300     if (size == 0) {// return if group is empty
00301 //        cout << " group of " << m_long << " is empty" << endl;
00302         return false;
00303     }
00304 //    cout << " parse group of " << m_long
00305 //         << " exclusive = " << m_exclusive
00306 //         << endl;
00307 
00308     char * groupNameArg = a_argv[a_idx-1];
00309 
00310     // nothing is parsed yet
00311     bool *parsed = (bool*)alloca(size * sizeof(bool));
00312     bool *p = parsed;
00313     for (int j = 0; j < size; ++j, ++p) {
00314         *p = false;
00315     }
00316 
00317     // need when parse merged short options
00318     int shortOptIdx = 1;
00319     bool someParsed = false;
00320     bool someParsedPerPass;
00321     int defaultCmdIdx = -1;
00322     ap_Argument_p_v_i defCmdIter;
00323     do {
00324         someParsedPerPass = false;
00325         ap_Argument_p_v_i iter = m_group_v.begin();
00326         for (int i = 0; i < size; ++i, ++iter) {
00327             if (!parsed[i]) { // not parsed yet
00328                 if ((*iter)->m_cliCommand == cc_DEFAULT)  {
00329                     defaultCmdIdx = i; // default command mest be parsed as last
00330                     defCmdIter = iter;
00331                 }
00332                 else if ((*iter)->ArgParse(a_idx, a_argc, a_argv, a_parsed,
00333                                         shortOptIdx,
00334                                         // if argument is mandatory and contain not exclusive group
00335                                         // then its next level arguments are mandatory to parse
00336                                         m_presence == pr_MANDATORY && !m_exclusive,
00337                                         m_exclusive
00338                                         ? m_long.c_str()  // if exclusive pass group name
00339                                         : "",    // to evaluate it by choiced opt
00340                                         m_allHasShort)) {
00341                     parsed[i] = someParsed = someParsedPerPass = true;
00342                     if (m_exclusive) {
00343                         goto foundExclusive; // got one;
00344                     }
00345                 }
00346             }
00347         }
00348     } while (someParsedPerPass);
00349     if (defaultCmdIdx != -1) { // default command parsed as last
00350         if ((*defCmdIter)->ArgParse(a_idx, a_argc, a_argv, a_parsed,
00351                             shortOptIdx,
00352                             m_presence != pr_OPTIONAL,
00353                             m_exclusive
00354                             ? m_long.c_str()  // if exclusive pass group name
00355                             : "",    // to evaluate it by choiced opt
00356                             m_allHasShort)) {
00357             parsed[defaultCmdIdx] = someParsed = true;
00358             if (m_exclusive) {
00359                 goto foundExclusive; // got one;
00360             }
00361         }
00362     }
00363 
00364     //cout << " "
00365     //     << " presence = " << m_presence
00366     //     << " some parsed = " << someParsed
00367     //     << " grupName = " << m_long
00368     //     << " needed " << a_necessary
00369     //     << endl;
00370 
00371     if (    m_presence != pr_OPTIONAL
00372         &&  a_necessary) {
00373         if (m_exclusive) {
00374             // fix bug 677  check if group is optional
00375             if (!someParsed) {
00376 //                char * lastArg = a_argv[a_idx-1];
00377 // TODO: Windows workaround for "Unknown exception" (bugs 1249 & 3136)
00378 // NOTE! Do not use ostringstream. It does not work on Windows.
00379                 string msg("No argument(s) specified for '");
00380                 msg += groupNameArg;
00381                 msg += "'";
00382                 throw ivd_Error(ie_AP_NOOPTION, msg);
00383             }
00384         }
00385         else {
00386             // check if all mandatory arguments are parsed
00387             for (int n = 0; n < size; ++n) {
00388                 if (    m_mandatoryEl_v[n]
00389                     && !parsed[n] ) {
00390 
00391 //                    char * lastArg = a_argv[a_idx-1];
00392 // TODO: Windows workaround for "Unknown exception" (bug 1249)
00393 // NOTE! Do not use ostringstream. It does not work on Windows.
00394                     string msg("No argument(s) specified for '");
00395                     msg += groupNameArg;
00396                     msg += "'";
00397                     throw ivd_Error(ie_AP_NOTENOUGH, msg);
00398                 }
00399             }
00400         }
00401     }
00402 
00403 foundExclusive:
00404     if (shortOptIdx != 1) {
00405         char * stopArg = a_argv[a_idx];
00406         string message;
00407         { //NOTE NOTE NOTE!!! Strange, but Windows thrown an error if use throw
00408           // in same bloc as ostring stream. See bug 5335.
00409          // ostring stream destructor must not be in same block as throw ivd_Error
00410             ostringstream msg;
00411             msg << "'" << stopArg
00412                 << "' on char '" << stopArg[shortOptIdx]
00413                 << "' index " << shortOptIdx
00414                 << ". Maybe long option without -- prefix.";
00415             message = msg.str();
00416         }
00417         throw ivd_Error(ie_AP_SYNERR, message );
00418     }
00419     return someParsed;
00420 }

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

IVD_PARSER_DECL_d ostream& operator<< ( ostream &  a_os,
const ap_Argument a_grp 
) [friend]

Definition at line 457 of file ap.cpp.

00457                                                               {
00458 
00459     if (  !ap_showHidden
00460        && a_arg.m_hidden) {
00461         return a_os;
00462     }
00463 
00464     bool opt         = a_arg.m_presence == pr_OPTIONAL;
00465     bool hasElements = a_arg.m_group_v.size() > 0;
00466     if (opt) {
00467         a_os << '[';
00468         if (ap_argLevel_g < 4) {
00469             ap_sizeUpTo3rdLevel_g++;
00470         }
00471     }
00472     switch (a_arg.m_argType) {
00473     case at_COMMAND :
00474         if (a_arg.m_cliCommand == cc_DEFAULT) { // default command has not name
00475             break;
00476         }
00477         // break intentionally left out - fall through
00478     case at_OPTION : {
00479         bool srt = *a_arg.m_short != '\0';
00480         if (srt) {
00481             if (!opt || hasElements) {
00482                 a_os << "{";
00483                 if (ap_argLevel_g < 4) {
00484                     ap_sizeUpTo3rdLevel_g++;
00485                 }
00486             }
00487             a_os  << "-" << a_arg.m_short << " | ";
00488             if (ap_argLevel_g < 4) {
00489                 ap_sizeUpTo3rdLevel_g += 5;
00490             }
00491         }
00492         a_os << "--" << a_arg.m_long;
00493         if (ap_argLevel_g < 4) {
00494             ap_sizeUpTo3rdLevel_g += 2 + string(a_arg.m_long).length();
00495         }
00496         if (srt && (!opt || hasElements)) {
00497             a_os << '}';
00498             if (ap_argLevel_g < 4) {
00499                 ap_sizeUpTo3rdLevel_g += 1;
00500             }
00501         }
00502         if (hasElements) {
00503             a_os << " ";
00504             if (ap_argLevel_g < 4) {
00505                 ap_sizeUpTo3rdLevel_g += 1;
00506             }
00507         }
00508         break;
00509     }
00510     case at_PARAMETER :
00511     case at_MULTIPAR :
00512         a_os << a_arg.m_long;
00513         if (hasElements) {
00514             a_os << " ";
00515             if (ap_argLevel_g < 4) {
00516                 ap_sizeUpTo3rdLevel_g += 1;
00517             }
00518         }
00519         break;
00520 
00521     case at_GROUP :
00522         break;
00523     case at_CLI :
00524         a_os << "Usage: " << endl;
00525 
00526         // ugly: hat to store in global
00527         ap_cmdName = a_arg.m_long.c_str();
00528         break;
00529 
00530     default : ;
00531     }
00532 
00533     if (hasElements) {
00534         a_arg.GroupDump(a_os);
00535     }
00536 
00537     if (opt) {
00538         a_os << ']';
00539         if (ap_argLevel_g < 4) {
00540             ap_sizeUpTo3rdLevel_g += 1;
00541         }
00542     }
00543     return a_os;
00544 }


Member Data Documentation

argument type

Definition at line 131 of file ap.h.

Referenced by ArgParse(), operator<<(), operator=(), and Parse().

Definition at line 133 of file ap.h.

Referenced by GroupDump(), GroupParse(), operator<<(), operator<<(), and operator=().

const char* ap_Argument::m_short

Definition at line 136 of file ap.h.

Referenced by ArgParse(), operator<<(), operator<<(), and operator=().

Definition at line 137 of file ap.h.

Referenced by ArgParse(), operator<<(), and operator=().

bool ap_Argument::m_exclusive [private]

Definition at line 140 of file ap.h.

Referenced by GroupDump(), GroupParse(), operator<<(), and operator=().

bool ap_Argument::m_allHasShort [mutable, private]

Definition at line 141 of file ap.h.

Referenced by GroupParse(), operator<<(), and operator=().

Definition at line 143 of file ap.h.

Referenced by GroupDump(), GroupList(), GroupParse(), operator<<(), operator<<(), and operator=().

Definition at line 144 of file ap.h.

Referenced by GroupParse(), operator<<(), and operator=().

bool ap_Argument::m_hidden [mutable, private]

Definition at line 145 of file ap.h.

Referenced by operator<<(), operator<<(), and operator=().


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

Generated on Mon Feb 27 18:57:48 2012 for OPENARCHIVE by  doxygen 1.5.6