本文整理汇总了C++中TiXmlNode::Accept方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlNode::Accept方法的具体用法?C++ TiXmlNode::Accept怎么用?C++ TiXmlNode::Accept使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlNode
的用法示例。
在下文中一共展示了TiXmlNode::Accept方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseOnePlacemarkPoint
KmlPastebufferType Kml::ParseOnePlacemarkPoint( TiXmlNode* node, wxString& name ) {
double newLat = 0., newLon = 0.;
dPointList coordinates;
if( ParseCoordinates( node->ToElement(), coordinates ) ) {
newLat = coordinates[0].y;
newLon = coordinates[0].x;
}
if( newLat == 0.0 && newLon == 0.0 ) {
wxString msg( _T("KML Parser failed to convert <Point> coordinates.") );
wxLogMessage( msg );
return KML_PASTE_INVALID;
}
wxString pointName = wxEmptyString;
TiXmlElement* e = node->Parent()->FirstChild( "name" )->ToElement();
if( e ) pointName = wxString( e->GetText(), wxConvUTF8 );
wxString pointDescr = wxEmptyString;
e = node->Parent()->FirstChildElement( "description" );
// If the <description> is an XML element we must convert it to text,
// otherwise it gets lost.
if( e ) {
TiXmlNode* n = e->FirstChild();
if( n ) switch( n->Type() ){
case TiXmlNode::TINYXML_TEXT:
pointDescr = wxString( e->GetText(), wxConvUTF8 );
break;
case TiXmlNode::TINYXML_ELEMENT:
TiXmlPrinter printer;
printer.SetIndent( "\t" );
n->Accept( &printer );
pointDescr = wxString( printer.CStr(), wxConvUTF8 );
break;
}
}
// Extended data will override description.
TiXmlNode* n = node->Parent()->FirstChild( "ExtendedData" );
if( n ) {
TiXmlPrinter printer;
printer.SetIndent( "\t" );
n->Accept( &printer );
pointDescr = wxString( printer.CStr(), wxConvUTF8 );
}
// XXX leak ?
parsedRoutePoint = new RoutePoint();
parsedRoutePoint->m_lat = newLat;
parsedRoutePoint->m_lon = newLon;
parsedRoutePoint->m_bIsolatedMark = true;
parsedRoutePoint->m_bPtIsSelected = false;
parsedRoutePoint->m_MarkDescription = pointDescr;
parsedRoutePoint->SetName( pointName );
return KML_PASTE_WAYPOINT;
}
示例2: getstr
// QC:A (discussion possible sur l'utilisation de snprintf. Les buffers statiques ne sont pas thread safe.)
char* ScriptVariable::getstr() const {
if(isPointer()) {
return getPointee()->getstr();
}
if(type == VAR_NULL) {
return NULL;
}
if(type == VAR_INT) {
static char number[32];
snprintf(number, 32, "%d", value);
number[31] ='\0';
return number;
}
if(type == VAR_XML) {
static TiXmlPrinter printer;
printer = TiXmlPrinter();
printer.SetStreamPrinting();
TiXmlNode* node = (TiXmlNode*) data;
node->Accept(&printer);
return (char*)printer.CStr();
}
if(type == VAR_OBJ) {
static char address[256];
snprintf(address, 256, "(*%p:%s)", data, ((ScriptableObject*)data)->getClassName());
address[255] ='\0';
return address;
}
if(type == VAR_PAIR) {
static char number[64];
snprintf(number, 64, "(%ld:%ld)", (long) data, (long) params);
number[63] ='\0';
return number;
}
if(type == VAR_PACK) {
static char info[4096]; // XXX : NOT thread safe
snprintf(info, 4096, "(*%p => \"%s\")", data, params);
info[4095] ='\0';
return info;
}
if(type == VAR_TBL) {
static char info[4096]; // XXX : NOT thread safe
snprintf(info, 4096, "(tbl[%ld]:*%p)", (long)(data?(((ScriptTable*)data)->size()):0), data);
info[4095] ='\0';
return info;
}
if(type == VAR_FCT) {
return params;
}
return data;
}