本文整理汇总了C++中Commands类的典型用法代码示例。如果您正苦于以下问题:C++ Commands类的具体用法?C++ Commands怎么用?C++ Commands使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Commands类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main()
{
size_t i = 0;
while (cin.good()) {
WorldStatusUpdate world;
readProtoFromStream(world, cin);
cerr << "Tick: " << i << endl;
cerr << "Proto content with DebugString" << endl;
cerr << world.DebugString() << endl;
Commands commands;
Commands::Command* command = commands.add_commands();
command->set_commandtype(Commands::TRAIN);
Commands::Train* train = command->mutable_traincommand();
train->set_withwhat("Champion");
train->set_what(Commands::WORKER);
writeProtoOnStream(commands, cout);
++i;
}
return 0;
}
示例2: _handle_options
static int
_handle_options(int argc, char **argv)
{
int i;
while(argc > 0)
{
const char *cmd = argv[0];
for (i = 0; i < ARRAY_SIZE(commands); i++) {
Commands *c = commands + i;
if (strcmp(c->cmd, cmd))
continue;
if (c->fn)
c->fn(argc, argv);
}
argv++;
argc--;
}
return 0;
}
示例3: while
void CommandMgr::ClearCommands()
{
while (!commandTable.empty())
{
Commands::iterator itr = commandTable.begin();
delete itr->second;
commandTable.erase(itr);
}
}
示例4:
~Rule()
{
delete filter_;
typedef Commands::const_iterator It;
for (It i = cmds_->begin(); i != cmds_->end(); ++i) {
delete *i;
}
delete cmds_;
}
示例5: main
int main()
{
Commands Input;
Input.Input();
ParseText();
return 0;
}
示例6: match
void Cmd_struct::match()
{
int choice = -1;
// first four letters are commands
string substring = this->command.substr(0,4);
string file = "";
Commands commands;
// get the commands from textResources\\basicCommands.txt
vector<string> command_codes = commands.getCodes();
// Iterate over all basic commands
for (int i = 0; i < command_codes.size(); i++)
{
if (substring == command_codes[i])
{
choice = i;
}
}
if(choice == 3 || choice == 6)
{
// If we search there is a search query
file = this->command.substr(5, this->command.length() - 5);
}
FunctionHandler fh;
switch (choice)
{
case 0:
this->test();
break;
case 1:
this->shutdown();
break;
case 2:
this->chrom();
break;
case 3:
this->playMedia(file);
break;
case 4:
fh.executeBatch("ccleaner.bat");
break;
case 5:
fh.executeBatch("startuTorrent.bat");
break;
case 6:
this->closeProgram(file);
break;
default:
this->error();
break;
}
}
示例7: execute
boost::any execute(const command& c) const
{
Commands::const_iterator it = commands.find(c.name);
if (it != commands.end())
{
return (it->second.func)->execute(c);
}
else
{
return boost::any();//return std::string("unknown command");
}
}
示例8: generateCommands
Shrinkable<Commands<Cmd>> generateCommands(const Random &random,
int size) const {
return shrinkable::map(generateSequence(random, size),
[](const CommandSequence &sequence) {
Commands<Cmd> cmds;
const auto &entries = sequence.entries;
cmds.reserve(entries.size());
std::transform(begin(entries),
end(entries),
std::back_inserter(cmds),
[](const CommandEntry &entry) {
return entry.shrinkable.value();
});
return cmds;
});
}
示例9: main
int main(int argc, char *argv[])
{
MythFileRecorderCommandLineParser cmdline;
if (!cmdline.Parse(argc, argv))
{
cmdline.PrintHelp();
return GENERIC_EXIT_INVALID_CMDLINE;
}
if (cmdline.toBool("showhelp"))
{
cmdline.PrintHelp();
return GENERIC_EXIT_OK;
}
if (cmdline.toBool("showversion"))
{
cmdline.PrintVersion();
return GENERIC_EXIT_OK;
}
bool loopinput = !cmdline.toBool("noloop");
int data_rate = cmdline.toInt("data_rate");
QCoreApplication a(argc, argv);
QCoreApplication::setApplicationName("mythfilerecorder");
int retval;
if ((retval = cmdline.ConfigureLogging()) != GENERIC_EXIT_OK)
return retval;
QString filename = "";
if (!cmdline.toString("infile").isEmpty())
filename = cmdline.toString("infile");
else if (cmdline.GetArgs().size() >= 1)
filename = cmdline.GetArgs()[0];
Commands recorder;
recorder.Run(filename, data_rate, loopinput);
return GENERIC_EXIT_OK;
}
示例10: LBClear
void VDDialogEditAccelerators::RefilterCommands(const char *pattern) {
mFilteredCommands.clear();
LBClear(IDC_AVAILCOMMANDS);
Commands::const_iterator it(mAllCommands.begin()), itEnd(mAllCommands.end());
for(; it != itEnd; ++it) {
const VDAccelToCommandEntry& ent = **it;
if (VDFileWildMatch(pattern, ent.mpName)) {
const VDStringW s(VDTextAToW(ent.mpName));
mFilteredCommands.push_back(&ent);
LBAddString(IDC_AVAILCOMMANDS, s.c_str());
}
}
LBSetSelectedIndex(IDC_AVAILCOMMANDS, 0);
}
示例11: prepareCommands
Commands prepareCommands() {
Commands commands;
commands.push_back(Command {"set-led-state", "Set led state", {"on", "off"}});
commands.push_back(Command {"get-led-state", "Get led state", {}});
commands.push_back(Command {"set-led-color", "Set led color (red, green or blue)", {"red", "green", "blue"}});
commands.push_back(Command {"get-led-color", "Get led color", {}});
commands.push_back(Command {"set-led-rate", "Set led rate (0..5 Hz)", {"0", "1", "2", "3", "4", "5"}});
commands.push_back(Command {"get-led-rate", "Get led rate", {}});
return commands;
}
示例12: cmdGetItem
/** The command handler functions. */
bool cmdGetItem( Command& command )
{
const QueueGetItemPacket* packet = command.get< QueueGetItemPacket >();
Commands commands;
queue.tryPop( packet->itemsRequested, commands );
for( CommandsCIter i = commands.begin(); i != commands.end(); ++i )
{
Command* item = *i;
ObjectPacket* reply = item->getModifiable< ObjectPacket >();
reply->instanceID = packet->slaveInstanceID;
command.getNode()->send( *reply );
item->release();
}
if( packet->itemsRequested > commands.size( ))
{
QueueEmptyPacket reply( packet );
command.getNode()->send( reply );
}
return true;
}
示例13: getAction
pair<int,int> getAction(const Commands& commands) {
while ( true ) {
displayMenu(commands);
int choice = getNumber(0,commands.size());
int subChoice = 0;
if (choice == 0) return make_pair(-1,0);
if (!commands[choice-1].params.empty()) {
displaySubMenu(commands[choice-1].params);
subChoice = getNumber(0,commands[choice-1].params.size());
if (subChoice == 0)
continue;
}
return make_pair(choice-1, subChoice-1);
}
}
示例14: split
void ScreenOptionsMaster::Init()
{
vector<RString> asLineNames;
split( LINE_NAMES, ",", asLineNames );
if( asLineNames.empty() )
{
LuaHelpers::ReportScriptErrorFmt("\"%s:LineNames\" is empty.", m_sName.c_str());
}
if( FORCE_ALL_PLAYERS )
{
FOREACH_PlayerNumber( pn )
GAMESTATE->JoinPlayer( pn );
}
if( NAVIGATION_MODE == "toggle" )
SetNavigation( PREFSMAN->m_iArcadeOptionsNavigation? NAV_TOGGLE_THREE_KEY:NAV_TOGGLE_FIVE_KEY );
else if( NAVIGATION_MODE == "menu" )
SetNavigation( NAV_THREE_KEY_MENU );
SetInputMode( StringToInputMode(INPUT_MODE) );
// Call this after enabling players, if any.
ScreenOptions::Init();
vector<OptionRowHandler*> OptionRowHandlers;
for( unsigned i = 0; i < asLineNames.size(); ++i )
{
RString sLineName = asLineNames[i];
RString sRowCommands = LINE(sLineName);
Commands cmds;
ParseCommands( sRowCommands, cmds, false );
OptionRowHandler *pHand = OptionRowHandlerUtil::Make( cmds );
if( pHand == NULL )
{
LuaHelpers::ReportScriptErrorFmt("Invalid OptionRowHandler \"%s\" in \"%s:Line:%s\".", cmds.GetOriginalCommandString().c_str(), m_sName.c_str(), sLineName.c_str());
}
else
{
OptionRowHandlers.push_back( pHand );
}
}
InitMenu( OptionRowHandlers );
}
示例15: OnItemSelectionChanged
void VDDialogEditAccelerators::OnItemSelectionChanged(VDUIProxyListView *source, int index) {
if (index < 0 || mbBlockCommandUpdate)
return;
const BoundCommand& bcmd = *mBoundCommands[index];
if (mpHotKeyControl)
mpHotKeyControl->SetAccelerator(bcmd.mAccel);
uint32 n = mFilteredCommands.size();
int cmdSelIndex = -1;
for(uint32 i=0; i<n; ++i) {
const VDAccelToCommandEntry& cent = *mFilteredCommands[i];
if (!_stricmp(cent.mpName, bcmd.mpCommand)) {
cmdSelIndex = i;
break;
}
}
LBSetSelectedIndex(IDC_AVAILCOMMANDS, cmdSelIndex);
}