Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Private Attributes

cfg_CliBase Class Reference
[Parser for config files; validation]

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

#include <cli_arg.h>

Inheritance diagram for cfg_CliBase:
Inheritance graph
[legend]
Collaboration diagram for cfg_CliBase:
Collaboration graph
[legend]

List of all members.

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

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 46 of file cli_arg.h.


Constructor & Destructor Documentation

cfg_CliBase::cfg_CliBase (  ) 

Definition at line 1055 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().

    : cfg_Base(),
    command(cc_DEFAULT),
    debug(false),
    dbgLevel("N"),
    noMonitor(false),
    revhist(" "),
    revisionNum(0),
    detail(false),
    showHidden(false)
{

    log_FUNC_m(cfg_CliBase);

    GetRules().Add(
        new val_CliCommand(
            ap_valCmdName, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
        this->command
    );

    GetRules().Add(
        new val_Path(
            ap_valArg0Name, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
        this->arg0
    );

    GetRules().Add(
        new val_Path(
            ap_paCfgFileName.m_long, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
        this->cfgFileName
    );

    GetRules().Add(
        new val_StrictString(
            ap_paName.m_long, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
        this->name
    );

    GetRules().Add(
        new val_StrictString(
            ap_goRevHistory.m_long, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
        this->revhist
    );

    GetRules().Add(
        new val_Integer(
            ap_paRevisionNum.m_long,
            val_Limit(cfg_MIN_CFG_REVISION_NO, cfg_MAX_CFG_REVISION_NO), 0),
        this->revisionNum
    );

    GetRules().Add(
        new val_StrictString(
            ap_paLibraryName.m_long, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
        this->libraryName
    );

    GetRules().Add(
        new val_StrictString(
            ap_paDriveName.m_long, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
        this->driveName
    );

    GetRules().Add(
        new val_StrictString(
            ap_paPoolName.m_long, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
        this->poolName
    );

    GetRules().Add(
        new val_StrictString(
            ap_paPartName.m_long, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
        this->partitionName
    );

// Anto: Not used
//     GetRules().Add(
//         new val_StrictString(
//             ap_goOutQuantum.m_long,
//             val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
//         this->outQuantum
//     );

    GetRules().Add(
        new val_Bool(
            ap_ooDetail.m_long, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
        this->detail
        );

    GetRules().Add(
        new val_Bool(
            ap_ooNoMonitor.m_long, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
        this->noMonitor
    );

    GetRules().Add(
        new val_Bool(
            ap_ooDebug.m_long, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
        this->debug
    );
    GetRules().Add(
        new val_DbgLevel(
            ap_paDbgLevel.m_long, val_Limit(1, 1)),
        this->dbgLevel
    );
    GetRules().Add(
        new val_Path(
            ap_paDbgPath.m_long, val_Limit(0, cfg_MAX_CLI_ARGLEN)),
        this->dbgPath
    );
    GetRules().Add(
        new val_DbgFlags(
            ap_paDbgFlags.m_long, val_Limit(0, 10)),
        this->dbgFlags
    );

    GetRules().Add(
        new val_Bool(
            ap_ooShowHidden.m_long, val_Limit(cfg_MIN_CLI_ARGLEN, cfg_MAX_CLI_ARGLEN)),
        this->showHidden
    );

    log_DBG_m(dbg_NORM,
        "Added " << GetRules().rules.size() << " rules for cfg_CliBase");
}

Here is the call graph for this function:

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

Definition at line 49 of file cli_arg.h.

{};


Member Function Documentation

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

Definition at line 1288 of file cfg_cliarg.cpp.

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

                                                        {
    for (int i=0; i < a_argc; ++i) {
        delete [] a_argv[i];
    }
    delete [] a_argv;
}

Here is the caller graph for this function:

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

Definition at line 1236 of file cfg_cliarg.cpp.

References command.

Referenced by LogCommand().

                                                         {
    ostringstream command;
    for (int i=0; i < a_argc; ++i) {
        command << a_argv[i] << " ";
    }
    return command.str();
}

Here is the caller graph for this function:

val_RuleVec& cfg_CliBase::GetRules (  )  [inline, protected]
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 1232 of file cfg_cliarg.cpp.

Referenced by Refresh().

                           {
}

Here is the caller graph for this function:

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

Definition at line 1267 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().

                                                               {

    if (g_cmn.si.m_codeset.empty()) {
        log_FUNC_m(LocaleToUTF8Argv);
        throw ivd_Error(ie_LOCALE,
            "Codeset not detected. Check your environment settings.");
    };

    char** args = new char* [a_argc];

    for (int i=0; i < a_argc; ++i) {
        string utf = cmn_LocaleToUTF8(a_argv[i]);
        args[i] = new char [utf.length()+1];
        utf.copy(args[i], utf.length());
        args[i][utf.length()] = '\0';
    }

    return args;
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 1245 of file cfg_cliarg.cpp.

References GetCommand(), and log_WriteEvent().

Referenced by main().

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

Here is the call graph for this function:

Here is the caller graph for this function:

void cfg_CliBase::Refresh ( const pf_ValueList a_parsedArgs  ) 

Definition at line 1182 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().

                                                         {
    log_FUNC_m(Refresh);

//    cout << "Parsed options: " << endl <<  a_parsedArgs << endl;

    Convert(a_parsedArgs, GetRules());

    dbg_SetProcName(arg0.c_str());
    if (debug) {

        dbg_SetArgs(
            (dbgLevel.length() > 0 ? dbgLevel[0] : '\0'),
            dbgPath, dbgFlags);
        dbg_On();
    }

    log_DBG_m(dbg_DETAIL,
        "Parsed options: " << endl <<  a_parsedArgs);

    ap_showHidden = showHidden;

    // Handle the command --version
    switch (command) {
    case cc_VERSION :
        cout <<
            g_cmn.prod.m_name << endl <<
            g_cmn.prod.m_copyright << endl << endl;
        if (!g_cmn.prod.m_copyright2.empty()) {
            cout << g_cmn.prod.m_copyright2 << endl << endl;
        }

        if (outQuantum == "detail") {
            cout << ivd_Versions::GetVersionStringDetail() << endl;
        }
        else {
            cout << ivd_Versions::GetVersionString() << endl;
        }
        exit(0);
        break;

    case cc_HELP :
        HelpDump();
        exit(0);
        break;

    default: ; // others commands will be executed by cli
    }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 55 of file cli_arg.h.

Referenced by cfg_CliBase(), and Refresh().

most common cli values

Definition at line 69 of file cli_arg.h.

Referenced by cfg_CliBase(), and main().

Definition at line 53 of file cli_arg.h.

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

Definition at line 61 of file cli_arg.h.

Referenced by cfg_CliBase(), and Refresh().

Definition at line 60 of file cli_arg.h.

Referenced by cfg_CliBase(), and Refresh().

Definition at line 62 of file cli_arg.h.

Referenced by cfg_CliBase(), and Refresh().

Definition at line 59 of file cli_arg.h.

Referenced by cfg_CliBase(), and Refresh().

Definition at line 79 of file cli_arg.h.

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

Definition at line 76 of file cli_arg.h.

Referenced by cfg_CliBase().

Definition at line 75 of file cli_arg.h.

Referenced by cfg_CliBase(), and main().

Definition at line 100 of file cli_arg.h.

Definition at line 70 of file cli_arg.h.

Referenced by cfg_CliBase(), and main().

Definition at line 66 of file cli_arg.h.

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

Definition at line 65 of file cli_arg.h.

Referenced by Refresh().

Definition at line 78 of file cli_arg.h.

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

Definition at line 77 of file cli_arg.h.

Referenced by cfg_CliBase(), and main().

Definition at line 72 of file cli_arg.h.

Referenced by cfg_CliBase(), and main().

Definition at line 73 of file cli_arg.h.

Referenced by cfg_CliBase(), and main().

Definition at line 80 of file cli_arg.h.

Referenced by cfg_CliBase(), and Refresh().


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