Example #1
0
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);
  }
}
Example #2
0
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)
Example #3
0
static inline string trimString(xmlpp::TextReader &r) {
  string tmp = r.read_string();
  boost::algorithm::trim(tmp);
  return tmp;
}