⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cimsubcommand.cpp

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 CPP
📖 第 1 页 / 共 5 页
字号:
    String handlerNameString;    Boolean filterSet = false;    Boolean handlerSet = false;    //    //  Construct optString    //    optString.append(OPTION_LIST);    optString.append(getoopt::GETOPT_ARGUMENT_DESIGNATOR);    optString.append(OPTION_DISABLE);    optString.append(OPTION_ENABLE);    optString.append(OPTION_REMOVE);    optString.append(getoopt::GETOPT_ARGUMENT_DESIGNATOR);    optString.append(OPTION_VERBOSE);    optString.append(OPTION_FILTER);    optString.append(getoopt::GETOPT_ARGUMENT_DESIGNATOR);    optString.append(OPTION_HANDLER);    optString.append(getoopt::GETOPT_ARGUMENT_DESIGNATOR);    optString.append(OPTION_NAMESPACE);    optString.append(getoopt::GETOPT_ARGUMENT_DESIGNATOR);    //    //  Initialize and parse options    //    getoopt options("");    options.addFlagspec(optString);    options.addLongFlagspec(LONG_HELP,getoopt::NOARG);    options.addLongFlagspec(LONG_VERSION,getoopt::NOARG);    options.parse(argc, argv);    if (options.hasErrors())    {        throw CommandFormatException(options.getErrorStrings()[0]);    }    _operationType = OPERATION_TYPE_UNINITIALIZED;    //    //  Get options and arguments from the command line    //    for (i = options.first(); i <  options.last(); i++)    {        if (options[i].getType () == Optarg::LONGFLAG)        {            if (options[i].getopt() == LONG_HELP)            {                if (_operationType != OPERATION_TYPE_UNINITIALIZED)                {                    //                    // More than one operation option was found                    //                    throw UnexpectedOptionException(LONG_HELP);                }               _operationType = OPERATION_TYPE_HELP;            }            else if (options[i].getopt() == LONG_VERSION)            {                if (_operationType != OPERATION_TYPE_UNINITIALIZED)                {                    //                    // More than one operation option was found                    //                    throw UnexpectedOptionException(LONG_VERSION);                }                _operationType = OPERATION_TYPE_VERSION;            }        }        else if (options [i].getType() == Optarg::REGULAR)        {            //            //  The cimsub command has no non-option argument options            //            throw UnexpectedArgumentException(options[i].Value());        }        else        {            c = options[i].getopt()[0];            switch (c)            {                case OPTION_DISABLE:                {                    if (_operationType != OPERATION_TYPE_UNINITIALIZED)                    {                        //                        // More than one operation option was found                        //                        throw UnexpectedOptionException(OPTION_DISABLE);                    }                    if (options.isSet(OPTION_DISABLE) > 1)                    {                        //                        // More than one disable subscription option was found                        //                        throw DuplicateOptionException(OPTION_DISABLE);                    }                    _operationType = OPERATION_TYPE_DISABLE;                    break;                }                case OPTION_ENABLE:                {                    if (_operationType != OPERATION_TYPE_UNINITIALIZED)                    {                        //                        // More than one operation option was found                        //                        throw UnexpectedOptionException (OPTION_ENABLE);                    }                    if (options.isSet(OPTION_ENABLE) > 1)                    {                        //                        // More than one enable option was found                        //                        throw DuplicateOptionException (OPTION_ENABLE);                    }                    _operationType = OPERATION_TYPE_ENABLE;                    break;                }                case OPTION_LIST:                {                    if (_operationType != OPERATION_TYPE_UNINITIALIZED)                    {                        //                        // More than one operation option was found                        //                        throw UnexpectedOptionException(OPTION_LIST);                    }                    if (options.isSet(OPTION_LIST) > 1)                    {                        //                        // More than one list option was found                        //                        throw DuplicateOptionException (OPTION_LIST);                    }                    _operationType = OPERATION_TYPE_LIST;                    _operationArg = options[i].Value();                    break;                }                case OPTION_REMOVE:                {                    if (_operationType != OPERATION_TYPE_UNINITIALIZED)                    {                        //                        // More than one operation option was found                        //                        throw UnexpectedOptionException(OPTION_REMOVE);                    }                    if (options.isSet(OPTION_REMOVE) > 1)                    {                        //                        // More than one remove option was found                        //                        throw DuplicateOptionException(OPTION_REMOVE);                    }                    _operationType = OPERATION_TYPE_REMOVE;                    _operationArg = options[i].Value();                    break;                }                case OPTION_VERBOSE:                {                  if (_operationType != OPERATION_TYPE_LIST)                    {                        //                        // Unexpected verbose option was found                        //                        throw UnexpectedOptionException(OPTION_VERBOSE);                    }                    if (options.isSet(OPTION_VERBOSE) > 1)                    {                        //                        // More than one verbose option was found                        //                        throw DuplicateOptionException(OPTION_VERBOSE);                    }                    _verbose = true;                    break;                }                case OPTION_FILTER:                {                    if ((_operationType == OPERATION_TYPE_HELP) ||                        (_operationType == OPERATION_TYPE_VERSION))                    {                        //                        // Help and version take no options.                        //                        throw UnexpectedOptionException(OPTION_FILTER);                    }                    if (options.isSet(OPTION_FILTER) > 1)                    {                        //                        // More than one filter option was found                        //                        throw DuplicateOptionException(OPTION_FILTER);                    }                    filterNameString = options[i].Value();                    filterSet = true;                    break;                }                case OPTION_HANDLER:                {                    if ((_operationType == OPERATION_TYPE_HELP) ||                        (_operationType == OPERATION_TYPE_VERSION))                    {                        //                        // Help and version take no options.                        //                        throw UnexpectedOptionException(OPTION_HANDLER);                    }                    if (options.isSet(OPTION_HANDLER) > 1)                    {                        //                        // More than one handler option was found                        //                        throw DuplicateOptionException(OPTION_HANDLER);                    }                    handlerNameString = options[i].Value();                    handlerSet = true;                    break;                }                case OPTION_NAMESPACE:                {                    if ((_operationType == OPERATION_TYPE_HELP) ||                        (_operationType == OPERATION_TYPE_VERSION))                    {                        //                        // Help and version take no options.                        //                        throw UnexpectedOptionException(OPTION_NAMESPACE);                    }                    if (options.isSet(OPTION_NAMESPACE) > 1)                    {                        //                        // More than one namespace option was found                        //                        throw DuplicateOptionException(OPTION_NAMESPACE);                    }                    String nsNameValue = options[i].Value();                    _subscriptionNamespace = nsNameValue;                    break;                }                default:                    PEGASUS_ASSERT(0);                }            }        }    //    // Some more validations    //    if (_operationType == OPERATION_TYPE_UNINITIALIZED)    {        //        // No operation type was specified        // Show the usage        //        throw CommandFormatException(localizeMessage(            MSG_PATH, REQUIRED_OPTION_MISSING_KEY, REQUIRED_OPTION_MISSING));    }    if (_operationType == OPERATION_TYPE_LIST)    {        if (_operationArg == ARG_FILTERS)        {            if (handlerSet)            {                //                // Wrong option for this operation                // was found                //                throw UnexpectedOptionException(OPTION_HANDLER);            }        }        else if (_operationArg == ARG_HANDLERS)        {            if (filterSet)            {                //                // Wrong option for this operation was found                //                throw UnexpectedOptionException                    (OPTION_FILTER);            }        }        else if (_operationArg != ARG_SUBSCRIPTIONS)        {            //            // A wrong option argument for this            // operation was found            //            throw InvalidOptionArgumentException(                _operationArg, OPTION_LIST);        }    }    if (_operationType == OPERATION_TYPE_DISABLE)    {        if (!filterSet)        {            throw MissingOptionException(OPTION_FILTER);        }        if (!handlerSet)        {            throw MissingOptionException(OPTION_HANDLER);        }    }    if (_operationType == OPERATION_TYPE_ENABLE)    {        if (!filterSet)        {            throw MissingOptionException(OPTION_FILTER);        }        if (!handlerSet)        {            throw MissingOptionException(OPTION_HANDLER);        }    }    if (_operationType == OPERATION_TYPE_REMOVE)    {        if (_operationArg == ARG_FILTERS)        {            if (handlerSet)            {                //                // Wrong option for this                // operation was found                //                throw UnexpectedOptionException(                    OPTION_HANDLER);            }        }        else        {            if (_operationArg == ARG_HANDLERS)            {                if (filterSet)                {                    //                    // Wrong option for this operation was found                    //                    throw UnexpectedOptionException(OPTION_FILTER);                }            }            else            {                if ((_operationArg != ARG_SUBSCRIPTIONS) &&                    (_operationArg != ARG_ALL))                {                    //                    // A wrong option argument for this operation                    // was found                    //                    throw InvalidOptionArgumentException                        (_operationArg, OPTION_REMOVE);                }            }        }        if ((_operationArg == ARG_SUBSCRIPTIONS) ||            (_operationArg == ARG_ALL) ||            (_operationArg == ARG_FILTERS))        {          if (!filterSet)            {                throw MissingOptionException(OPTION_FILTER);            }        }        if ((_operationArg == ARG_SUBSCRIPTIONS) ||            (_operationArg == ARG_ALL) ||            (_operationArg == ARG_HANDLERS))        {            if (!handlerSet)            {                throw MissingOptionException(OPTION_HANDLER);            }        }    }    if (filterSet)    {        _parseFilterName(filterNameString, _filterName, _filterNamespace);    }    if (handlerSet)    {        _parseHandlerName(handlerNameString, _handlerName, _handlerNamespace,            _handlerCreationClass);    }}/**    Executes the command and writes the results to the PrintWriters.*/Uint32 CIMSubCommand::execute(    ostream& outPrintWriter,    ostream& errPrintWriter){    Array<CIMNamespaceName> namespaceNames;    //    // The CIM Client reference    //

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -