本文整理汇总了C++中Match::setNode方法的典型用法代码示例。如果您正苦于以下问题:C++ Match::setNode方法的具体用法?C++ Match::setNode怎么用?C++ Match::setNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Match
的用法示例。
在下文中一共展示了Match::setNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: st
Match *Kernel::match(Nodemaster *node, Nodemaster *parent, int state, const string &input, const string &star, const string &path) {
StringTokenizer st(input);
if (st.countTokens() == 0) {
if (node->hasTemplate()) {
Match *m = new Match();
m->setNode(node);
m->addTopicStar(trim(star));
m->setTopicPattern(trim(path));
return m;
}
return NULL;
}
string word = st.nextToken();
string uWord = toUpper(word);
string tail = "";
Match *m = NULL;
if (st.hasMoreTokens()) {
tail = trim(input.substr(word.length()));
}
int index = constants.find(" " + word + " ");
if (index != string::npos) {
if (node->getChild(uWord) != NULL) {
m = match(node->getChild(uWord), node, state + 1, tail, "", "");
if (m != NULL) {
addStar(m, trim(star), state);
addPath(m, trim(path), state);
}
}
return m;
}
if (node->getChild("_") != NULL) {
m = match(node->getChild("_"), node, state, tail, word, path + " _");
if (m != NULL) {
addStar(m, trim(star), state);
return m;
}
}
if (node->getChild(uWord) != NULL) {
m = match(node->getChild(uWord), node, state, tail, star, path + " " + word);
if (m != NULL) {
return m;
}
}
if (node->getChild("@") != NULL) {
// This one is a bit of a mystery to get figured out
//Vector queries = node.getQueries();
//for (int ix = 0; ix < queries.size(); ++ix) {
//String type = (String)queries.elementAt(ix);
//if (lookup(type, star.trim()) == true) {
//m = match(node.getChild("@" + type), node, state, tail, word, path + " @" + type);
//if (m != null) {
//addStar(m, star.trim(), state);
//return m;
//}
//}
//}
}
if (node->getChild("*") != NULL) {
m = match(node->getChild("*"), node, state, tail, word, path + " *");
if (m != NULL) {
addStar(m, trim(star), state);
return m;
}
}
if (node == parent->getChild("*") ||
node == parent->getChild("_") ||
node == parent->getChild("@")) {
return match(node, parent, state, tail, star + " " + word, path);
}
return NULL;
}