当前位置: 首页>>代码示例>>C++>>正文


C++ CommandParser类代码示例

本文整理汇总了C++中CommandParser的典型用法代码示例。如果您正苦于以下问题:C++ CommandParser类的具体用法?C++ CommandParser怎么用?C++ CommandParser使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CommandParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

Package* HelpCommandParser::constructPackageFromLine(int argc, const char **argv, std::string packageID)
{
    if(argc == 1)
    {
        std::cout<<"Possible commands are:"<<std::endl;
        for(std::map<std::string, CommandParser*>::iterator iter = commands->begin(); iter != commands->end(); iter++)
        {
            if(iter->second)
            {
                std::cout<<"\t"<<std::left<<std::setw(maxCommandNameLength)<<iter->second->getCommand()<<"\t"<<std::setw(0)<<iter->second->getDescription()<<std::endl;
            }
        }
    }
    else if(argc > 1)
    {
        CommandParser *parser = retrieveCommandParser(std::string(argv[1]));
        if(parser)
        {
            parser->printParameterHelp();
        }
        else
        {
            std::cout<<"help: the specified command doesn't exist"<<std::endl;
        }
    }
    return NULL;
}
开发者ID:profmaad,项目名称:yonderboy,代码行数:27,代码来源:help_command_parser.cpp

示例2: main

int main(int argc, char* argv[]) {
    mreal::initPrecision();
    mreal::initRand();

    CommandParser commandParser;
    initCommands(&commandParser);

    CommandFactory commandFactory;

    try {
        int commandCode = UNKNOWN_COMMAND;
        CommandParams commandParams;
        commandParser.getCommandCodeAndParams(argc, argv, commandCode, commandParams);

        ContextPtr pContext = Context::setup(DRY_MODE, ".3app");
        CommandPtr pCommand = commandFactory.getCommand(commandCode, commandParams);
        pCommand->execute();
        _destroy(pCommand);

        delete pContext;
    }
    catch(std::exception const& e) {
        std::cout << e.what() << std::endl;
        printSyntaxMessage();
    }
}
开发者ID:wws2003,项目名称:Research,代码行数:26,代码来源:Application.cpp

示例3: registerStatusCommands

void
registerStatusCommands(CommandParser& parser)
{
  CommandDefinition defStatusReport("status", "report");
  defStatusReport
    .setTitle("print full status report")
    .addArg("format", ArgValueType::REPORT_FORMAT, Required::NO, Positional::YES);
  parser.addCommand(defStatusReport, &reportStatusComprehensive);

  CommandDefinition defStatusShow("status", "show");
  defStatusShow
    .setTitle("print general status");
  parser.addCommand(defStatusShow, bind(&reportStatusSingleSection, _1, &StatusReportOptions::wantForwarderGeneral));
  parser.addAlias("status", "show", "");

  CommandDefinition defChannelList("channel", "list");
  defChannelList
    .setTitle("print channel list");
  parser.addCommand(defChannelList, bind(&reportStatusSingleSection, _1, &StatusReportOptions::wantChannels));
  parser.addAlias("channel", "list", "");

  CommandDefinition defFibList("fib", "list");
  defFibList
    .setTitle("print FIB entries");
  parser.addCommand(defFibList, bind(&reportStatusSingleSection, _1, &StatusReportOptions::wantFib));
  parser.addAlias("fib", "list", "");

  CommandDefinition defCsInfo("cs", "info");
  defCsInfo
    .setTitle("print CS information");
  parser.addCommand(defCsInfo, bind(&reportStatusSingleSection, _1, &StatusReportOptions::wantCs));
  parser.addAlias("cs", "info", "");
}
开发者ID:cawka,项目名称:NFD,代码行数:33,代码来源:status.cpp

示例4: completeName

void Completer::completeName(const CommandParser &parser)
{
  m_startIndex = parser.nameStart();
  m_endIndex = parser.nameEnd();

  const auto list = Command::findCommands(parser.name());

  for(const CommandEntry *entry : list) {
    addItem(entry->name);

    if(entry->hasFlag(CO_FORCE))
      addItem(entry->name + "!");
  }
}
开发者ID:cfillion,项目名称:island,代码行数:14,代码来源:completer.cpp

示例5: exec

void DMIParser::exec()
{
    bool readDescription = false;
    bool readFeatureList = true;
    std::string currentFeature = "";
    int currentIndex = -1;
    CommandParser *parser = CommandParser::Instance();
    std::stringstream o;
    o << "--type " << mType;
    parser->parse( "dmidecode", o.str(), true);
    std::vector<std::string> lines = parser->lines();
    parser->split(":");
    std::vector<std::vector<std::string> > fields = parser->fields();
    // Process the lines one by one
    for (unsigned int i = 0; i < lines.size() ; ++i) {
        if (readDescription) {
            mFrames[currentIndex].Description = lines[i];
            readDescription = false;
            continue;
        }
        if (lines[i].substr(0,6) == "Handle") {
            // Start new Frame
            Frame f;
            f.Handle = lines[i];
            mFrames.push_back(f);
            currentIndex++;
            readDescription = true;
            readFeatureList = false;
            continue;
        }
        if (currentIndex < 0)
            continue;
        if (lines[i].find(":") != std::string::npos) {
            readFeatureList = false;
        } else if (readFeatureList) {
            mFrames[currentIndex].FeatureData[currentFeature].push_back(lines[i]);
        }
        if (fields[i].size() == 2) {
            // Simple field
            readFeatureList = false;
            mFrames[currentIndex].Data[fields[i][0]] = fields[i][1];
        } else if (fields[i].size() == 1) {
            // Possible Feature list type field
            boost::trim(fields[i][0]);
            currentFeature = fields[i][0];
            readFeatureList = true;
        }

    }
}
开发者ID:mariusroets,项目名称:Audit-Agent,代码行数:50,代码来源:dmiparser.cpp

示例6: main

int main()
{
    CommandParser commandParser;
    string input;

    while ( !cin.eof() )
    {
        getline( cin, input );
        if(!commandParser.parse( input ))
        {
            LOGME( "Error executing: "<< input << endl );
        }
    }
    return 0;
}
开发者ID:saidinesh5,项目名称:ModularMadness,代码行数:15,代码来源:main.cpp

示例7: specFile

void Controller::parseSpecFile(std::string file)
{
    std::string expandedFilename;
    if(file[0] == '~')
    {
        file.erase(0,1);
        expandedFilename = std::string(getenv("HOME"));
        expandedFilename += file;
    }
    else
    {
        expandedFilename = file;
    }

    std::ifstream specFile(expandedFilename.c_str());
    
    if(!specFile.fail())
    {
        YAML::Parser specParser(specFile);
        YAML::Node specDoc;
        specParser.GetNextDocument(specDoc);
        
        for(int i=0; i<specDoc["commands"].size(); i++)
        {
            if(specDoc["commands"][i]["command"].GetType() == YAML::CT_SCALAR && specDoc["commands"][i]["source"].GetType() == YAML::CT_SEQUENCE)
            {
                std::string command;
                specDoc["commands"][i]["command"] >> command;
                
                // lets check whether this command is for us
                for(int s=0; s<specDoc["commands"][i]["source"].size(); s++)
                {
                    std::string source;
                    specDoc["commands"][i]["source"][s] >> source;
                    
                    if(source == "controller")
                    {
                        CommandParser *parser = new CommandParser(specDoc["commands"][i]);
                        commands->insert(std::make_pair(command, parser));

                        if(parser->getCommand().length() > maxCommandNameLength)
                        {
                            maxCommandNameLength = parser->getCommand().length();
                        }
                    }
                }
            }
        }
开发者ID:profmaad,项目名称:yonderboy,代码行数:48,代码来源:controller.cpp

示例8: registerLegacyStatusCommand

void
registerLegacyStatusCommand(CommandParser& parser)
{
  CommandDefinition defLegacyNfdStatus("legacy-nfd-status", "");
  defLegacyNfdStatus
    .addArg("args", ArgValueType::ANY, Required::NO, Positional::YES);
  parser.addCommand(defLegacyNfdStatus, &legacyNfdStatus, AVAILABLE_IN_ALL & ~AVAILABLE_IN_HELP);
}
开发者ID:named-data-ndnSIM,项目名称:NFD,代码行数:8,代码来源:legacy-status.cpp

示例9: read

void MacSoftware::read()
{
    Util::exec("pkgutil --package > /tmp/pkgutil.txt");
    CommandParser *c = CommandParser::Instance();
    c->parse("cat", "/tmp/pkgutil.txt");
    vector<string> lines = c->lines();
    for (int i = 0; i < (int)lines.size(); i++) {
        mSoftwareList.push_back(SoftwarePackage());
        mSoftwareList[i].name = lines[i];
        c->parse("pkgutil", "--pkg-info " + lines[i]);
        vector<string> lines2 = c->lines();
        c->split(":");
        vector<vector<string> > fields = c->fields();
        for (int j = 0; j < (int)lines2.size(); j++) {
            if (fields[j][0] == "version") {
                mSoftwareList[i].version = fields[j][1];
            }
            if (fields[j][0] == "install-time") {
                //TODO: Format the time which is a time_t to a string
                // and poplulate mSoftwareList[i].install_time
                //mSoftwareList[i].install_time = fields[j][1];
            }

        }
    }
}
开发者ID:mariusroets,项目名称:Audit-Agent,代码行数:26,代码来源:macsoftware.cpp

示例10: kernel_main

#include <idt.h>
#include <gdt.h>
#include <isrs.h>
#include <timer.h>
#include <irq.h>
#include "keyboard.h"
#include <terminal.h>
#include <Array.h>
#include <commandparser.h>
#include <system.h>
#include <vector.h>
#include "printf.h"
#include "types.h"
#include "callrealmode.h"
#include "multiboot.h"
#include "fat_filelib.h"
#include "filesystem.h"
#include "heap.h"
#include "std/string.h"
#include "include/assert.h"

extern "C" /* Use C link age for kernel_main. */
    void
    kernel_main()
{
    Terminal::install(Terminal::VgaColor::Blue, Terminal::VgaColor::Cyan);
    GDT::install();
    IDT::install();
    ISRs::install();
    IRQ::install();
    Timer::install();
    Keyboard::install();
    FileSystem::install();
    Heap::install();

    CommandParser commandParser;
    commandParser.start();

    ENDLESS_LOOP;
}
开发者ID:ZakharBondia,项目名称:AnOs,代码行数:40,代码来源:kernel.cpp

示例11: execute

  void
  execute(const std::string& cmd)
  {
    std::vector<std::string> args;
    boost::split(args, cmd, boost::is_any_of(" "));

    CommandParser parser;
    registerCommands(parser);

    std::string noun, verb;
    CommandArguments ca;
    ExecuteCommand execute;
    std::tie(noun, verb, ca, execute) = parser.parse(args, ParseMode::ONE_SHOT);

    Controller controller(face, m_keyChain);
    ExecuteContext ctx{noun, verb, ca, 0, out, err, face, m_keyChain, controller};
    execute(ctx);
    exitCode = ctx.exitCode;
  }
开发者ID:cawka,项目名称:NFD,代码行数:19,代码来源:execute-command-fixture.hpp

示例12: TEST

TEST(parser, parseToCmd) {

  std::string storeConfig = "services/store/test/data_store.conf";
  ResultCode code = ::idgs::util::singleton<DataStore>::getInstance().initialize(storeConfig);

  //string insert_cmd = "store.service insert {\"store_name\":\"Customer\"} key={\"c_custkey\":\"234000\"} value={\"c_name\":\"Tom0\",\"c_nationkey\":\"10\",\"c_phone\":\"13500000000\"}";
  string insert_cmd = "store.service insert {\"store_name\":\"Orders\"} key={\"o_orderkey\":\"100000\"} value={\"o_custkey\":\"234000\",\"o_orderstatus\":\"2\",\"o_totalprice\":\"200.55\",\"o_orderdate\":\"2013-02-01\"}";

  CommandParser parser;
  Command command;
  code = parser.parse(insert_cmd, &command);
  ASSERT_EQ(RC_SUCCESS, code);
  ASSERT_EQ("store.service", command.actorId);
  ASSERT_EQ("insert", command.opName);
  ASSERT_EQ("{\"store_name\":\"Orders\"}", command.payload);
/*  for(auto it = command.attachments.begin(); it!=command.attachments.end(); ++it) {
    LOG(INFO) << "get Attachment " << it->first << " | " << it->second;
  }*/
}
开发者ID:XiaominZhang,项目名称:raf,代码行数:19,代码来源:parser_test.cpp

示例13: addEvent

void HistoryHandler::addEvent (CommandParser& test)
{
    int index = masterList[0].dateDifference(test.getDateObj());
    if (masterList.size()<=index)
        fillDates(index);
    
    masterList[index].addEvent(	test.getId(), 
                                test.getInputName(), 
                                test.getInputLocation(), 
                                test.getStartTimeObj(), 
                                test.getEndTimeObj(), 
                                test.getInputEventType(), 
                                test.getEventStatus());	
}
开发者ID:ishaansingal,项目名称:Tempus,代码行数:14,代码来源:HistoryHandler.cpp

示例14:

void CommandCC110LPrint::parse(CommandParser & cmdParser) {
    //bool           boolParam;
    //float          floatParam;
    //double         doubleParam;
    //int            intParam;
    //unsigned int   uintParam;
    //std::string    stringParam;

    // default value true
    this->mExecutable = true;

    // test reversed
    cmdParser.read("-", this->mWhat);
}
开发者ID:rtreichl,项目名称:weather_station,代码行数:14,代码来源:CommandPrintCC110L.cpp

示例15: read

void LinuxOS::read()
{

    mName = Util::exec("uname -s");
    boost::trim(mName);
    std::string kernel = Util::exec("uname -r");
    boost::trim(kernel);
    std::vector<std::string> tokens;
    boost::split(tokens, kernel, boost::is_any_of("."));
    mMajorVersion = tokens[0];
    mMinorVersion = tokens[1];
    mBuild = tokens[2];


    CommandParser *c = CommandParser::Instance();
    c->parse("lsb_release", " -a");
    c->split(":");
    std::vector<std::vector<std::string> > fields2 = c->fields();
    for (unsigned int i = 0; i < fields2.size() ; ++i) {
        if (fields2[i].size() <= 0)
            continue;
        if (fields2[i][0] == "Description") {
            mName = fields2[i][1];
        }
        if (fields2[i][0] == "Release") {
            mMajorVersion = fields2[i][1];
            mMinorVersion = "";
            mBuild = kernel;
        }
    }

    c->parse("cat", "/etc/*-release");
    c->split("=");
    std::vector<std::vector<std::string> > fields = c->fields();
    for (unsigned int i = 0; i < fields.size() ; ++i) {
        if (fields[i].size() <= 0)
            continue;
        if (fields[i][0] == "PATCHLEVEL") {
            mMinorVersion = fields[i][1];
        }
    }
    
    /*
     * Slackware: /etc/slackware-version
Mandrake: /etc/mandrake-release
Red Hat: /etc/redhat-release
Fedora: /etc/fedora-release
Suse :  /etc/SuSE-release
United : /etc/UnitedLinux-release
Debian : /etc/debian_version
*/
}
开发者ID:mariusroets,项目名称:Audit-Agent,代码行数:52,代码来源:linuxos.cpp


注:本文中的CommandParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。