本文整理汇总了C++中Operand::GetVariable方法的典型用法代码示例。如果您正苦于以下问题:C++ Operand::GetVariable方法的具体用法?C++ Operand::GetVariable怎么用?C++ Operand::GetVariable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Operand
的用法示例。
在下文中一共展示了Operand::GetVariable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Operand
Operand (const Operand &cp) {
action = cp.GetAction();
variable = cp.GetVariable();
time = cp.GetTime();
location = cp.GetLocation();
if (cp.GetTimeRange() != NULL) {
time_range = new string[2];
time_range[0] = cp.GetTimeRange()[0];
time_range[1] = cp.GetTimeRange()[1];
} else
time_range = NULL;
if (cp.GetNodeRange() != NULL) {
node_range = new string[2];
node_range[0] = cp.GetNodeRange()[0];
node_range[1] = cp.GetNodeRange()[1];
} else
node_range = NULL;
}
示例2: SetVariable
void SetVariable(string word,
Operand *&currod,
queue<Operand*> &ods,
stack<string> &bucket,
int *currop,
int *opcount,
register int &bracket_ct,
register int &currop_ind) {
if (currod->GetVariable() == DefaultComponent) {
currod->SetVariable(word);
} else {
Operand *od = new Operand(*currod);
if (od->GetVariable() != DefaultComponent) {
ods.push(od);
opcount[currop_ind] += 1;
if (opcount[currop_ind] == currop[currop_ind]) {
FixMissingEntriesAndFillTheBucket(ods, bucket);
bucket.push(OpenBracket);currop_ind--;opcount[currop_ind] += 1;bracket_ct--;
}
}
ResetCurrentOperand(currod, word, DefaultAction, DefaultWhen, DefaultLocation, NULL, NULL);
}
}
示例3: main
int main() {
stack<string> tree_bucket;
char command[100];
gets(command);
vector<string> words;
stack<string> bucket;
string nx_command = EmptyString;
queue<Operand*> ods;
queue<Operand*> temp;
string cmd = command;
cmd = ReplaceCommaBySpaceAnd(cmd);
istringstream iss(cmd);
while (getline(iss, cmd, ' '))
words.push_back(cmd);
string word;
Operand *currod = new Operand();
register int is_op, bracket_ct = 0, first_time = 0, currop_ind = -1;
int currop[100];
int opcount[100] = {0};
for(register int i = 0; i < words.size(); i++) {
word = words[i];
//Set NX Command
SetNXCmd(word, nx_command);
//Check for operator
is_op = IsPresentInOperators(word);
if(is_op != -1) {
bucket.push(ClosedBracket);bracket_ct++;
bucket.push(operators[is_op][1]);
currop[++currop_ind] = IsWhichOperator(operators[is_op][1]);
//Check for subtraction if between/from interpretation
CheckForAbnormalOperators(operators[is_op][1], i, words, bucket);
//Find its operands
i++;
while (i < words.size()) {
word = words[i];
//Set NX Command
SetNXCmd(word, nx_command);
is_op = IsPresentInOperators(word);
if (is_op != -1) {
if (((currod->GetVariable() != DefaultComponent) || (currod->GetAction() != DefaultAction)) && ((opcount[currop_ind]+1) == currop[currop_ind])) {
} else if (i != 0) {
if ((IsPartOfOperand(words[i-1])) || (IsStringANumber(words[i-1]))) {
bucket.push(ClosedBracket);bracket_ct++;
FillTheBucket(currod, bucket);
ResetCurrentOperand(currod);
bucket.push(operators[is_op][1]);
currop[++currop_ind] = IsWhichOperator(operators[is_op][1]);
opcount[currop_ind] += 1;
break;
}
}
Operand *od = new Operand(*currod);
ods.push(od);
opcount[currop_ind] += 1;
bool inside = FixMissingEntriesAndFillTheBucket(ods, bucket);
ResetCurrentOperand(currod);
if (inside == 1) {
if (opcount[currop_ind] == currop[currop_ind]) {
bucket.push(OpenBracket);
bucket.push(BlankSpace);
currop_ind--;bracket_ct--;
currop[++currop_ind] = IsWhichOperator(operators[is_op][1]);
if (currop[currop_ind] != 1) {
//Bracket resolution for this particular condition
PushBracketBackWhenOperator(bracket_ct, bucket);
//Bracket resolution is done
bucket.push(operators[is_op][1]);
CheckForAbnormalOperators(operators[is_op][1], i, words, bucket);
} else {
bucket.push(ClosedBracket);bracket_ct++;
bucket.push(operators[is_op][1]);
CheckForAbnormalOperators(operators[is_op][1], i, words, bucket);
}
} else {
bucket.push(BlankSpace);
i--;
}
}
else {
opcount[currop_ind] -= 1;
bucket.push(BlankSpace);
i--;
}
break;
}
if (IsVariable(word)) {
SetVariable(word, currod, ods, bucket, currop, opcount, bracket_ct, currop_ind);
} else if (IsAction(word)) {
SetAction(word, currod, ods, bucket, currop, opcount, bracket_ct, currop_ind);
} else if (IsLocation(word)) {
SetLocation(word, currod, words, i);
} else if (IsTime(word)) {
SetTime(word, currod, words, i);
}
i++;
//.........这里部分代码省略.........
示例4: FixMissingEntriesAndFillTheBucket
bool FixMissingEntriesAndFillTheBucket(queue<Operand*> &ods, stack<string> &bucket) {
//Fix missing entries
queue<Operand*> temp;
register bool inside = 0;
temp = ods;
while (ods.size() != 1)
ods.pop();
Operand *tmpod = new Operand(*(ods.front()));
string *rt = tmpod->GetTimeRange();
string *rl = tmpod->GetNodeRange();
string tact = tmpod->GetAction();
string rtime = tmpod->GetTime();
string rloc = tmpod->GetLocation();
ods = temp;
//pop entire queue
string when = BlankSpace, loc = BlankSpace;
while (ods.size() != 0) {
when = BlankSpace, loc = BlankSpace;
Operand *t = new Operand(*(ods.front()));
when.append(t->GetTime());when.append(BlankSpace);
loc.append(t->GetLocation()); loc.append(BlankSpace);
if (t->GetTimeRange() == NULL) {
t->SetTimeRange(rt);
}
if (t->GetNodeRange() == NULL)
t->SetNodeRange(rl);
if (t->GetAction() == DefaultAction)
t->SetAction(tact);
if (t->GetTime() == DefaultWhen)
t->SetTime(rtime);
if (t->GetLocation() == DefaultLocation)
t->SetLocation(rloc);
if (t->GetTimeRange() != NULL) {
when.append(t->GetTimeRange()[0]);
if (t->GetTimeRange()[1] != EmptyString) {
when.append(ToKeyword);
when.append(t->GetTimeRange()[1]);
}
} else {
when.append(DefaultWhenValue);
}
if (t->GetNodeRange() != NULL) {
loc.append(t->GetNodeRange()[0]);
if (t->GetNodeRange()[1] != EmptyString) {
loc.append(ToKeyword);
loc.append(t->GetNodeRange()[1]);
}
} else {
loc.append(DefaultLocationValue);
}
if ((t->GetVariable() != DefaultComponent) || (t->GetAction() != DefaultAction)) {
inside = 1;
bucket.push(BlankSpace);
bucket.push(when);
bucket.push(loc);
bucket.push(t->GetAction());
bucket.push(BlankSpace);
bucket.push(t->GetVariable());
}
ods.pop();
}
return inside;
}