本文整理汇总了C++中xmlpp::TextReader类的典型用法代码示例。如果您正苦于以下问题:C++ TextReader类的具体用法?C++ TextReader怎么用?C++ TextReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readElement
/*----------------------------------------------------------------------------*/
void readElement(xmlpp::TextReader& reader,string elem)
{
do
{
reader.read();
}while(elem!=reader.get_name());
}
示例2: buscarElemento
/*----------------------------------------------------------------------------*/
void XmlParser::buscarElemento(xmlpp::TextReader& reader)
{
int nodeType = (int)reader.get_node_type();
//Busca un nodo tipo Elemento.
while(nodeType!=1 && nodeType!=0)
{
reader.read();
nodeType = (int)reader.get_node_type();
}
}
示例3: read_skip_comment
inline void read_skip_comment(xmlpp::TextReader &reader)
{
const int line = xml_line(reader.get_current_node());
do
{
if(!reader.read())
throw xml_eof(line);
}
while(reader.get_node_type() == xmlpp::TextReader::Comment);
}
示例4: cargarMundo
/*----------------------------------------------------------------------------*/
void XmlParser::cargarMundo(Mundo* mundo,xmlpp::TextReader& reader)
{
do
{
buscarElemento(reader);
string path = reader.get_attribute(ATRIB_PATH);
if(path!="")
{
mundo->getNiveles()->push(path);
}
}while(reader.read());
}
示例5: cargarGrafo
/*----------------------------------------------------------------------------*/
void XmlParser::cargarGrafo(Mapa* mapa,xmlpp::TextReader& reader)
{
std::string name="";
do
{
buscarElemento(reader);
name = reader.get_name();
if(name==ARISTA)
agregarArista(mapa,reader);
}while(reader.read() && name!=ELEMENTOS);
}
示例6: agregarArista
/*----------------------------------------------------------------------------*/
void XmlParser::agregarArista(Mapa* mapa,xmlpp::TextReader& reader)
{
int arcoId=-1;
string orientacion = reader.get_attribute (ATRIB_ORIENTACION);
arcoId=getAtributoInt(reader,ATRIB_ID);
cargarArista(mapa,reader,arcoId,orientacion);
}
示例7: agregarElementos
/*----------------------------------------------------------------------------*/
void XmlParser::agregarElementos(Mapa* mapa,xmlpp::TextReader& reader)
{
do
{
string tipoElemento = reader.get_attribute(ATRIB_TIPO);
if(tipoElemento==POWER_UP)
agregarPowerUp(mapa,reader);
if(tipoElemento==BONUS)
agregarBonus(mapa,reader);
if(tipoElemento==CASA_FANTASMAS)
agregarCasaFantasmas(mapa,reader);
if(tipoElemento==SALIDA_PACMAN)
agregarSalidaPacMan(mapa,reader);
}while(reader.read());
//Se agregan las pantillas al mapa
agregarPastillas(mapa);
}
示例8: assert
void polyline_road::xml_read(xmlpp::TextReader &reader, const vec3f &scale)
{
assert(is_opening_element(reader, "line_rep"));
read_to_open(reader, "points");
std::cout<<"abcd"<<std::endl;
do
{
read_skip_comment(reader);
if(reader.get_node_type() == xmlpp::TextReader::Text ||
reader.get_node_type() == xmlpp::TextReader::SignificantWhitespace)
{
//std::cout<<"BE CAREFUL, NEED TEST! (hwm_xml_read.cpp)"<<std::endl;
std::string res(reader.get_value());
std::stringstream s1(res);
std::string line;
while(getline(s1, line, '\n')) {
std::istringstream s2(line);
vec3f pos;
s2 >> pos[0];
s2 >> pos[1];
s2 >> pos[2];
if((std::abs(pos[0] - 0) < 1e-6 && std::abs(pos[1] - 0) < 1e-6 && std::abs(pos[2] - 0) < 1e-6))
continue;
points_.push_back(vec3f(pos*scale));
}
}
}
while(!is_closing_element(reader, "points"));
if(!initialize())
throw xml_error(reader, "Failed to initialize polyine");
read_to_close(reader, "line_rep");
}
示例9: readVector
static inline void readVector(set<string> &v, xmlpp::TextReader &r, string sep="\n") {
string tmp = r.read_string();
vector<string> sv;
boost::algorithm::split( sv, tmp, boost::algorithm::is_any_of(sep), boost::algorithm::token_compress_on );
for (vector<string>::iterator it=sv.begin(); it != sv.end(); ++it) {
tmp = *it;
boost::algorithm::trim(tmp);
if (! tmp.empty())
v.insert(tmp);
}
}
示例10: get_attribute
inline bool get_attribute(T &res,
xmlpp::TextReader &reader,
const str &eltname)
{
str val(reader.get_attribute(eltname));
if(!val.empty()) {
std::istringstream str_in(val);
str_in >> res;
return true;
}
示例11: while
void PRUplus::readXML(xmlpp::TextReader &reader) {
while(reader.read()) {
string name = reader.get_name();
if ((reader.get_node_type() == xmlpp::TextReader::EndElement) &&
(name == "pru"))
break;
if (reader.get_node_type() != xmlpp::TextReader::Element )
continue;
if (name == "pru") {
} else if (name == "Start") {
} else if (name == "SVU")
readVector(stateVariablesInitialAssignments, reader);
else if (name == "Next")
readVector(firstEnabledModules, reader, "\n ");
else if (name == "Layer")
layers.push_back(new PRUlayer(reader));
else if (name == "Constraint")
constraints.push_back(new PRUconstraint(reader));
else
std::cerr << "Unexpected tag " << name << "!" << std::endl;
} // while reader.read()
} // PRUplus(reader)
示例12: agregarCasaFantasmas
/*----------------------------------------------------------------------------*/
void XmlParser::agregarCasaFantasmas(Mapa* mapa,xmlpp::TextReader& reader)
{
int idVertice=0;
int idPuerta = getAtributoInt(reader,ATRIB_ID_VERTICE);
tVecVerticeId vertices;
elementosNoPastillas.push_back(idPuerta);
for(int i=1;i<7;i++)
{
idVertice=getAtributoInt(reader,ATRIB_ID_VERTICE+StrToken::intToString(i));
elementosNoPastillas.push_back(idVertice);
vertices.push_back(idVertice);
}
string orientacion=reader.get_attribute(ATRIB_ORIENTACION);
CasaFantasmas casaFantasmas(idPuerta,orientacionParser(orientacion));
casaFantasmas.setVerticesId(vertices);
Modelo::getInstance()->SetCasaFantasmas(casaFantasmas);
}
示例13: getAtributoInt
/*----------------------------------------------------------------------------*/
int XmlParser::getAtributoInt(xmlpp::TextReader& reader,string atrib)
{
int intValor=-1;
StrToken::stringTo<int>(intValor,reader.get_attribute (atrib));
return intValor;
}
示例14: initDefaultValues
PRUoutcome::PRUoutcome(xmlpp::TextReader &reader) {
initDefaultValues();
if (reader.has_attributes()) {
reader.move_to_first_attribute();
do {
if (reader.get_name() == "id")
name = reader.get_value();
else if (reader.get_name() == "p")
probability = atof(reader.get_value().c_str());
} while (reader.move_to_next_attribute());
reader.move_to_element();
}
while(reader.read()) {
string name = reader.get_name();
if ((reader.get_node_type() == xmlpp::TextReader::EndElement) &&
(name == "Outcome"))
break;
if (reader.get_node_type() != xmlpp::TextReader::Element )
continue;
if (name == "Quality") {
if (reader.has_attributes()) {
reader.move_to_first_attribute();
do {
if (reader.get_name() == "kind")
quality = reader.get_value();
else if (reader.get_name() == "param")
qualityParameter = atof(reader.get_value().c_str());
else if (reader.get_name() == "const")
qualityConstant = atof(reader.get_value().c_str());
} while (reader.move_to_next_attribute());
reader.move_to_element();
}
} else if (name == "Duration") {
if (reader.has_attributes()) {
reader.move_to_first_attribute();
do {
if (reader.get_name() == "kind")
duration = reader.get_value();
else if (reader.get_name() == "param")
durationParameter = atof(reader.get_value().c_str());
else if (reader.get_name() == "const")
durationConstant = atof(reader.get_value().c_str());
} while (reader.move_to_next_attribute());
reader.move_to_element();
}
} else if (name == "Observe") {
if (reader.has_value())
observable = reader.get_value();
else
observable = reader.read_string();
} else if (name == "SVU") {
readVector(stateVariableUpdate,reader);
} else if (name == "Final") {
isFinal = true;
if (reader.has_attributes()) {
reader.move_to_first_attribute();
do {
if (reader.get_name() == "label")
finalLabel = reader.get_value();
} while (reader.move_to_next_attribute());
reader.move_to_element();
}
} else if (name == "Next")
readVector(nextModules,reader,"\n ");
else
std::cerr << "Unexpected tag " << name << "!" << std::endl;
} // while reader.read()
} // PRUoutcome(reader)
示例15: trimString
static inline string trimString(xmlpp::TextReader &r) {
string tmp = r.read_string();
boost::algorithm::trim(tmp);
return tmp;
}