4 #include <boost/algorithm/string.hpp>
16 std::ofstream
ofs(
"test.txt");
20 static const char * pINDENT=
" + ";
21 static const unsigned int LENGTH=strlen( pINDENT );
31 static const char * pINDENT=
" ";
32 static const unsigned int LENGTH=strlen( pINDENT );
41 if ( !pElement )
return 0;
43 TiXmlAttribute* pAttrib=pElement->FirstAttribute();
51 printf(
"%s%s: value=[%s]", pIndent, pAttrib->Name(), pAttrib->Value());
53 if (pAttrib->QueryIntValue(&ival)==TIXML_SUCCESS) printf(
" int=%d", ival);
54 if (pAttrib->QueryDoubleValue(&dval)==TIXML_SUCCESS) printf(
" d=%1.1f", dval);
57 pAttrib=pAttrib->Next();
65 int t = pParent->Type();
66 std::cout <<
"-" << std::endl;
67 for ( pChild = pParent->FirstChild(); pChild != 0; pChild = pChild->NextSibling())
70 std::string
type = pChild->Value();
76 std::cout <<
getIndentAlt(indent) <<
"model: \"" << pChild->FirstChild()->Value() <<
"\"" << std::endl;
77 }
else if(
type ==
"name"){
79 std::cout <<
getIndentAlt(indent) <<
"name: \"" << pChild->FirstChild()->Value() <<
"\"" << std::endl;
80 }
else if(
type ==
"pose"){
82 std::string child_value = pChild->FirstChild()->Value();
83 std::vector<std::string>
v;
84 boost::algorithm::split(
v, child_value, boost::algorithm::is_space() );
86 std::cout <<
getIndentAlt(indent) <<
"pose:" << std::endl;
87 std::cout <<
getIndentAlt(indent + 1) <<
"position:" << std::endl;
88 std::cout <<
getIndentAlt(indent + 2) <<
"x: " <<
v[0] << std::endl;
89 std::cout <<
getIndentAlt(indent + 2) <<
"y: " <<
v[1] << std::endl;
90 std::cout <<
getIndentAlt(indent + 2) <<
"z: " <<
v[2] << std::endl;
94 std::istringstream r_str(
v[3]);
97 std::istringstream p_str(
v[4]);
99 std::istringstream y_str(
v[5]);
113 std::cout <<
getIndentAlt(indent + 1) <<
"orientation:" << std::endl;
115 std::cout <<
getIndentAlt(indent + 2) <<
"x: " <<
q.x() << std::endl;
116 std::cout <<
getIndentAlt(indent + 2) <<
"y: " <<
q.y() << std::endl;
117 std::cout <<
getIndentAlt(indent + 2) <<
"z: " <<
q.z() << std::endl;
118 std::cout <<
getIndentAlt(indent + 2) <<
"w: " <<
q.w() << std::endl;
131 std::cout <<
getIndentAlt(indent) <<
"frmae-id: \"map\"" << std::endl;
132 std::cout <<
getIndentAlt(indent) <<
"robot: false" << std::endl;
138 if ( !pParent )
return;
142 int t = pParent->Type();
147 std::string
value = pParent->Value();
148 if (
value ==
"include"){
192 for ( pChild = pParent->FirstChild(); pChild != 0; pChild = pChild->NextSibling())
200 TiXmlDocument
doc(pFilename);
201 bool loadOkay =
doc.LoadFile();
204 printf(
"\n%s:\n", pFilename);
209 printf(
"Failed to load file \"%s\"\n", pFilename);
215 int main(
int argc,
char** argv){