Beispiel #1
0
int Weather::getProperty(const char* str) {
	int count = 0; 
	int value = 0;


	//Parsing information, just there to get the condition code and temp. Takes in a char*, spits out the requested information it gets from parsing
	pugi::xml_node node = doc.child("query");
	pugi::xml_node channel = node.first_child().first_child();
	pugi::xml_node weath = channel.last_child().first_child().next_sibling();
	for(pugi::xml_node weathernode = weath;
		weathernode;
		weathernode = weathernode.next_sibling()){
			if(weathernode.attribute("date")){
				if(day + 1 == count){
					value = weathernode.attribute(str).as_int();
					//std::cout << weathernode.attribute(str).as_int();
					//std::cout << "Value"<< value;

				}
			count++;
			}

	}
	return value;
}			
Beispiel #2
0
bool program_data::read(const pugi::xml_document & doc)
{
    pugi::xml_node root_node = doc.child("program");
    if(root_node.empty())
        return false;

    pugi::xml_node vertex_node = root_node.child("shaders").child("vertex");
    if(vertex_node.text().empty())
        return false;
    pugi::xml_node fragment_node = root_node.child("shaders").child("fragment");
    if(fragment_node.text().empty())
        return false;

    v_shader_ = vertex_node.text().get();
    f_shader_ = fragment_node.text().get();

    pugi::xml_node a_locations_node = root_node.child("a_locations");
    for(const auto & value : a_locations_node.children("location"))
    {
        attribute_locations_.emplace_back(value.attribute("name").value(),
                                          value.attribute("index").as_int());
    }

    pugi::xml_node u_locations_node = root_node.child("u_locations");
    for(const auto & value : u_locations_node.children("location"))
    {
        uniform_locations_.emplace_back(value.attribute("name").value(),
                                        value.attribute("index").as_int());
    }

    return true;
}
Beispiel #3
0
void Patent::_init(const pugi::xml_document& doc, const bool& loadAbstract, const bool& loadDescription) {
	pugi::xml_node root = doc.child("patent");

	text.clear();
	source_tfvec.clear();
	target_tfvec.clear();

	// walk through nodes below the root node to collect abstracts and descriptions
	for (pugi::xml_node node = root.first_child(); node; node = node.next_sibling()) {

		if ( strcmp(node.name(), "ucid") == 0 )
			ucid = node.text().as_string();
		else if ( strcmp(node.name(), "lang") == 0 )
			lang = node.text().as_string();
		else if ( loadAbstract
			 && strcmp(node.name(), "abstract") == 0 )
			this->loadText(node);
		else if ( loadDescription
			 && strcmp(node.name(), "description") == 0 )
			this->loadText(node);

	}

	s_count = text.size();

	isParsed = true;
}
Beispiel #4
0
      void CDatabase::loadParsedDatabase(const pugi::xml_document &doc)
      {
         LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ );

         mApplications.clear();
         pugi::xml_node appMan = doc.child("app-man");
         pugi::xml_node applications = appMan.child("applications");
         for (pugi::xml_node_iterator it = applications.begin(); it != applications.end(); ++it)
         {
            LOG4CPLUS_INFO(msLogger, "it->name : " + std::string(it->name()));
            if (strcmp(it->name(), "app"))
            {
               continue;
            }
            LOG4CPLUS_INFO(msLogger, "it->child_value(launch-info) : " + std::string(it->child_value("launch-info")));
            std::string trimmedLaunchInfo = mLaunchInfoProcessor->trimLaunchInfo(it->child_value("launch-info"));
            CApplication app(trimmedLaunchInfo);
            LOG4CPLUS_INFO(msLogger, "launch-info : " + trimmedLaunchInfo);
            if (hasAppWithNoLocks(app.launchInfo()))
            {
               LOG4CPLUS_WARN(msLogger, "!!! Application launch info repetition !!!");
               continue;
            }

            if (!mLaunchInfoProcessor->isLaunchInfoValid(app.launchInfo()))
            {
               LOG4CPLUS_ERROR(msLogger, "!!! LAUNCHINFO IS NOT VALID !!!");
               continue;
            }
            else
            {
               LOG4CPLUS_INFO(msLogger, "launchinfo is valid: " + app.launchInfo());
            }
            int id = genId();
            mApplications[id] = app;

            pugi::xml_node services = it->child("services");

            for (pugi::xml_node_iterator srv = services.begin();
                  services.end() != srv; ++srv)
            {
               if (strcmp(srv->name(),"service") || !strcmp(srv->name(), ""))
               {
                  continue;
               }
               std::string uid(srv->attribute("uid").value());
               LOG4CPLUS_INFO(msLogger, "service UID: " + uid);
               mApplications[id].addService(Service::Uid(uid));
            }
         }
      }
Beispiel #5
0
bool ProfileDatabase::loadParsedDatabase(const pugi::xml_document &doc)
{
    LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ );
    if (EDB_NORMAL_OK != mDbState)
    {
        LOG4CPLUS_ERROR(msLogger, "parsing state error");
        return false;
    }
    pugi::xml_node profs = doc.child("profiles");

    for (pugi::xml_node_iterator it = profs.begin(); it != profs.end(); ++it)
    {
        LOG4CPLUS_INFO(msLogger, "Profile adding");
        Profile::Uid profileUid = Profile::Uid(it->child_value("uid"));
        Profile::ApiUid apiUid = Profile::ApiUid(it->child_value("api-uid"));
        std::string name = it->child_value("name");
        Profile::Uid complement = Profile::Uid(it->child_value("complement"));
        if ("" == profileUid.value() || "" == apiUid.value() || "" == complement.value() || "" == name)
        {
            LOG4CPLUS_WARN(msLogger, "Profile adding error\nProfile UID: " + profileUid.value() +
                    ", API UID: " + apiUid.value() + ", Complement UID: " + complement.value() +
                    ", name: " + name);
            continue;
        }
        ProfileInfo profile(profileUid, apiUid, complement, name);

        pugi::xml_node libs = it->child("libs");
        for (pugi::xml_node_iterator sit = libs.begin(); sit != libs.end(); ++sit)
        {
            std::string pathToLib = mRootFolderPath + (std::string)sit->attribute("path").value();
            UInt32 version = atoi(sit->attribute("version").value());
            std::string platform = sit->attribute("platform").value();
            profile.addLib(ProfileLibInfo(version, pathToLib, platform));
        }

        ProfileInfoMap::iterator mit = mProfiles.find(profile.uid());
        if (mProfiles.end() == mit)
        {
            mProfiles.insert(std::make_pair(profile.uid(), profile));
            LOG4CPLUS_INFO(msLogger, "Added profile into profiles map, profile UID: " + profile.uid().value());
        }
        else
        {
            LOG4CPLUS_WARN(msLogger, "Error: UID repetition: " + profile.uid().value());
        }
    }
    return true;
}
Beispiel #6
0
// ---------------------------------------------
pugi::xml_node j1App::LoadConfig(pugi::xml_document& config_file) const
{
	pugi::xml_node ret;

	char* buf;
	int size = App->fs->Load("config.xml", &buf);
	pugi::xml_parse_result result = config_file.load_buffer(buf, size);
	RELEASE(buf);

	if(result == NULL)
		LOG("Could not load map xml file config.xml. pugi error: %s", result.description());
	else
		ret = config_file.child("config");

	return ret;
}
Beispiel #7
0
// TODO: Fix up the format of the config file so it's all process oriented
// rather than plugin oriented. i.e. You should specify your process, and then
// attach your config for plugins/gui/etc to that (and also have some sort of
// 'global' config which applies for cases where there is no process-specific
// override). That way you can override the GUI on a per-process basis so it
// matches the plugins you're trying to load.
void Config::LoadImpl(pugi::xml_document const& doc)
{
  auto const hadesmem_root = doc.child(L"HadesMem");
  if (!hadesmem_root)
  {
    HADESMEM_DETAIL_THROW_EXCEPTION(hadesmem::Error{} << hadesmem::ErrorString{
                                      "Failed to find 'HadesMem' root node."});
  }

  auto const cerberus_node = hadesmem_root.child(L"Cerberus");
  if (!cerberus_node)
  {
    HADESMEM_DETAIL_TRACE_A("No Cerberus node.");
    return;
  }

  for (auto const& plugin_node : cerberus_node.children(L"Plugin"))
  {
    auto const path =
      hadesmem::detail::pugixml::GetAttributeValue(plugin_node, L"Path");
    auto const process = hadesmem::detail::pugixml::GetOptionalAttributeValue(
      plugin_node, L"Process");
    HADESMEM_DETAIL_TRACE_FORMAT_A(
      "Got Plugin entry. Path: [%s]. Process: [%s].",
      path.c_str(),
      process.c_str());
    plugins_.emplace_back(Plugin{path, process});
  }

  // TODO: Find a better way to do this.
  auto const gui =
    hadesmem::detail::pugixml::GetOptionalAttributeValue(cerberus_node, L"GUI");
  if (hadesmem::detail::ToUpperOrdinal(gui) == L"ANTTWEAKBAR")
  {
    HADESMEM_DETAIL_TRACE_A("AntTweakBar enabled.");
    ant_tweak_bar_enabled_ = true;
  }
  else if (hadesmem::detail::ToUpperOrdinal(gui) == L"GWEN")
  {
    HADESMEM_DETAIL_TRACE_A("GWEN enabled.");
    gwen_enabled_ = true;
  }
  else
  {
    ant_tweak_bar_enabled_ = false;
  }
}
Beispiel #8
0
 bool CProfileDatabase::loadParsedDatabase(const pugi::xml_document &doc)
 {
    LOG4CPLUS_TRACE_METHOD(msLogger, __PRETTY_FUNCTION__ );
    if (EDB_NORMAL_OK != mDBState)
    {
       return false;
    }
    pugi::xml_node profs = doc.child("profiles");
    for (pugi::xml_node_iterator it = profs.begin(); it != profs.end(); ++it)
    {
       CProfileInfo info(std::string(it->child_value("manifest-path")));
       if (info.failed())
       {
          LOG4CPLUS_WARN(msLogger, "Failed loading of XML Manifest");
          continue;
       }
       std::map<UID,CProfileInfo>::iterator mit = mProfiles.find(info.uid());
       if (mProfiles.end() == mit)
       {
          mProfiles[info.uid()] = info;
          pugi::xml_node libs = it->child("libs");
          for (pugi::xml_node_iterator sit = libs.begin(); sit != libs.end(); ++sit)
          {
             mProfiles[info.uid()].addLib(sit->attribute("platform").value(), sit->attribute("path").value());
          }
       }
       else if ( 0 != it->child_value("uid"))
       {
          LOG4CPLUS_WARN(msLogger, "Error: UID repetition: " + std::string(it->child_value("uid")));
       }
       else
       {
          LOG4CPLUS_WARN(msLogger, "Error: UID repetition");
       }
    }
    return true;
 }
Beispiel #9
0
//-----------------------------------------------------------------------------
void X3DFile::write_vertices(pugi::xml_document& xml_doc, const Mesh& mesh,
                             const std::vector<std::size_t> vecindex)
{
  std::size_t offset = MPI::global_offset(vecindex.size(), true);

  const std::size_t process_number = MPI::process_number();
  const std::size_t num_processes = MPI::num_processes();
  const std::size_t tdim = mesh.topology().dim();
  const std::size_t gdim = mesh.geometry().dim();

  std::stringstream local_output;
  if (facet_type == "IndexedLineSet")
  {
    for (EdgeIterator e(mesh); !e.end(); ++e)
    {
      bool allow_edge = (tdim == 2);

      // If one of the faces connected to this edge is external, then
      // output the edge
      if (!allow_edge)
      {
        for (FaceIterator f(*e); !f.end(); ++f)
        {
          if (f->num_global_entities(tdim) == 1)
            allow_edge = true;
        }
      }

      if (allow_edge)
      {
        for (VertexIterator v(*e); !v.end(); ++v)
        {
          std::size_t index_it  = std::find(vecindex.begin(),
                                            vecindex.end(),
                                            v->index()) - vecindex.begin();
          local_output << index_it + offset  << " " ;
        }
        local_output << "-1 ";
      }
    }
  }
  else if (facet_type == "IndexedFaceSet")
  {
    // Output faces
    for (FaceIterator f(mesh); !f.end(); ++f)
    {
      if (tdim == 2 || f->num_global_entities(tdim) == 1)
      {
        for (VertexIterator v(*f); !v.end(); ++v)
        {
          std::size_t index_it = std::find(vecindex.begin(),
                                           vecindex.end(),
                                           v->index()) - vecindex.begin();
          local_output << index_it + offset  << " " ;
        }
        local_output << "-1 ";
      }
    }
  }

  std::vector<std::string> gathered_output;
  MPI::gather(local_output.str(), gathered_output);

  if (process_number == 0)
  {
    pugi::xml_node indexed_face_set
      = xml_doc.child("X3D").child("Scene").child("Shape").child(facet_type.c_str());

    std::stringstream str_output;
    for (std::size_t i = 0; i < num_processes; ++i)
      str_output << gathered_output[i];

    indexed_face_set.append_attribute("coordIndex") = str_output.str().c_str();
  }

  local_output.str("");

  // Now fill in the geometry
  for (std::vector<std::size_t>::const_iterator index = vecindex.begin();
       index != vecindex.end(); ++index)
  {
    Vertex v(mesh, *index);
    local_output << v.x(0) << " " << v.x(1) << " ";
    if (gdim == 2)
      local_output << "0 ";
    else
      local_output << v.x(2) << " ";
  }

  MPI::gather(local_output.str(), gathered_output);

  // Finally, close off with the XML footer on process zero
  if (process_number == 0)
  {
    pugi::xml_node indexed_face_set
      = xml_doc.child("X3D").child("Scene").child("Shape").child(facet_type.c_str());

    pugi::xml_node coordinate = indexed_face_set.append_child("Coordinate");

    std::stringstream str_output;
    for (std::size_t i = 0; i < num_processes; ++i)
      str_output << gathered_output[i];

    coordinate.append_attribute("point") = str_output.str().c_str();
  }
}
Beispiel #10
0
//-----------------------------------------------------------------------------
void X3DFile::write_values(pugi::xml_document& xml_doc, const Mesh& mesh,
                           const std::vector<std::size_t> vecindex,
                           const std::vector<double> data_values)
{
  const std::size_t tdim = mesh.topology().dim();

  double minval = *std::min_element(data_values.begin(), data_values.end());
  minval = MPI::min(minval);
  double maxval = *std::max_element(data_values.begin(), data_values.end());
  maxval = MPI::max(maxval);

  double scale = 0.0;
  if (maxval == minval)
    scale = 1.0;
  else
    scale = 255.0/(maxval - minval);

  std::stringstream local_output;
  if (facet_type == "IndexedLineSet")
  {
    for (EdgeIterator e(mesh); !e.end(); ++e)
    {
      bool allow_edge = (tdim == 2);

      // If one of the faces connected to this edge is external, then
      // output the edge
      if (!allow_edge)
      {
        for (FaceIterator f(*e); !f.end(); ++f)
        {
          if (f->num_global_entities(tdim) == 1)
            allow_edge = true;
        }
      }

      if (allow_edge)
      {
        for (VertexIterator v(*e); !v.end(); ++v)
        {
          local_output << (int)((data_values[v->index()] - minval)*scale)
                       << " " ;
        }
        local_output << "-1 ";
      }
    }
  }
  else if (facet_type == "IndexedFaceSet")
  {
    // Output faces
    for (FaceIterator f(mesh); !f.end(); ++f)
    {
      if (tdim == 2 || f->num_global_entities(tdim) == 1)
      {
        for (VertexIterator v(*f); !v.end(); ++v)
        {
          local_output << (int)((data_values[v->index()] - minval)*scale)
                       << " " ;
        }
        local_output << "-1 ";
      }
    }
  }

  // Gather up on zero
  std::vector<std::string> gathered_output;
  MPI::gather(local_output.str(), gathered_output);
  if (MPI::process_number() == 0)
  {
    pugi::xml_node indexed_face_set = xml_doc.child("X3D")
      .child("Scene").child("Shape").child(facet_type.c_str());
    indexed_face_set.append_attribute("colorPerVertex") = "true";

    std::stringstream str_output;
    for (std::size_t i = 0; i < MPI::num_processes(); ++i)
      str_output << gathered_output[i];

    indexed_face_set.append_attribute("colorIndex") = str_output.str().c_str();

    // Output colour palette
    const int palette = 2;
    pugi::xml_node color = indexed_face_set.append_child("Color");
    color.append_attribute("color") = color_palette(palette).c_str();
  }
}
void PhysicBodyManager::loadDefinitions(const pugi::xml_document& doc)
{
    Logger log("PhysicBodyManager::loadDefinitions");

    pugi::xml_node config = doc.child("physics").child("world");

    myGravity = config.attribute("gravity").as_float();

    log << "gravity : "<< myGravity;

    for (pugi::xml_node body = doc.child("physics").child("body"); body; body = body.next_sibling("body"))
    {
        //<body...

        log << "\t new body found ...";

        b2BodyDef bodyDef;

        std::string type = body.attribute("type").value();
        std::string name = body.attribute("name").value();

        log << "\t attributes : name -> " << name << " type -> " << type;

        if(type.compare("dynamic") == 0)
        {
            bodyDef.type = b2_dynamicBody;
            bodyDef.allowSleep = true;
            bodyDef.awake = false;
        }

        //for(pugi::xml_node fixture = body.child("fixture"); fixture; fixture = body.next_sibling("fixture"))
        {
            pugi::xml_node fixture = body.child("fixture");

            b2FixtureDef fixtureDef;

            float density, friction, restitution = 0.0f;

            density = fixture.attribute("density").as_float();
            friction = fixture.attribute("friction").as_float();
            restitution = fixture.attribute("restitution").as_float();

            fixtureDef.density = density;
            fixtureDef.friction = friction;
            fixtureDef.restitution = restitution;

            log << "\t\t Fixture : density ->" << density << " friction -> " << friction << " restitution -> " << restitution;

            pugi::xml_node shape = fixture.child("shape");

            std::string shapeType = shape.attribute("type").value();

            if(shapeType.compare("box") == 0)
            {
                b2PolygonShape* boxShape = new b2PolygonShape();
                pugi::xml_node point = shape.child("point");

                float pX, pY = 0.0f;

                pX = Utils::pixelsToMeters(point.attribute("x").as_float())/2;
                pY = Utils::pixelsToMeters(point.attribute("y").as_float())/2;

                log << "\t\t\t Box : x -> " << pX << " y -> " << pY;

                boxShape->SetAsBox(pX,pY);

                fixtureDef.shape = boxShape;


                myBodyDef[name] = std::make_tuple(bodyDef,fixtureDef,boxShape);
            }

        }
    }
}
Beispiel #12
0
	const pugi::char_t* GetValue(const char* name)
	{
		return m_system_doc.child(name).child_value();
	}