本文整理汇总了C++中TiXmlHandle类的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlHandle类的具体用法?C++ TiXmlHandle怎么用?C++ TiXmlHandle使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TiXmlHandle类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: pushTag
//---------------------------------------------------------
bool ofxXmlSettings::pushTag(string tag, int which){
int pos = tag.find(":");
if(pos > 0){
tag = tag.substr(0,pos);
}
//we only allow to push one tag at a time.
TiXmlHandle isRealHandle = storedHandle->ChildElement(tag, which);
if( isRealHandle.Node() ){
*storedHandle = isRealHandle;
level++;
return true;
}else{
printf("pushTag - tag not found\n");
}
return false;
}
开发者ID:Ahmedn1,项目名称:ccv-hand,代码行数:22,代码来源:ofxXmlSettings.cpp
示例2: tokenize
//---------------------------------------------------------
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;
}
开发者ID:m9dfukc,项目名称:Motion-Sensing-Toolkit,代码行数:22,代码来源:ofxXmlSettings.cpp
示例3: tokenize
//---------------------------------------------------------
void ofXMLSettings::removeTag(string tag, int which){
vector<string> tokens = tokenize(tag,":");
//no tags so we return
if( tokens.size() == 0 ) return;
//grab the handle from the level we are at
//normally this is the doc but could be a pushed node
TiXmlHandle tagHandle = *storedHandle;
if(which < 0) which = 0;
for(int x=0;x<tokens.size();x++){
//we only support multi tags
//with same name at root level
if(x > 0) which = 0;
TiXmlHandle isRealHandle = tagHandle.ChildElement( tokens.at(x), which);
if ( !isRealHandle.Node() ) break;
else{
if (x == tokens.size()-1){
//if we are at the last tag and it exists
//we use its parent to remove it - haha
tagHandle.ToNode()->RemoveChild( isRealHandle.ToNode() );
}
tagHandle = isRealHandle;
}
}
tokens.clear();
}
开发者ID:LeonFedotov,项目名称:L.A.S.E.R.-TAG-GRL,代码行数:35,代码来源:ofXMLSettings.cpp
示例4: root
bool OutputFile::getIt(ParamQt * p)
{
int deb=0;
currentIteration++;
p->setRho(0);
p->setTheta(0);
p->setLL(0);
TiXmlHandle root(&mDoc);
TiXmlHandle h = root.FirstChild("outputFile");
TiXmlHandle hIter = h.Child("Iteration", currentIteration);
TiXmlElement* t;
// <Tree>
t = hIter.FirstChild("Tree").ToElement();
if (t == NULL) // Can I use hIter to return false?
return false;
string s(t->GetText());
while (s.at(0)==10 || s.at(0)==13) s=s.substr(1,s.length()-1);
while (s.at(s.size()-1)==10 || s.at(s.size()-1)==13) s=s.substr(0,s.length()-1);
p->setTreeData(new RecTree(getL(),s,false,false),blocks);
// <number>, <theta>, <delta>, <rho>, <ll>.
t = hIter.FirstChild("number").ToElement(); p->setNumber(atol(t->GetText()));
t = hIter.FirstChild("theta").ToElement(); p->setTheta(p->getTheta() + atof(t->GetText()));
t = hIter.FirstChild("delta").ToElement(); p->setDelta(atof(t->GetText()));
t = hIter.FirstChild("rho").ToElement(); p->setRho(p->getRho() + atof(t->GetText()));
t = hIter.FirstChild("ll").ToElement(); p->setLL(p->getLL() + atof(t->GetText()));
// <recedge>
TiXmlElement* parent = hIter.ToElement();
TiXmlElement* child = 0;
while (child = (TiXmlElement*) parent->IterateChildren("recedge", child))
{
int start=0,end=0,efrom=0,eto=0;
double ato=0,afrom=0;
t = child->FirstChildElement("start"); start = deb + atoi(t->GetText());
t = child->FirstChildElement("end"); end = deb + atoi(t->GetText());
t = child->FirstChildElement("efrom"); efrom = atoi(t->GetText());
t = child->FirstChildElement("eto"); eto = atoi(t->GetText());
t = child->FirstChildElement("afrom"); afrom = atof(t->GetText());
t = child->FirstChildElement("ato"); ato = atof(t->GetText());
p->getTree()->addRecEdge(afrom,ato,start,end,efrom,eto);
}
return true;
}
开发者ID:ConstantinV,项目名称:Mauve-Analysis,代码行数:45,代码来源:outputfile.cpp
示例5: 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;
}
开发者ID:zhangchuhu,项目名称:s2s,代码行数:28,代码来源:MetaConfig.cpp
示例6: docH
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);
}
开发者ID:NonPlayerCharactor,项目名称:serviceframe,代码行数:22,代码来源:TinyXmlServerConfigImp.cpp
示例7: userCheck
bool userCheck(std::string createdAtStr, TiXmlHandle timelineRootHandle, TiXmlHandle userRootHandle)
{
std::string weekday, month, day, time, year, tmpStr;
long utcOffset, utcLower, utcHigher;
std::stringstream ss, utcStrstream;
std::stringstream strstream;
boost::posix_time::ptime ptime, pt, currentTime, mostRecentTweetTime;
boost::posix_time::time_duration hourDiff;
int userCount = 0;
///// Checks to see if the UTC Offset of the user is in the Americas ///////////
if(userRootHandle.FirstChild("user").FirstChild("utc_offset").ToNode())
{
utcStrstream << userRootHandle.FirstChild("user").FirstChild("utc_offset").ToElement()->GetText();
utcStrstream >> utcOffset;
utcLower = 60*60*(-10); // This is the time zone for Hawaii
utcHigher = 60*60*(-5); // This is the time zone for the Eastern most US
if(utcOffset >= utcLower && utcOffset <= utcHigher)
{
userCount++;
}
}
开发者ID:nt-complete,项目名称:twitSpam,代码行数:22,代码来源:ptTwitSpam.cpp
示例8: tagToFind
//---------------------------------------------------------
bool ofxXmlSettings::pushTag(const string& tag, int which){
int pos = tag.find(":");
// Either find the tag specified, or the first tag if colon-seperated.
string tagToFind((pos > 0) ? tag.substr(0,pos) :tag);
//we only allow to push one tag at a time.
TiXmlHandle isRealHandle = storedHandle.ChildElement(tagToFind, which);
if( isRealHandle.ToNode() ){
storedHandle = isRealHandle;
level++;
return true;
}else{
printf("pushTag - <");
printf("%s",tag.c_str());
printf("> tag not found\n");
}
return false;
}
开发者ID:AinurBegalinova,项目名称:TreasureHuntingRobot,代码行数:23,代码来源:ofxXmlSettings.cpp
示例9: statusCheck
bool statusCheck(TiXmlHandle rootHandle)
{
std::string status;
status = rootHandle.FirstChild("text").ToElement()->GetText();
for(int i = 0; i < status.size(); i++)
{
if(!isascii(status[i]))
return false;
}
return true;
}
开发者ID:nt-complete,项目名称:twitSpam,代码行数:14,代码来源:ptTwitSpam.cpp
示例10: initFromXML
void PointLumiere::initFromXML(TiXmlHandle hObj){
double x,y,z;
TiXmlElement* pElem=hObj.Element();
Lumiere::initFromXML(hObj);
pElem->QueryDoubleAttribute("x", &x);
pElem->QueryDoubleAttribute("y", &y);
pElem->QueryDoubleAttribute("z", &z);
this->position.Set(x,y,z);
this->falloff[0]=1.0;
this->falloff[1]=0.0;
this->falloff[2]=0.0;
}
开发者ID:etchevery,项目名称:MonteCarlo,代码行数:14,代码来源:PointLumiere.cpp
示例11: in
bool TinyDemarshaller::deserialize( PropertyBag &v )
{
Logger::In in("TinyDemarshaller");
if ( !d->loadOkay )
return false;
TiXmlHandle docHandle( &d->doc );
TiXmlHandle propHandle = docHandle.FirstChildElement( "properties" );
if ( ! propHandle.Node() ) {
log(Error) << "No <properties> element found in document!"<< endlog();
return false;
}
detail::Tiny2CPFHandler proc( v );
if ( proc.populateBag( propHandle.Node() ) == false) {
deleteProperties( v );
return false;
}
return true;
}
开发者ID:jsreng,项目名称:orocos-rtt,代码行数:23,代码来源:TinyDemarshaller.cpp
示例12: LoadGangXML
bool sGang::LoadGangXML( TiXmlHandle hGang )
{
TiXmlElement* pGang = hGang.ToElement();
if( pGang == nullptr )
{
return false;
}
if( pGang->Attribute( "Name" ) )
{
m_Name = pGang->Attribute( "Name" );
}
// load their skills
LoadSkillsXML( hGang.FirstChild( "Skills" ), m_Skills );
// load their stats
LoadStatsXML( hGang.FirstChild( "Stats" ), m_Stats );
pGang->QueryIntAttribute( "Num", &m_Num );
//these may not have been saved
//if not, the query just does not set the value
//so the default is used, assuming the gang was properly init
{
pGang->QueryValueAttribute<u_int>( "MissionID", &m_MissionID );
pGang->QueryIntAttribute( "LastMissID", &m_LastMissID );
// load the combat boolean
pGang->QueryValueAttribute<bool>( "Combat", &m_Combat );
// load the auto recruit boolean
pGang->QueryValueAttribute<bool>( "AutoRecruit", &m_AutoRecruit );
}
return true;
}
开发者ID:EnterTheNameHere,项目名称:WhoreMasterRenewal,代码行数:37,代码来源:cGangs.cpp
示例13: LoadStatsXML
bool LoadStatsXML(TiXmlHandle hStats, int stats[], int statMods[], int tempStats[])
{
TiXmlElement* pStats = hStats.ToElement();
if (pStats == 0) return false;
for (int i = 0; i < NUM_STATS; i++)
{
TiXmlElement* pStat = pStats->FirstChildElement(XMLifyString(sGirl::stat_names[i]));
if (pStat)
{
int tempInt = 0;
if (pStat->Attribute("Value")) pStat->QueryIntAttribute("Value", &tempInt);
int min = 0, max = 100;
switch (i)
{
case STAT_AGE:
if (tempInt > 99) tempInt = 100;
else if (tempInt > 80) tempInt = 80;
else if (tempInt < 18) tempInt = 18; // `J` Legal Note: 18 is the Legal Age of Majority for the USA where I live
break;
case STAT_EXP: max = 32000; break;
case STAT_LEVEL: max = 255; break;
case STAT_PCFEAR: case STAT_PCHATE: case STAT_PCLOVE: case STAT_MORALITY:
case STAT_REFINEMENT: case STAT_DIGNITY: case STAT_LACTATION:
min = -100; break;
default: break;
}
if (tempInt < -1000) tempInt = -1; // test for null stats and set them to 0
if (tempInt > max) tempInt = max;
else if (tempInt < min) tempInt = min;
stats[i] = tempInt;
if (statMods)
{
tempInt = 0;
if (pStat->Attribute("Mod")) pStat->QueryIntAttribute("Mod", &tempInt);
statMods[i] = tempInt;
}
if (tempStats)
{
tempInt = 0;
if (pStat->Attribute("Temp")) pStat->QueryIntAttribute("Temp", &tempInt);
tempStats[i] = tempInt;
}
}
}
return true;
}
开发者ID:mjsmagalhaes,项目名称:crazys-wm-mod,代码行数:49,代码来源:XmlMisc.cpp
示例14: fopen
int MetaConfig::reload()
{
FILE *fp = fopen(fname.c_str(), "r");
if(!fp){
log(Warn, "reload file %s error", fname.c_str());
return -1;
}
TiXmlDocument doc;
doc.LoadFile(fp);
TiXmlHandle docH( &doc );
TiXmlHandle meta = docH.FirstChildElement( "conf" ).FirstChildElement( "servers" ).FirstChildElement("meta");
if(meta.Element()){
loadBool(&meta, "sync", bsync, false);
TiXmlHandle daemon = meta.FirstChildElement("daemon");
int ret = flushNodeSrvs(&daemon);
return ret;
}else{
fclose(fp);
return -1;
}
}
开发者ID:zhangchuhu,项目名称:s2s,代码行数:24,代码来源:MetaConfig.cpp
示例15: tokenize
//---------------------------------------------------------
int ofxXmlSettings::getNumAttributes(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));
}
if (tagHandle.ToElement()) {
TiXmlElement* elem = tagHandle.ToElement();
// Do stuff with the element here
TiXmlAttribute* first = elem->FirstAttribute();
if (first) {
int count = 1;
for (TiXmlAttribute* curr = first; curr != elem->LastAttribute(); curr = curr->Next())
count++;
return count;
}
}
return 0;
}
开发者ID:AnnaKolla,项目名称:openFrameworks,代码行数:25,代码来源:ofxXmlSettings.cpp
示例16: loadServer
void TinyXmlConfigHADbd::loadServer(TiXmlHandle &serverH){
//提取进程所需的数据库id配置
TiXmlElement *id = serverH.FirstChildElement("default-ora-db-id").Element();
if(id){
defaultId = atoi(id->GetText());
log(Info, "get Oracle-dbid[%d]\n", defaultId);
}
id = serverH.FirstChildElement("dbnode_max_connect").Element();
if(id){
dbnode_max_connect = atoi(id->GetText());
log(Info, "get Oracle-dbnode_max_connect[%d]\n", dbnode_max_connect);
}
else
{
dbnode_max_connect=100;
}
id = serverH.FirstChildElement("dbnode_time_out_mill").Element();
if(id){
dbnode_time_out_mill = atoi(id->GetText());
log(Info, "get Oracle-dbnode_time_out_mill[%d]\n", dbnode_time_out_mill);
}
else
{
dbnode_time_out_mill=5000;
}
id = serverH.FirstChildElement("broker_uri").Element();
if(id){
_brokerURI = id->GetText();
log(Info, "get Oracle-broker_uri[%s]\n", _brokerURI.c_str());
}
else
{
_brokerURI.clear();
}
memcaches.clear();
TiXmlElement *mc = serverH.FirstChildElement("memcache").Element();
while(mc){
std::string host = getStr(mc->FirstChildElement("host"));
int port = atoi(getStr(mc->FirstChildElement("port")).data());
memcaches.push_back(make_pair(host, port));
mc = mc->NextSiblingElement("memcache");
}
TiXmlElement *webdbAllow = serverH.FirstChildElement("webdbAllows").FirstChildElement("webdbAllow").Element();
webdbAllowIps.clear();
while(webdbAllow){
const char *ip = webdbAllow->Attribute("ip");
webdbAllowIps.insert(ip);
webdbAllow = webdbAllow->NextSiblingElement("webdbAllow");
}
TinyXmlServerConfigImp::loadServer(serverH);
}
开发者ID:NonPlayerCharactor,项目名称:serviceframe,代码行数:56,代码来源:TinyXmlServerConfigImp.cpp
示例17:
std::vector<SDL_Surface*> ResourceCache::LoadTextures(
const TiXmlHandle& hndl,
const std::string& name,
const Size size
)
{
std::vector<SDL_Surface*> textures;
for (auto elem = hndl.FirstChild(name).Element();
elem;
elem = elem->NextSiblingElement(name))
{
textures.push_back(LoadTexture(elem->GetText(), size));
}
return textures;
}
开发者ID:vobject,项目名称:bomberperson,代码行数:16,代码来源:ResourceCache.cpp
示例18: OpenAndReadName
bool CSmartPlaylist::Load(const CStdString &path)
{
TiXmlElement *root = OpenAndReadName(path);
if (!root)
return false;
// encoding:
CStdString encoding;
XMLUtils::GetEncoding(&m_xmlDoc, encoding);
TiXmlHandle match = ((TiXmlHandle)root->FirstChild("match")).FirstChild();
if (match.Node())
m_matchAllRules = strcmpi(match.Node()->Value(), "all") == 0;
// now the rules
TiXmlElement *rule = root->FirstChildElement("rule");
while (rule)
{
// format is:
// <rule field="Genre" operator="contains">parameter</rule>
const char *field = rule->Attribute("field");
const char *oper = rule->Attribute("operator");
TiXmlNode *parameter = rule->FirstChild();
if (field && oper)
{ // valid rule
CStdString utf8Parameter;
if (parameter)
{
if (encoding.IsEmpty()) // utf8
utf8Parameter = parameter->Value();
else
g_charsetConverter.stringCharsetToUtf8(encoding, parameter->Value(), utf8Parameter);
}
CSmartPlaylistRule rule;
rule.TranslateStrings(field, oper, utf8Parameter.c_str());
m_playlistRules.push_back(rule);
}
rule = rule->NextSiblingElement("rule");
}
// now any limits
// format is <limit>25</limit>
TiXmlHandle limit = ((TiXmlHandle)root->FirstChild("limit")).FirstChild();
if (limit.Node())
m_limit = atoi(limit.Node()->Value());
// and order
// format is <order direction="ascending">field</order>
TiXmlElement *order = root->FirstChildElement("order");
if (order && order->FirstChild())
{
const char *direction = order->Attribute("direction");
if (direction)
m_orderAscending = strcmpi(direction, "ascending") == 0;
m_orderField = CSmartPlaylistRule::TranslateField(order->FirstChild()->Value());
}
return true;
}
开发者ID:Alxandr,项目名称:spotyxbmc2,代码行数:55,代码来源:SmartPlayList.cpp
示例19: LoadTraitsXML
bool LoadTraitsXML(TiXmlHandle hTraits, unsigned char& numTraits, sTrait* traits[], int tempTraits[])
{
numTraits = 0;
TiXmlElement* pTraits = hTraits.ToElement();
if (pTraits == 0) return false;
//this loop does not need UnXMLifyString, which is a bit of a hack currently
//however, it's coupled more tightly to traits, and seems to do more processing
sTrait* pTrait = g_Traits.GetTraitNum(0);
while (pTrait)
{
TiXmlElement* pTraitElement = pTraits->FirstChildElement(XMLifyString(pTrait->m_Name));
if (pTraitElement)
{
int tempInt = 0;
traits[numTraits] = pTrait;
if (tempTraits)
{
pTraitElement->QueryIntAttribute("Temp", &tempInt); tempTraits[numTraits] = tempInt; tempInt = 0;
}
++numTraits;
}
pTrait = pTrait->m_Next;
}
#if 0
//old loop, not sure which way is better
//also, this loop method has not been tested
for (TiXmlElement* pTrait = pTraits->FirstChildElement();
pTrait != 0;
pTrait = pTrait->NextSiblingElement())
{
std::string traitName = pTrait->ValueStr();
if (traitName.empty() == false)
{
int tempInt = 0;
traits[numTraits] = g_Traits.GetTrait(UnXMLifyString(traitName));
if (tempTraits)
{
pTrait->QueryIntAttribute("Temp", &tempInt); tempTraits[numTraits] = tempInt; tempInt = 0;
}
++numTraits;
}
}
#endif
return true;
}
开发者ID:mjsmagalhaes,项目名称:crazys-wm-mod,代码行数:47,代码来源:XmlMisc.cpp
示例20: methodHandle
void
StateLoader::LoadFunctionEnums(TiXmlHandle &handle, IGlobalState *state) {
TiXmlElement *pElem;
std::string name;
std::string data = "";
std::string functionName;
pElem = handle.FirstChild().Element();
for (; 0 != pElem; pElem = pElem->NextSiblingElement()) {
TiXmlHandle methodHandle(pElem);
pElem->QueryStringAttribute("function", &functionName);
LoadEnums(methodHandle, functionName, state);
}
}
开发者ID:monthero,项目名称:nau,代码行数:18,代码来源:stateLoader.cpp
注:本文中的TiXmlHandle类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论