cfg_CliBase Class Reference
[Parser for config files; validation]

#include <cli_arg.h>

Inheritance diagram for cfg_CliBase:

Inheritance graph
[legend]
Collaboration diagram for cfg_CliBase:

Collaboration graph
[legend]

List of all members.


Detailed Description

This class is a base for parsed and validated data specified in cli.

It already contains most of the data that is used by common commands.

Definition at line 32 of file cli_arg.h.


Public Member Functions

 cfg_CliBase ()
virtual ~cfg_CliBase ()
void Refresh (const pf_ValueList &a_parsedArgs)
virtual void HelpDump ()
 it it called at cc_HELP command each cli must implement its own method base HelpDump display common help
string GetCommand (int a_argc, char **a_argv)
void LogCommand (int a_argc, char **a_argv)

Static Public Member Functions

static char ** LocaleToUTF8Argv (int a_argc, char *a_argv[])
static void FreeUTF8Argv (int a_argc, char **a_argv)

Public Attributes

ivd_CliCommand_e command
string arg0
bool debug
string dbgLevel
string dbgFlags
cmn_Path dbgPath
string outQuantum
bool noMonitor
string cfgFileName
 most common cli values
string name
string revhist
UInt32_t revisionNum
string libraryName
string driveName
string poolName
string partitionName
bool detail
bool showHidden

Protected Member Functions

val_RuleVecGetRules ()

Private Attributes

val_RuleVec m_validationRules
 log_CLASSID_m

Constructor & Destructor Documentation

cfg_CliBase::cfg_CliBase (  ) 

Definition at line 1001 of file cfg_cliarg.cpp.

References val_RuleVec::Add(), ap_ooDetail, ap_ooNoMonitor, ap_paCfgFileName, ap_paDbgFlags, ap_paDriveName, ap_paLibraryName, ap_paName, ap_paPartName, ap_paPoolName, ap_paRevisionNum, ap_valArg0Name, ap_valCmdName, arg0, cfg_MAX_CFG_REVISION_NO, cfg_MAX_CLI_ARGLEN, cfg_MIN_CFG_REVISION_NO, cfg_MIN_CLI_ARGLEN, cfgFileName, command, dbg_NORM, dbgFlags, dbgLevel, dbgPath, debug, detail, driveName, GetRules(), libraryName, log_DBG_m, log_FUNC_m, ap_Argument::m_long, name, noMonitor, partitionName, poolName, revhist, revisionNum, showHidden, and val_RuleVec::size().

01002     : cfg_Base(),
01003     command(cc_DEFAULT),
01004     debug(false),
01005     dbgLevel("N"),
01006     noMonitor(false),
01007     revhist(" "),
01008     revisionNum(0),
01009     detail(false),
01010     showHidden(false)
01011 {
01012 
01013     log_FUNC_m(cfg_CliBase);
01014 
01015     GetRules().Add(
01016         new val_CliCommand(
01017             ap_valCmdName, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
01018         this->command
01019     );
01020 
01021     GetRules().Add(
01022         new val_Path(
01023             ap_valArg0Name, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
01024         this->arg0
01025     );
01026 
01027     GetRules().Add(
01028         new val_Path(
01029             ap_paCfgFileName.m_long, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
01030         this->cfgFileName
01031     );
01032 
01033     GetRules().Add(
01034         new val_StrictString(
01035             ap_paName.m_long, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
01036         this->name
01037     );
01038 
01039     GetRules().Add(
01040         new val_StrictString(
01041             ap_goRevHistory.m_long, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
01042         this->revhist
01043     );
01044 
01045     GetRules().Add(
01046         new val_Integer(
01047             ap_paRevisionNum.m_long,
01048             val_Limit(cfg_MIN_CFG_REVISION_NO, cfg_MAX_CFG_REVISION_NO), 0),
01049         this->revisionNum
01050     );
01051 
01052     GetRules().Add(
01053         new val_StrictString(
01054             ap_paLibraryName.m_long, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
01055         this->libraryName
01056     );
01057 
01058     GetRules().Add(
01059         new val_StrictString(
01060             ap_paDriveName.m_long, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
01061         this->driveName
01062     );
01063 
01064     GetRules().Add(
01065         new val_StrictString(
01066             ap_paPoolName.m_long, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
01067         this->poolName
01068     );
01069 
01070     GetRules().Add(
01071         new val_StrictString(
01072             ap_paPartName.m_long, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
01073         this->partitionName
01074     );
01075 
01076 // Anto: Not used
01077 //     GetRules().Add(
01078 //         new val_StrictString(
01079 //             ap_goOutQuantum.m_long,
01080 //             val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
01081 //         this->outQuantum
01082 //     );
01083 
01084     GetRules().Add(
01085         new val_Bool(
01086             ap_ooDetail.m_long, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
01087         this->detail
01088         );
01089 
01090     GetRules().Add(
01091         new val_Bool(
01092             ap_ooNoMonitor.m_long, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
01093         this->noMonitor
01094     );
01095 
01096     GetRules().Add(
01097         new val_Bool(
01098             ap_ooDebug.m_long, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
01099         this->debug
01100     );
01101     GetRules().Add(
01102         new val_DbgLevel(
01103             ap_paDbgLevel.m_long, val_Limit(1, 1)),
01104         this->dbgLevel
01105     );
01106     GetRules().Add(
01107         new val_Path(
01108             ap_paDbgPath.m_long, val_Limit(0, cfg_MAX_CLI_ARGLEN)),
01109         this->dbgPath
01110     );
01111     GetRules().Add(
01112         new val_DbgFlags(
01113             ap_paDbgFlags.m_long, val_Limit(0, 10)),
01114         this->dbgFlags
01115     );
01116 
01117     GetRules().Add(
01118         new val_Bool(
01119             ap_ooShowHidden.m_long, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
01120         this->showHidden
01121     );
01122 
01123     log_DBG_m(dbg_NORM,
01124         "Added " << GetRules().rules.size() << " rules for cfg_CliBase");
01125 }

Here is the call graph for this function:

virtual cfg_CliBase::~cfg_CliBase (  )  [inline, virtual]

Definition at line 35 of file cli_arg.h.

00035 {};


Member Function Documentation

void cfg_CliBase::Refresh ( const pf_ValueList a_parsedArgs  ) 

Definition at line 1128 of file cfg_cliarg.cpp.

References ap_showHidden, arg0, cc_HELP, cc_VERSION, command, cfg_Base::Convert(), dbg_DETAIL, dbg_On(), dbg_SetArgs(), dbg_SetProcName(), dbgFlags, dbgLevel, dbgPath, debug, g_cmn, GetRules(), ivd_Versions::GetVersionString(), ivd_Versions::GetVersionStringDetail(), HelpDump(), log_DBG_m, log_FUNC_m, ivd_Product::m_copyright, ivd_Product::m_copyright2, ivd_Product::m_name, outQuantum, cmn_Global::prod, and showHidden.

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().

01128                                                          {
01129     log_FUNC_m(Refresh);
01130 
01131 //    cout << "Parsed options: " << endl <<  a_parsedArgs << endl;
01132 
01133     Convert(a_parsedArgs, GetRules());
01134 
01135     dbg_SetProcName(arg0.c_str());
01136     if (debug) {
01137 
01138         dbg_SetArgs(
01139             (dbgLevel.length() > 0 ? dbgLevel[0] : '\0'),
01140             dbgPath, dbgFlags);
01141         dbg_On();
01142     }
01143 
01144     log_DBG_m(dbg_DETAIL,
01145         "Parsed options: " << endl <<  a_parsedArgs);
01146 
01147     ap_showHidden = showHidden;
01148 
01149     // Handle the command --version
01150     switch (command) {
01151     case cc_VERSION :
01152         cout <<
01153             g_cmn.prod.m_name << endl <<
01154             g_cmn.prod.m_copyright << endl << endl;
01155         if (!g_cmn.prod.m_copyright2.empty()) {
01156             cout << g_cmn.prod.m_copyright2 << endl << endl;
01157         }
01158 
01159         if (outQuantum == "detail") {
01160             cout << ivd_Versions::GetVersionStringDetail() << endl;
01161         }
01162         else {
01163             cout << ivd_Versions::GetVersionString() << endl;
01164         }
01165         exit(0);
01166         break;
01167 
01168     case cc_HELP :
01169         HelpDump();
01170         exit(0);
01171         break;
01172 
01173     default: ; // others commands will be executed by cli
01174     }
01175 }

Here is the call graph for this function:

Here is the caller graph for this function:

void cfg_CliBase::HelpDump (  )  [virtual]

it it called at cc_HELP command each cli must implement its own method base HelpDump display common help

Reimplemented in cfg_CliRecover, cfg_CliCheck, cfg_CliJob, cfg_CliLibrary, cfg_CliDrive, cfg_CliPool, cfg_CliMedium, cfg_CliSystem, cfg_CliPartition, cfg_CliBak, cfg_Cli_fsc, cfg_Cli_hsm, cfg_CliDD, cfg_CliCreateFile, cfg_CliFile, cfg_ivddbg, and cfg_CliFsTest.

Definition at line 1178 of file cfg_cliarg.cpp.

Referenced by cfg_CliFsTest::HelpDump(), cfg_CliRecover::HelpDump(), and Refresh().

01178                            {
01179 }

Here is the caller graph for this function:

string cfg_CliBase::GetCommand ( int  a_argc,
char **  a_argv 
)

Definition at line 1182 of file cfg_cliarg.cpp.

References command.

Referenced by LogCommand().

01182                                                          {
01183     ostringstream command;
01184     for (int i=0; i < a_argc; ++i) {
01185         command << a_argv[i] << " ";
01186     }
01187     return command.str();
01188 }

Here is the caller graph for this function:

void cfg_CliBase::LogCommand ( int  a_argc,
char **  a_argv 
)

Definition at line 1191 of file cfg_cliarg.cpp.

References GetCommand(), and log_WriteEvent().

Referenced by main().

01191                                                        {
01192     log_WriteEvent(GetCommand(a_argc, a_argv), a_argv[0], a_argc);
01193 }

Here is the call graph for this function:

Here is the caller graph for this function:

char ** cfg_CliBase::LocaleToUTF8Argv ( int  a_argc,
char *  a_argv[] 
) [static]

Definition at line 1213 of file cfg_cliarg.cpp.

References cmn_LocaleToUTF8(), g_cmn, ie_LOCALE, ivd_Error, log_FUNC_m, cmn_SysInfo::m_codeset, and cmn_Global::si.

Referenced by cfg_CliFile::cfg_CliFile(), and cfg_CliFsTest::cfg_CliFsTest().

01213                                                                {
01214 
01215     if (g_cmn.si.m_codeset.empty()) {
01216         log_FUNC_m(LocaleToUTF8Argv);
01217         throw ivd_Error(ie_LOCALE,
01218             "Codeset not detected. Check your environment settings.");
01219     };
01220 
01221     char** args = new char* [a_argc];
01222 
01223     for (int i=0; i < a_argc; ++i) {
01224         string utf = cmn_LocaleToUTF8(a_argv[i]);
01225         args[i] = new char [utf.length()+1];
01226         utf.copy(args[i], utf.length());
01227         args[i][utf.length()] = '\0';
01228     }
01229 
01230     return args;
01231 }

Here is the call graph for this function:

Here is the caller graph for this function:

void cfg_CliBase::FreeUTF8Argv ( int  a_argc,
char **  a_argv 
) [static]

Definition at line 1234 of file cfg_cliarg.cpp.

Referenced by cfg_CliFile::cfg_CliFile(), and cfg_CliFsTest::cfg_CliFsTest().

01234                                                         {
01235     for (int i=0; i < a_argc; ++i) {
01236         delete [] a_argv[i];
01237     }
01238     delete [] a_argv;
01239 }

Here is the caller graph for this function:

val_RuleVec& cfg_CliBase::GetRules (  )  [inline, protected]


Member Data Documentation

Definition at line 39 of file cli_arg.h.

Referenced by _tmain(), cfg_CliBase(), GetCommand(), main(), and Refresh().

Definition at line 41 of file cli_arg.h.

Referenced by cfg_CliBase(), and Refresh().

Definition at line 45 of file cli_arg.h.

Referenced by cfg_CliBase(), and Refresh().

Definition at line 46 of file cli_arg.h.

Referenced by cfg_CliBase(), and Refresh().

Definition at line 47 of file cli_arg.h.

Referenced by cfg_CliBase(), and Refresh().

Definition at line 48 of file cli_arg.h.

Referenced by cfg_CliBase(), and Refresh().

Definition at line 51 of file cli_arg.h.

Referenced by Refresh().

Definition at line 52 of file cli_arg.h.

Referenced by _tmain(), cfg_CliBase(), and main().

most common cli values

Definition at line 55 of file cli_arg.h.

Referenced by cfg_CliBase(), and main().

Definition at line 56 of file cli_arg.h.

Referenced by cfg_CliBase(), and main().

Definition at line 58 of file cli_arg.h.

Referenced by cfg_CliBase(), and main().

Definition at line 59 of file cli_arg.h.

Referenced by cfg_CliBase(), and main().

Definition at line 61 of file cli_arg.h.

Referenced by cfg_CliBase(), and main().

Definition at line 62 of file cli_arg.h.

Referenced by cfg_CliBase().

Definition at line 63 of file cli_arg.h.

Referenced by cfg_CliBase(), and main().

Definition at line 64 of file cli_arg.h.

Referenced by _tmain(), cfg_CliBase(), and main().

Definition at line 65 of file cli_arg.h.

Referenced by _tmain(), cfg_CliBase(), and main().

Definition at line 66 of file cli_arg.h.

Referenced by cfg_CliBase(), and Refresh().

Definition at line 86 of file cli_arg.h.


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

Generated on Mon Feb 27 19:03:18 2012 for OPENARCHIVE by  doxygen 1.5.6