本文整理汇总了C++中Executer::setCount方法的典型用法代码示例。如果您正苦于以下问题:C++ Executer::setCount方法的具体用法?C++ Executer::setCount怎么用?C++ Executer::setCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Executer
的用法示例。
在下文中一共展示了Executer::setCount方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: execute
int Parser::execute()
{
// If I use my imagination hard enough
// this will magically work
// every odd number is a connector (besides the last one);
// 0 and even numbers are the commands
int status = 0;
unsigned int i = 0;
Executer E;
// if user puts "ls test ||" or "echo test &&", etc
// then prompt the user ">" and another command
if ((cmd.size() != 1) && ((cmd.back() == "||") || (cmd.back() == "&&")))
{
string cmd;
cout << ">";
getline(cin, cmd);
setCommand(cmd);
parse();
}
//for(unsigned int i = 0; i < cmd.size(); i++)
// cout << i << ": " << cmd.at(i) << endl;
//for(unsigned int i = 0; i < test.size(); i++)
// cout << test[i] << endl;
//for(unsigned int i = 0; i < cmd.size(); i++)
// cout << cmd[i] << endl;
// this loop analyzes the connectors
// and determines what gets runned
while(i < cmd.size())
{
E.setCount(i);
this->bPtr = &E;
status = bPtr->execute();
if(status == -1) // if status is -1 then "exit was inputted"
{ // so we want to exit rshell program
return status;
}
// should on on connector now
// b/c connectors are on odd numbers
i++;
if(i >= cmd.size())
{
return status;
}
if(cmd.at(i) == ";")
{
//cout << "Before i++" << endl;
i++;
//cout << "After i++" << endl;
}
// if next one is && move to the next one if
// previous worked
else if(cmd.at(i) == "&&")
{
// if previous worked
if(status == 0)
{
i++; // go to the next command
}
else
{
i+=3; // moves on to next connector
}
}
else if(cmd.at(i) == "||")
{
// if previous failed
if(status == 149)
{
i++; // go to the next command
}
else
{
i+=3;
}
}
//cout << "i after everything: " << i << endl;
if(isOdd(i) || i > cmd.size())
{
//cout << "goes here" << endl;
return status;
}
}
return status;
}