本文整理汇总了C++中DataNode::getNodeName方法的典型用法代码示例。如果您正苦于以下问题:C++ DataNode::getNodeName方法的具体用法?C++ DataNode::getNodeName怎么用?C++ DataNode::getNodeName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataNode
的用法示例。
在下文中一共展示了DataNode::getNodeName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
DataNode*
DataNode::getChild(string nodeName, int index)
{
DataNode* pNode;
int curIndex=0;
vector<DataNode*>::iterator itr;
for (itr = m_childList.begin();itr != m_childList.end();itr++)
{
pNode = *itr;
if (!pNode->getNodeName().compare(nodeName))
{
if (curIndex == index)
{
return pNode;
}
else
{
curIndex++;
}
}
else
{
// Do nothing
}
}
return NULL;
}
示例2: Exception
DataNode*
MasterCVReader::readConfigFile(string fileName)
{
DataNode* parentNode = NULL;
DataNode* curNode = NULL;
FILE* conf;
Attribute attrib;
MasterCVState state;
char lastCharacter;
string token;
state = WAIT_FOR_OPEN_BRACKET;
try
{
// Check if the codec was set or not
if (!m_codec)
{
throw Exception("MasterCVReader::readConfigFile() : fatal error codec was not set properly", 1);
}
// State machine implement configuration reader
conf = fopen(fileName.c_str(), "r");
if (conf)
{
while (!feof(conf))
{
switch(state) {
case WAIT_FOR_OPEN_BRACKET:
char c;
c = 0;
c = m_codec->getNextChar(conf);
if (c == 0 && feof(conf) && curNode->dataNodeComplete)
{
return curNode;
}
if (m_codec->blankCharacter(c))
{
state = WAIT_FOR_OPEN_BRACKET;
break;
}
if (c == '<')
{
state = WAIT_FOR_DATANODE_NAME;
}
else
{
string msg;
msg.append("MasterCVReader::readConfigFile() : Invalid configuration file expect < instead of");
msg.append(1, c);
throw Exception(msg, 2);
}
break;
case WAIT_FOR_DATANODE_NAME:
lastCharacter = 0;
token.clear();
m_codec->getNextToken(conf, token, lastCharacter);
if (token.empty())
{
if (feof(conf) && curNode->dataNodeComplete)
{
return curNode;
}
else if (lastCharacter == '/')
{
if (!curNode->dataNodeComplete)
{
state = WAIT_FOR_CLOSE_DATANODE_NAME;
}
else
{
string msg;
msg.append("MasterCVReader::readConfigFile() : Duplicate close tag for ");
msg.append(curNode->getNodeName());
throw Exception(msg);
}
}
else
{
throw Exception("MasterCVReader::readConfigFile() : Invalid DataNode Name", 2);
}
}
else
{
if (!curNode) // This is actually root node
{
curNode = new DataNode();
}
else
{
parentNode = curNode;
curNode = new DataNode();
}
if (curNode)
{
if (parentNode)
//.........这里部分代码省略.........