本文整理汇总了C++中TiXmlHandle::FirstChildElement方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlHandle::FirstChildElement方法的具体用法?C++ TiXmlHandle::FirstChildElement怎么用?C++ TiXmlHandle::FirstChildElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlHandle
的用法示例。
在下文中一共展示了TiXmlHandle::FirstChildElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadServer
void TinyXmlServerConfigImp::loadServer(TiXmlHandle &serverH){
TiXmlElement *portE = serverH.FirstChildElement("port").Element();
if(portE){
port = atoi(portE->GetText());
}
if(port == 0){
log(Fatal, "config port first");
exit(-1);
}
TiXmlElement *nameE = serverH.FirstChildElement("name").Element();
if(nameE){
//null to die;
name = nameE->GetText();
}
TiXmlElement *fportE = serverH.FirstChildElement("front_port").Element();
while(fportE){
uint16_t p = atoi(fportE->GetText());
if(p != 0)
frontPorts.push_back(p);
fportE = fportE->NextSiblingElement("front_port");
}
TiXmlElement *groupE = serverH.FirstChildElement("group").Element();
if(groupE){
groupId = atoi(groupE->GetText());
}else{
groupId = 0;
}
}
示例2: ReadXml
void Animation::ReadXml(const char* filename)
{
m_animationParts.clear(); // clear our parts list first
// create a new xml document
XmlDocument doc;
doc.Load(filename);
TiXmlHandle * hdoc = doc.Handle();
TiXmlElement * root = hdoc->FirstChildElement().Element();
if(root != 0)
{
TiXmlElement * child = root->FirstChildElement();
// loop through children
while(child)
{
// whats the name of this part
string partName = (string)child->Value();
// add this part to the part map
m_animationParts[partName] = new AnimationPart(child);
// move to the next game object
child = child->NextSiblingElement();
}
}
}
示例3: flushNodeSrvs
int MetaConfig::flushNodeSrvs(TiXmlHandle *meta)
{
std::vector<NodeService> tmp;
TiXmlHandle srvs = meta->FirstChildElement("services");
if(srvs.Element()){
TiXmlHandle srv = srvs.FirstChildElement("service");
while(srv.Element()){
NodeService ns;
loadInt(&srv, "gid", ns.gid, -1);
loadString(&srv, "name", ns.service, "");
loadString(&srv, "ip", ns.ip, "");
loadInt(&srv, "port", ns.port, -1);
if(!(ns.gid != -1 && !ns.service.empty() && !ns.ip.empty() && ns.port != -1)){
std::cerr << "load service error name:" << ns.service << " ip:" << ns.ip << " port:" << ns.port << " node:" << ns.gid<< std::endl;
return -1;
}
tmp.push_back(ns);
srv = srv.Element()->NextSibling("service");
}
std::sort(tmp.begin(), tmp.end());
std::unique(tmp.begin(), tmp.end());
}
boost::mutex::scoped_lock lock(mtx);
ndSrvs.swap(tmp);
return 0;
}
示例4: readTag
//---------------------------------------------------------
bool ofXMLSettings::readTag(string tag, char * valueString, int which){
vector<string> tokens = tokenize(tag,":");
TiXmlHandle tagHandle = *storedHandle;
for(int x=0;x<tokens.size();x++){
if(x == 0)tagHandle = tagHandle.ChildElement(tokens.at(x), which);
else tagHandle = tagHandle.FirstChildElement( tokens.at(x) );
}
// once we've walked, let's get that value...
TiXmlHandle valHandle = tagHandle.Child( 0 );
//now, clear that vector!
tokens.clear();
// if that value is really text, let's get the value out of it !
if (valHandle.Text()){
int maxLen = MIN(MAX_TAG_VALUE_LENGTH_IN_CHARS, strlen(valHandle.Text()->Value()));
memcpy(valueString, valHandle.Text()->Value(), maxLen);
return true;
} else {
return false;
}
}
示例5: writeAttribute
//---------------------------------------------------------
int ofxXmlSettings::writeAttribute(const string& tag, const string& attribute, const string& valueString, int which){
vector<string> tokens = tokenize(tag,":");
TiXmlHandle tagHandle = storedHandle;
for (int x = 0; x < (int)tokens.size(); x++) {
if (x == 0)
tagHandle = tagHandle.ChildElement(tokens.at(x), which);
else
tagHandle = tagHandle.FirstChildElement(tokens.at(x));
}
int ret = 0;
if (tagHandle.ToElement()) {
TiXmlElement* elem = tagHandle.ToElement();
elem->SetAttribute(attribute, valueString);
// Do we really need this? We could just ignore this and remove the 'addAttribute' functions...
// Now, just get the ID.
int numSameTags;
TiXmlElement* child = ( storedHandle.FirstChildElement( tokens.at(0) ) ).ToElement();
for (numSameTags = 0; child; child = child->NextSiblingElement( tokens.at(0) ), ++numSameTags) {
// nothing
}
ret = numSameTags;
}
return ret;
}
示例6: Initialise
void MaterialManager::Initialise(char *materialXMLFile)
{
// read through the xml file and load all materials
XmlDocument doc;
doc.Load(materialXMLFile);
TiXmlHandle * hdoc = doc.Handle();
TiXmlElement * root = hdoc->FirstChildElement().Element();
TiXmlElement * child = root->FirstChildElement();
// loop through our materials
while(child)
{
// get the name of the material
const char * matName = XmlUtilities::ReadAttributeAsString(child, "", "name");
// create the new material
Material* mat = new Material(matName);
mat->ReadXml(child); // read the properties
m_materialMap[matName] = mat; // add to the material map
// move to the next material
child = child->NextSiblingElement();
}
}
示例7: getElementForAttribute
//---------------------------------------------------------
TiXmlElement* ofxXmlSettings::getElementForAttribute(const string& tag, int which){
vector<string> tokens = tokenize(tag,":");
TiXmlHandle tagHandle = storedHandle;
for (int x = 0; x < (int)tokens.size(); x++) {
if (x == 0)
tagHandle = tagHandle.ChildElement(tokens.at(x), which);
else
tagHandle = tagHandle.FirstChildElement(tokens.at(x));
}
return tagHandle.ToElement();
}
示例8: if
bool CppCheck::DoCppCheckParseXMLv2(TiXmlHandle& Handle)
{
bool ErrorsPresent = false;
const TiXmlHandle& Errors = Handle.FirstChildElement("errors");
for (const TiXmlElement* Error = Errors.FirstChildElement("error").ToElement();
Error;
Error = Error->NextSiblingElement("error"))
{
wxString Id;
if (const char* IdValue = Error->Attribute("id"))
Id = wxString::FromAscii(IdValue);
wxString Severity;
if (const char* SeverityValue = Error->Attribute("severity"))
Severity = wxString::FromAscii(SeverityValue);
wxString Message;
if (const char* MessageValue = Error->Attribute("msg"))
Message = wxString::FromAscii(MessageValue);
wxString CWE;
if (const char* CWEValue = Error->Attribute("cwe"))
CWE = wxString::FromAscii(CWEValue);
wxString Verbose;
if (const char* VerboseValue = Error->Attribute("verbose"))
Verbose = wxString::FromAscii(VerboseValue);
const wxString FullMessage = Id + _T(" : ") + Severity + _T(" : ") + Verbose;
wxString File;
wxString Line;
const TiXmlElement* Location = Error->FirstChildElement("location");
if (nullptr!=Location)
{
if (const char* FileValue = Location->Attribute("file"))
File = wxString::FromAscii(FileValue);
if (const char* LineValue = Location->Attribute("line"))
Line = wxString::FromAscii(LineValue);
}
if (!FullMessage.IsEmpty() && !File.IsEmpty() && !Line.IsEmpty())
{
wxArrayString Arr;
Arr.Add(File);
Arr.Add(Line);
Arr.Add(FullMessage);
m_ListLog->Append(Arr);
ErrorsPresent = true;
}
else if (!Message.IsEmpty())
AppendToLog(Message); // might be something important like config not found...
}
return ErrorsPresent;
}
示例9: readTag
//---------------------------------------------------------
bool ofxXmlSettings::readTag(const string& tag, TiXmlHandle& valHandle, int which){
vector<string> tokens = tokenize(tag,":");
TiXmlHandle tagHandle = storedHandle;
for(int x=0;x<(int)tokens.size();x++){
if(x == 0)tagHandle = tagHandle.ChildElement(tokens.at(x), which);
else tagHandle = tagHandle.FirstChildElement( tokens.at(x) );
}
// once we've walked, let's get that value...
valHandle = tagHandle.Child( 0 );
return (valHandle.ToText() != NULL);
}
示例10: LoadLocations
bool Recordings::LoadLocations()
{
std::string url;
if (Settings::GetInstance().GetRecordingsFromCurrentLocationOnly())
url = StringUtils::Format("%s%s", Settings::GetInstance().GetConnectionURL().c_str(), "web/getcurrlocation");
else
url = StringUtils::Format("%s%s", Settings::GetInstance().GetConnectionURL().c_str(), "web/getlocations");
const std::string strXML = WebUtils::GetHttpXML(url);
TiXmlDocument xmlDoc;
if (!xmlDoc.Parse(strXML.c_str()))
{
Logger::Log(LEVEL_ERROR, "%s Unable to parse XML: %s at line %d", __FUNCTION__, xmlDoc.ErrorDesc(), xmlDoc.ErrorRow());
return false;
}
TiXmlHandle hDoc(&xmlDoc);
TiXmlElement* pElem = hDoc.FirstChildElement("e2locations").Element();
if (!pElem)
{
Logger::Log(LEVEL_ERROR, "%s Could not find <e2locations> element", __FUNCTION__);
return false;
}
TiXmlHandle hRoot = TiXmlHandle(pElem);
TiXmlElement* pNode = hRoot.FirstChildElement("e2location").Element();
if (!pNode)
{
Logger::Log(LEVEL_ERROR, "%s Could not find <e2location> element", __FUNCTION__);
return false;
}
for (; pNode != nullptr; pNode = pNode->NextSiblingElement("e2location"))
{
const std::string strTmp = pNode->GetText();
m_locations.emplace_back(strTmp);
Logger::Log(LEVEL_DEBUG, "%s Added '%s' as a recording location", __FUNCTION__, strTmp.c_str());
}
Logger::Log(LEVEL_INFO, "%s Loaded '%d' recording locations", __FUNCTION__, m_locations.size());
return true;
}
示例11: removeAttribute
//---------------------------------------------------------
void ofxXmlSettings::removeAttribute(const string& tag, const string& attribute, int which){
vector<string> tokens = tokenize(tag,":");
TiXmlHandle tagHandle = storedHandle;
for (int x = 0; x < (int)tokens.size(); x++) {
if (x == 0)
tagHandle = tagHandle.ChildElement(tokens.at(x), which);
else
tagHandle = tagHandle.FirstChildElement(tokens.at(x));
}
if (tagHandle.ToElement()) {
TiXmlElement* elem = tagHandle.ToElement();
elem->RemoveAttribute(attribute);
}
}
示例12: DoInitWizard
bool wxTreeMultiXmlMapper::DoInitWizard(const wxString &start_tag)
{
bool allok = false;
// clean up the control first
m_ctrl->DeleteAllItems();
// reset the ID counter
m_currentId = XMLMAP_BASE_ID;
// obtain handle to document
TiXmlHandle h(m_tiDoc);
// find our first wizard declaration
TiXmlHandle wizard = h.FirstChildElement(start_tag.c_str());
// we expect it to be an element, and we should go from there with
// parsing categories and other stuff..
if(wizard.Element())
{
// we skip all and look for the first category element
TiXmlElement *cat = wizard.FirstChildElement(XMLMAP_TAG_CATEGORY).Element();
// go through the loop of creating all categories
allok = (cat != 0);
while(cat && allok)
{
// ok create a category root name, but only when we
// have a name to give it
if(cat->Attribute(XMLMAP_ATTR_CAPTION))
{
wxTreeMultiItem item = AddCategory(cat, wxTreeMultiItem(0));
allok = DoCreateControls(cat, item, 0, 0);
}
// find a next one
if(allok)
cat = cat->NextSiblingElement(XMLMAP_TAG_CATEGORY);
}
}
return allok;
}
示例13: getAttributeNames
//---------------------------------------------------------
bool ofxXmlSettings::getAttributeNames(const string& tag, vector<string>& outNames, int which){
vector<string> tokens = tokenize(tag,":");
TiXmlHandle tagHandle = storedHandle;
for (int x = 0; x < (int)tokens.size(); x++) {
if (x == 0)
tagHandle = tagHandle.ChildElement(tokens.at(x), which);
else
tagHandle = tagHandle.FirstChildElement(tokens.at(x));
}
if (tagHandle.ToElement()) {
TiXmlElement* elem = tagHandle.ToElement();
// Do stuff with the element here
for (TiXmlAttribute* a = elem->FirstAttribute(); a; a = a->Next())
outNames.push_back( string(a->Name()) );
}
return !outNames.empty();
}
示例14: attributeExists
//---------------------------------------------------------
bool ofxXmlSettings::attributeExists(const string& tag, const string& attribute, int which){
vector<string> tokens = tokenize(tag,":");
TiXmlHandle tagHandle = storedHandle;
for (int x = 0; x < (int)tokens.size(); x++) {
if (x == 0)
tagHandle = tagHandle.ChildElement(tokens.at(x), which);
else
tagHandle = tagHandle.FirstChildElement(tokens.at(x));
}
if (tagHandle.ToElement()) {
TiXmlElement* elem = tagHandle.ToElement();
// Do stuff with the element here
for (TiXmlAttribute* a = elem->FirstAttribute(); a; a = a->Next()) {
if (a->Name() == attribute)
return true;
}
}
return false;
}
示例15: load
void TinyXmlServerConfigImp::load(FILE *fp){
loaded = true;
TiXmlDocument doc;
doc.LoadFile(fp);
TiXmlHandle docH( &doc );
TiXmlHandle servers = docH.FirstChildElement( "conf" ).FirstChildElement( "servers" );
if(servers.Element()){
TiXmlHandle server = servers.FirstChildElement(serverElem.data());
if(server.Element()){
loadServer(server);
}else{
log(Fatal, "%s config not found", serverElem.data());
exit(-1);
}
}else{
log(Error, "servers element is NULL");
}
forEachWatcher0(&IServerConfigWatcher::onConfigRefresh);
}