Пример #1
0
bool XMLSceneVisitor::VisitExit( const TiXmlElement& element)
{
    if(element.ValueStr() == "scene")
    {
        return (element.Parent() == element.GetDocument());
    }
    else if (element.ValueStr() == "materials")
    {
        return true;
    }
    else if (element.ValueStr() == "primitives")
    {
        return true;
    }
    else if (element.ValueStr() == "plane")
    {
        m_scene->insert_primitive(m_current);
        m_current = NULL;
        return true;
    }
    else if (element.ValueStr() == "sphere")
    {
        m_scene->insert_primitive(m_current);
        m_current = NULL;
        return true;
    }
    else
        return false;
}
Пример #2
0
bool Rule::LoadFromXml(TiXmlElement *node)
{
    TiXmlAttribute *attr = node->ToElement()->FirstAttribute();

    for (; attr; attr = attr->Next())
    {
        if (string(attr->Name()) != "name" && string(attr->Name()) != "type")
            params.Add(attr->Name(), attr->ValueStr());
    }

    TiXmlElement *cnode = node->FirstChildElement();

    for (; cnode; cnode = cnode->NextSiblingElement())
    {
        if (cnode->ValueStr() == "calaos:condition")
        {
            Condition *cond = RulesFactory::CreateCondition(cnode);
            if (cond)
                AddCondition(cond);
        }
        else if (cnode->ValueStr() == "calaos:action")
        {
            Action *action = RulesFactory::CreateAction(cnode);
            if (action)
                AddAction(action);
        }
    }

    return true;
}
Пример #3
0
void CIRTranslator::MapRemote(TiXmlNode *pRemote, const std::string &szDevice)
{
  CLog::Log(LOGINFO, "* Adding remote mapping for device '%s'", szDevice.c_str());

  std::vector<std::string> remoteNames;

  auto it = m_irRemotesMap.find(szDevice);
  if (it == m_irRemotesMap.end())
    m_irRemotesMap[szDevice].reset(new IRButtonMap);

  std::shared_ptr<IRButtonMap>& buttons = m_irRemotesMap[szDevice];

  TiXmlElement *pButton = pRemote->FirstChildElement();
  while (pButton != nullptr)
  {
    if (!pButton->NoChildren())
    {
      if (pButton->ValueStr() == "altname")
        remoteNames.push_back(pButton->FirstChild()->ValueStr());
      else
        (*buttons)[pButton->FirstChild()->ValueStr()] = pButton->ValueStr();
    }
    pButton = pButton->NextSiblingElement();
  }

  for (const auto& remoteName : remoteNames)
  {
    CLog::Log(LOGINFO, "* Linking remote mapping for '%s' to '%s'", szDevice.c_str(), remoteName.c_str());
    m_irRemotesMap[remoteName] = buttons;
  }
}
Пример #4
0
void ModelLibrary::LoadAnimsFromXML(TiXmlElement* parent, vector<SAnimation*>* anims, vector<SSound*>* sounds)
{
	TiXmlElement* child;
	for(child = parent->FirstChildElement(); child; child = child->NextSiblingElement())
	{
		if (child->ValueStr() == "sound") 
		{
			SSound* s = new SSound();
			s->filename = child->Attribute(FILENAME);
			child->Attribute(SOUNDLOOP, &s->soundloop);
			sounds->push_back(s);

			Ogre::LogManager::getSingleton().logMessage("XML: SOUND: "+s->filename);
		}
		else if (child->ValueStr() == "animation")
		{
			SAnimation* a = new SAnimation();
			a->name = child->Attribute(ANIMNAME);
			child->Attribute(FRAMES, &a->frames);
			child->Attribute(LOOP, &a->loop);
			anims->push_back(a);

			Ogre::LogManager::getSingleton().logMessage("XML: ANIM: "+a->name);
		}
		else
		{
			Ogre::LogManager::getSingleton().logMessage("XML: subPart : should never get here *giggles*");
			Ogre::LogManager::getSingleton().logMessage("XML: subPart : culporate: "+child->ValueStr());
		};
	}
}
Пример #5
0
void PRFParser::parseFile (TiXmlElement *elem)
{
    DEBUG(4, PRFParser, "In parseFile.");

    TiXmlElement *prop = elem->FirstChildElement();


    DEBUG(8, PRFParser, "Process property entries");
    for ( ; prop; prop = prop->NextSiblingElement()) {
	DEBUG(8, PRFParser, "Found property " << prop->ValueStr());
        std::string str = prop->ValueStr();

        if (str == "simple") addProperty (new PRFSimpleProperty(prop));
	if (str == "simplesequence") addProperty (new PRFSimpleSequenceProperty(prop));

    }
    DEBUG(9, PRFParser, "Done processing property entries");

    for (unsigned int i = 0; i < configProperties.size(); i++)
	allProperties.push_back (configProperties[i]);

    for (unsigned int i = 0; i < capacityProperties.size (); i++)
	allProperties.push_back (capacityProperties[i]);

    for (unsigned int i = 0; i < matchingProperties.size (); i++)
	allProperties.push_back (matchingProperties[i]);

    for (unsigned int i = 0; i < execProperties.size (); i++)
	allProperties.push_back (execProperties[i]);

    for (unsigned int i = 0; i < factoryProperties.size (); i++)
	allProperties.push_back (factoryProperties[i]);

}
Пример #6
0
void CreatureManager::loadCreatureBuffer(const std::string& buffer)
{
    TiXmlDocument doc;
    doc.Parse(buffer.c_str());
    if(doc.Error())
        stdext::throw_exception(stdext::format("cannot load creature buffer: %s", doc.ErrorDesc()));

    TiXmlElement* root = doc.FirstChildElement();
    if(!root || (root->ValueStr() != "monster" && root->ValueStr() != "npc"))
        stdext::throw_exception("invalid root tag name");

    std::string cName = root->Attribute("name");
    stdext::tolower(cName);
    stdext::trim(cName);
    stdext::ucwords(cName);

    CreatureTypePtr newType(new CreatureType(cName));
    for(TiXmlElement* attrib = root->FirstChildElement(); attrib; attrib = attrib->NextSiblingElement()) {
        if(attrib->ValueStr() != "look")
            continue;

        internalLoadCreatureBuffer(attrib, newType);
        break;
    }

    doc.Clear();
}
Пример #7
0
TiXmlElement *FirstChildScraperElement(TiXmlElement *element)
{
  for (TiXmlElement *child = element->FirstChildElement(); child; child = child->NextSiblingElement())
  {
    if (child->ValueStr() == "RegExp" || child->ValueStr() == "XSLT")
      return child;
  }
  return NULL;
}
 virtual bool VisitEnter(const TiXmlElement &elt, const TiXmlAttribute *)
 {
   if (elt.Attribute("name") &&
         ( elt.ValueStr() == std::string("actuator")
        || elt.ValueStr() == std::string("rightActuator")
        || elt.ValueStr() == std::string("leftActuator") )) 
     actuators.insert(elt.Attribute("name"));
   return true;
 }
Пример #9
0
TiXmlElement *NextSiblingScraperElement(TiXmlElement *element)
{
  for (TiXmlElement *next = element->NextSiblingElement(); next; next = next->NextSiblingElement())
  {
    if (next->ValueStr() == "RegExp" || next->ValueStr() == "XSLT")
      return next;
  }
  return NULL;
}
Пример #10
0
void CSvsFile::LoadXML()
{
	UnloadXML();
	TiXmlDocument XmlDoc;
	XmlDoc.SetCondenseWhiteSpace(false);
	ifstream iXML( m_strFile.c_str() );
	if (!iXML)
	{
		GenErr("技能配置表转换文件读取错误", m_strFile);
	}
	iXML>>XmlDoc;
	iXML.close();

	TiXmlNode* pBody = XmlDoc.FirstChild("body");
	TiXmlNode* pTable = pBody->FirstChild("table");

	for ( TiXmlNode* pTr = pTable->FirstChild(); pTr; pTr = pTr->NextSibling() )
	{
		TiXmlElement* pElemet = pTr->ToElement();
		if (!pElemet)
			continue;

		if(pElemet->ValueStr() != "tr")
			continue;

		m_vecTR.resize(m_vecTR.size() + 1);
		TableRow& vecTD = m_vecTR.back();		
		for ( TiXmlNode* pTd = pTr->FirstChild(); pTd; pTd=pTd->NextSibling() )
		{
			TiXmlElement* pElemet = pTd->ToElement();
			if (!pElemet)
				continue;

			if(pElemet->ValueStr() != "td")
				continue;

			TiXmlNode* pParagraph = pTd->FirstChild();
			TiXmlElement* pParaElemet = pParagraph->ToElement();
			if(!pParaElemet || pParaElemet->ValueStr() != "p")
			{
				GenErr("<td>读取<p>不存在");
			}

			TableData aTD;

			aTD.m_eTDType = GetTableDataType(pParaElemet->Attribute("t"));
			if(pParaElemet->FirstChild())
			{
				aTD.m_sTDValue = utf8_to_gbk(pParaElemet->GetText());
				XMLDecode(aTD.m_sTDValue);
			}

			vecTD.push_back(aTD);
		}
	}
}
Пример #11
0
bool XMLSceneVisitor::VisitEnter(const TiXmlElement& element, const TiXmlAttribute* attribute)
{
    if(element.ValueStr() == "scene")
    {
        return (element.Parent() == element.GetDocument());
    }
    else if (element.ValueStr() == "materials")
    {
        return true;
    }
    else if (element.ValueStr() == "primitives")
    {
        return (element.Parent()->ValueStr() == "scene");
    }
    else if (element.ValueStr() == "plane")
    {
        if(element.Parent()->ValueStr() != "primitives")
            return false;
        assert(m_current == NULL);

        double nx(0.0f), ny(1.0f), nz(0.0f), value(0.0f);

        element.Attribute("nx", &nx);
        element.Attribute("ny", &ny);
        element.Attribute("nz", &nz);
        element.Attribute("value", &value);

        glm::vec3 normal(nx, ny, nz);
        normal = glm::normalize(normal);

        m_current = new Scene::Plane(normal, value);
        return true;
    }
    else if (element.ValueStr() == "sphere")
    {
        if(element.Parent()->ValueStr() != "primitives")
            return false;
        assert(m_current == NULL);

        double cx(0.0f), cy(1.0f), cz(0.0f), radius(0.0f);

        element.Attribute("cx", &cx);
        element.Attribute("cy", &cy);
        element.Attribute("cz", &cz);
        element.Attribute("radius", &radius);

        glm::vec3 center(cx, cy, cz);
        m_current = new Scene::Sphere(center, radius);
        return true;
    }
    else
        return false;
}
Пример #12
0
TiXmlElement *FirstChildScraperElement(TiXmlElement *element)
{
  for (TiXmlElement *child = element->FirstChildElement(); child; child = child->NextSiblingElement())
  {
#ifdef HAVE_LIBXSLT
    if (child->ValueStr() == "XSLT")
      return child;
#endif
    if (child->ValueStr() == "RegExp")
      return child;
  }
  return NULL;
}
Пример #13
0
TiXmlElement *NextSiblingScraperElement(TiXmlElement *element)
{
  for (TiXmlElement *next = element->NextSiblingElement(); next; next = next->NextSiblingElement())
  {
#ifdef HAVE_LIBXSLT
    if (next->ValueStr() == "XSLT")
      return next;
#endif
    if (next->ValueStr() == "RegExp")
      return next;
  }
  return NULL;
}
Пример #14
0
RobotInterface::ParamList RobotInterface::XMLReader::Private::readParamListTag(TiXmlElement* paramListElem)
{
    if (paramListElem->ValueStr().compare("paramlist") != 0) {
        SYNTAX_ERROR(paramListElem->Row()) << "Expected \"paramlist\". Found" << paramListElem->ValueStr();
    }

    ParamList params;
    Param mainparam;

    if (paramListElem->QueryStringAttribute("name", &mainparam.name()) != TIXML_SUCCESS) {
        SYNTAX_ERROR(paramListElem->Row()) << "\"paramlist\" element should contain the \"name\" attribute";
    }

    params.push_back(mainparam);

    // yDebug() << "Found paramlist [" << params.at(0).name() << "]";

    for (TiXmlElement* childElem = paramListElem->FirstChildElement(); childElem != 0; childElem = childElem->NextSiblingElement()) {
        if (childElem->ValueStr().compare("elem") != 0) {
            SYNTAX_ERROR(childElem->Row()) << "Expected \"elem\". Found" << childElem->ValueStr();
        }

        Param childParam;

        if (childElem->QueryStringAttribute("name", &childParam.name()) != TIXML_SUCCESS) {
            SYNTAX_ERROR(childElem->Row()) << "\"elem\" element should contain the \"name\" attribute";
        }

        const char *valueText = childElem->GetText();
        if (!valueText) {
            SYNTAX_ERROR(childElem->Row()) << "\"elem\" element should have a value [ \"name\" = " << childParam.name() << "]";
        }
        childParam.value() = valueText;

        params.push_back(childParam);
    }

    if (params.empty()) {
        SYNTAX_ERROR(paramListElem->Row()) << "\"paramlist\" cannot be empty";
    }

    // +1 skips the first element, that is the main param
    for (ParamList::iterator it = params.begin() + 1; it != params.end(); ++it) {
        Param &param = *it;
        params.at(0).value() += (params.at(0).value().empty() ? "(" : " ") + param.name();
    }
    params.at(0).value() += ")";

    // yDebug() << params;
    return params;
}
Пример #15
0
bool Facade::readXml(TiXmlElement* e)
{
	// reset for reloading
	reset();

	TiXmlElement* child = e->FirstChildElement();
	while(child != NULL)
	{
		if(child->ValueStr() == "move")
		{
			int x = Xml::getAttrInt(child, "x");
			int y = Xml::getAttrInt(child, "y"); 
			moveSides(x, y);
			LOG_DEBUG << "Facade: Moving sides: " << x << " " << y << endl;
		}
		else if(child->ValueStr() == "sides")
		{
			TiXmlElement* child2 = child->FirstChildElement();
			while(child2 != NULL)
			{
				if(child2->ValueStr() == "MainEast")
					parseSideXml(child2, facade::SIDE_MAIN_EAST);
				else if(child2->ValueStr() == "MainNorth")
					parseSideXml(child2, facade::SIDE_MAIN_NORTH);
				else if(child2->ValueStr() == "MainWest")
					parseSideXml(child2, facade::SIDE_MAIN_WEST);
				else if(child2->ValueStr() == "MainSouth")
					parseSideXml(child2, facade::SIDE_MAIN_SOUTH);
				else if(child2->ValueStr() == "MainSouthStreet")
					parseSideXml(child2, facade::SIDE_MAIN_SOUTH_STREET);
				else if(child2->ValueStr() == "LabEast")
					parseSideXml(child2, facade::SIDE_LAB_EAST);
				else if(child2->ValueStr() == "LabNorth")
					parseSideXml(child2, facade::SIDE_LAB_NORTH);
				else if(child2->ValueStr() == "LabSouth")
					parseSideXml(child2, facade::SIDE_LAB_SOUTH);
				else
					LOG_WARN << "Facade: Unknown element \""
					         << child->ValueStr() << "\"" << endl;
					
				 child2 = child2->NextSiblingElement();
			}
		}

		child = child->NextSiblingElement();
	}

	recomputeSize();

	return true;
}
Пример #16
0
	bool CPluginDefVisitor::VisitEnter(const TiXmlElement &element, const TiXmlAttribute *firstAttribute)
	{
		if(element.ValueStr() == _plugin)
			return ProcessPluginDef(element, firstAttribute);
		else if (element.ValueStr() == _prereq)
			return ProcessPrerequisites(element, firstAttribute);
		else if (element.ValueStr() == _exports)
			return ProcessExports(element, firstAttribute);
		else if (element.ValueStr() == _provides)
			return ProcessProvides(element, firstAttribute);
		else if (element.ValueStr() == _extends)
			return ProcessExtends(element, firstAttribute);
			
		return false;
	}
Пример #17
0
RobotInterface::Robot& RobotInterface::XMLReader::Private::readRobotTag(TiXmlElement *robotElem)
{
    if (robotElem->ValueStr().compare("robot") != 0) {
        SYNTAX_ERROR(robotElem->Row()) << "Root element should be \"robot\". Found" << robotElem->ValueStr();
    }

    if (robotElem->QueryStringAttribute("name", &robot.name()) != TIXML_SUCCESS) {
        SYNTAX_ERROR(robotElem->Row()) << "\"robot\" element should contain the \"name\" attribute";
    }

#if TINYXML_UNSIGNED_INT_BUG
    if (robotElem->QueryUnsignedAttribute("build", &robot.build()) != TIXML_SUCCESS) {
        // No build attribute. Assuming build="0"
        SYNTAX_WARNING(robotElem->Row()) << "\"robot\" element should contain the \"build\" attribute [unsigned int]. Assuming 0";
    }
#else
    int tmp;
    if (robotElem->QueryIntAttribute("build", &tmp) != TIXML_SUCCESS || tmp < 0) {
        // No build attribute. Assuming build="0"
        SYNTAX_WARNING(robotElem->Row()) << "\"robot\" element should contain the \"build\" attribute [unsigned int]. Assuming 0";
        tmp = 0;
    }
    robot.build() = (unsigned)tmp;
#endif

    if (robotElem->QueryStringAttribute("portprefix", &robot.portprefix()) != TIXML_SUCCESS) {
        SYNTAX_WARNING(robotElem->Row()) << "\"robot\" element should contain the \"portprefix\" attribute. Using \"name\" attribute";
        robot.portprefix() = robot.name();
    }

    // yDebug() << "Found robot [" << robot.name() << "] build [" << robot.build() << "] portprefix [" << robot.portprefix() << "]";

    for (TiXmlElement* childElem = robotElem->FirstChildElement(); childElem != 0; childElem = childElem->NextSiblingElement()) {
        if (childElem->ValueStr().compare("device") == 0 || childElem->ValueStr().compare("devices") == 0) {
            DeviceList childDevices = readDevices(childElem);
            for (DeviceList::const_iterator it = childDevices.begin(); it != childDevices.end(); ++it) {
                robot.devices().push_back(*it);
            }
        } else {
            ParamList childParams = readParams(childElem);
            for (ParamList::const_iterator it = childParams.begin(); it != childParams.end(); ++it) {
                robot.params().push_back(*it);
            }
        }
    }

    return robot;
}
Пример #18
0
boost::shared_ptr<Geometry> parseGeometry(TiXmlElement *g)
{
  boost::shared_ptr<Geometry> geom;
  if (!g) return geom;

  TiXmlElement *shape = g->FirstChildElement();
  if (!shape)
  {
    ROS_ERROR("Geometry tag contains no child element.");
    return geom;
  }

  std::string type_name = shape->ValueStr();
  if (type_name == "sphere")
    geom.reset(new Sphere);
  else if (type_name == "box")
    geom.reset(new Box);
  else if (type_name == "cylinder")
    geom.reset(new Cylinder);
  else if (type_name == "mesh")
    geom.reset(new Mesh);
  else
  {
    ROS_ERROR("Unknown geometry type '%s'", type_name.c_str());
    return geom;
  }

  // clear geom object when fails to initialize
  if (!geom->initXml(shape)){
    ROS_ERROR("Geometry failed to parse");
    geom.reset();
  }

  return geom;
}
Пример #19
0
   virtual void process(TiXmlElement* root, int version)
   {
      static_cast<void>(version);
      std::string mngr;
      utilib::get_string_attribute( root, "process_manager", mngr, 
                            ExecuteManager::default_process_mngr );
      ExecuteMngr().set_process_manager(mngr);
      

      // each child element should be a valid command...
      TiXmlElement* node = root->FirstChildElement();

      // special case: if it is an empty element, just execute the last
      // solver
      if ( node == NULL )
      {
         string solver = SolverMngr().get_newest_solver();
         if ( ! solver.empty() )
            ExecuteMngr().run_command(string("solve:") + solver);
         return;
      }
      
      int rank;
      int myRank = ExecuteMngr().rank();

      // step through all the commands
      for( ; node != NULL; node = node->NextSiblingElement() )
      {
         utilib::get_num_attribute( node, "rank", rank, ExecuteManager::local );
         if (( rank == ExecuteManager::local ) || ( rank == myRank ))
            ExecuteMngr().run_command(node->ValueStr(), rank, node);
      }
   }
Пример #20
0
bool html_parse::_parse(TiXmlDocument& doc)
{
    TiXmlElement* rootElement = doc.RootElement();
    if (!rootElement)
    {
        return false;
    }

    std::string rootName = rootElement->ValueStr();
    if (rootName.empty()
        || rootName != "html")
    {
        return false;
    }

    for (TiXmlNode* nodeRoot = rootElement->FirstChildElement();
        nodeRoot != nullptr;
        nodeRoot = nodeRoot->NextSiblingElement())
    {
        html_object* object = new html_object;
        if (!object)
        {
            continue;
        }

        if (object->parse(nodeRoot))
        {
            m_htmlElement.push_back(object);
        }
    }
    return true;
}
Пример #21
0
bool CMediaSourceSettings::Load(const std::string &file)
{
  Clear();

  if (!CFile::Exists(file))
    return false;

  CLog::Log(LOGNOTICE, "CMediaSourceSettings: loading media sources from %s", file.c_str());

  // load xml file
  CXBMCTinyXML xmlDoc;
  if (!xmlDoc.LoadFile(file))
  {
    CLog::Log(LOGERROR, "CMediaSourceSettings: error loading %s: Line %d, %s", file.c_str(), xmlDoc.ErrorRow(), xmlDoc.ErrorDesc());
    return false;
  }

  TiXmlElement *pRootElement = xmlDoc.RootElement();
  if (pRootElement == NULL || !StringUtils::EqualsNoCase(pRootElement->ValueStr(), XML_SOURCES))
    CLog::Log(LOGERROR, "CMediaSourceSettings: sources.xml file does not contain <sources>");

  // parse sources
  std::string dummy;
  GetSources(pRootElement, "video", m_videoSources, dummy);
  GetSources(pRootElement, "programs", m_programSources, m_defaultProgramSource);
  GetSources(pRootElement, "pictures", m_pictureSources, m_defaultPictureSource);
  GetSources(pRootElement, "files", m_fileSources, m_defaultFileSource);
  GetSources(pRootElement, "music", m_musicSources, m_defaultMusicSource);

  return true;
}
DefaultShaderParameters::DefaultShaderParameters(string filename) {
	TiXmlDocument doc(filename);
	if (!doc.LoadFile()) {
		return;
	}

	TiXmlHandle hDoc(&doc);
	TiXmlElement* pElem;
	TiXmlHandle hRoot(0);

	pElem=hDoc.FirstChildElement().Element();
	if (!pElem) {
		return;
	}

	pElem=pElem->FirstChildElement();
	for(pElem; pElem; pElem=pElem->NextSiblingElement()) {
		string entry_name = pElem->ValueStr();

		if (entry_name=="Parameter") {
			DefaultShaderParameter *parameter = new DefaultShaderParameter();
			parameter->read(pElem);
			parameters.push_back(parameter);
		}
	}
}
Пример #23
0
bool CController::LoadLayout(void)
{
  if (!m_bLoaded)
  {
    std::string strLayoutXmlPath = LibPath();

    CLog::Log(LOGINFO, "Loading controller layout: %s", CURL::GetRedacted(strLayoutXmlPath).c_str());

    CXBMCTinyXML xmlDoc;
    if (!xmlDoc.LoadFile(strLayoutXmlPath))
    {
      CLog::Log(LOGDEBUG, "Unable to load file: %s at line %d", xmlDoc.ErrorDesc(), xmlDoc.ErrorRow());
      return false;
    }

    TiXmlElement* pRootElement = xmlDoc.RootElement();
    if (!pRootElement || pRootElement->NoChildren() || pRootElement->ValueStr() != LAYOUT_XML_ROOT)
    {
      CLog::Log(LOGERROR, "Can't find root <%s> tag", LAYOUT_XML_ROOT);
      return false;
    }

    m_layout->Deserialize(pRootElement, this, m_features);
    if (m_layout->IsValid(true))
    {
      m_bLoaded = true;
    }
    else
    {
      m_layout->Reset();
    }
  }

  return m_bLoaded;
}
Пример #24
0
bool Sprite::readXml(TiXmlElement* e)
{
	string name;

	TiXmlElement* child = e->FirstChildElement();
	while(child != NULL)
	{
		if(child->ValueStr() == "bitmap")
		{
			//if((name = Xml::getAttrString(child, "name")) != "")
			//{
			name = Xml::getAttrString(child, "name");
				LOG_DEBUG << "Sprite: Loading bitmap \"" << name << "\"" << std::endl;
				Bitmap* b = new Bitmap(name);
				b->loadXml(child);
				addBitmap(b);
			//}
			/*
			else
			{

				LOG_WARN << "Sprite: Cannot load bitmap without name, line "
						 << child->Row() << endl;
			}
			*/
		}

		child = child->NextSiblingElement();
	}

	// init all loaded bitmaps draw settings
	setDrawFromCenter(bDrawFromCenter);

	return true;
}
Пример #25
0
bool CMetadataResolverMusic::LoadAlbumsInfo(BOXEE::BXXMLDocument& doc, vectorMetadata& list)
{
  TiXmlElement* pRootElement = doc.GetDocument().RootElement();
  bool bRetVal = true;
  if (pRootElement->ValueStr() == "results")
  {
    TiXmlNode* pTag = 0;
    BXMetadata album(MEDIA_ITEM_TYPE_AUDIO);

    while ((pTag = pRootElement->IterateChildren(pTag)))
    {
      if (pTag && pTag->ValueStr() == "album")
      {
        TiXmlElement* pValue = pTag->FirstChildElement();

        if (pValue && (LoadAlbumInfo(pValue,album)))
          list.push_back(album);
        else
           bRetVal = false;
      }
      else
        bRetVal = false;
    }
  }
  else
    bRetVal = false;

  return bRetVal;
}
Пример #26
0
void Leaf::loadLeaf(TiXmlElement *node)
{
	int nbStates=0, i=0;
	node->QueryIntAttribute("nbPatchs", &_nbPatchs);
	node->QueryDoubleAttribute("conf", &_conf);
	node->QueryIntAttribute("nbStates", &nbStates);
	node->QueryIntAttribute("meanOffsetX", &_meanOffsets.x);
	node->QueryIntAttribute("meanOffsetY", &_meanOffsets.y);
	node->QueryDoubleAttribute("varianceOffsetX", &_varOffsets.x);
	node->QueryDoubleAttribute("varianceOffsetY", &_varOffsets.y);
    node->QueryDoubleAttribute("varianceTrace", &_varTrace);

	_stateVectorMean = cv::Mat(nbStates, 1, CV_64F, cv::Scalar_<double>(0));
	_stateVectorVariance = cv::Mat(nbStates, 1, CV_64F, cv::Scalar_<double>(0));

	for (TiXmlElement *pState = node->FirstChildElement() ; pState ; pState = pState->NextSiblingElement())
	{
		double mean, var;
		_stateVectorNames.push_back(pState->ValueStr());
		pState->QueryDoubleAttribute("mean", &mean);
		pState->QueryDoubleAttribute("variance", &var);

        _stateVectorMean.at<double>(i) = mean;
		_stateVectorVariance.at<double>(i) = var;
		i++;
	}
}
Пример #27
0
/*! \brief Tries to load ids and strings from a strings.xml file to the `strings` map..
 * It should only be called from the LoadStr2Mem function to try a PO file first.
 \param pathname The directory name, where we look for the strings file.
 \param strings [out] The resulting strings map.
 \param encoding Encoding of the strings.
 \param offset An offset value to place strings from the id value.
 \return false if no strings.xml file was loaded.
 */
static bool LoadXML(const std::string &filename, std::map<uint32_t, LocStr>& strings,
    std::string &encoding, uint32_t offset = 0)
{
  CXBMCTinyXML xmlDoc;
  if (!xmlDoc.LoadFile(filename))
  {
    CLog::Log(LOGDEBUG, "unable to load %s: %s at line %d", filename.c_str(), xmlDoc.ErrorDesc(), xmlDoc.ErrorRow());
    return false;
  }

  TiXmlElement* pRootElement = xmlDoc.RootElement();
  if (!pRootElement || pRootElement->NoChildren() ||
      pRootElement->ValueStr()!="strings")
  {
    CLog::Log(LOGERROR, "%s Doesn't contain <strings>", filename.c_str());
    return false;
  }

  const auto originalSize = strings.size();
  const TiXmlElement *pChild = pRootElement->FirstChildElement("string");
  while (pChild)
  {
    // Load old style language file with id as attribute
    const char* attrId=pChild->Attribute("id");
    if (attrId && !pChild->NoChildren())
    {
      uint32_t id = atoi(attrId) + offset;
      if (strings.find(id) == strings.end())
        strings[id].strTranslated = pChild->FirstChild()->Value();
    }
    pChild = pChild->NextSiblingElement("string");
  }
  CLog::Log(LOGDEBUG, "LocalizeStrings: loaded %i strings from file %s", strings.size() - originalSize, filename.c_str());
  return true;
}
	void ObjectLibrary::loadDatabase(string filename) {
		TiXmlDocument doc(filename);
		if (!doc.LoadFile()) {
			Error::addMessage(Error::FILE_NOT_FOUND, LIBGENS_LIBRARY_ERROR_FILE + filename);
			return;
		}

		TiXmlHandle hDoc(&doc);
		TiXmlElement* pElem;
		TiXmlHandle hRoot(0);

		pElem=hDoc.FirstChildElement().Element();
		if (!pElem) {
			Error::addMessage(Error::EXCEPTION, LIBGENS_LIBRARY_ERROR_FILE_ROOT);
			return;
		}

		pElem=pElem->FirstChildElement();
		for(pElem; pElem; pElem=pElem->NextSiblingElement()) {
			string entry_name="";
			string category_name="";
			string folder_name="";

			entry_name = pElem->ValueStr();
			pElem->QueryValueAttribute(LIBGENS_LIBRARY_NAME_ATTRIBUTE, &category_name);
			pElem->QueryValueAttribute(LIBGENS_LIBRARY_FOLDER_ATTRIBUTE, &folder_name);

			if ((entry_name==LIBGENS_LIBRARY_ENTRY) && category_name.size() && folder_name.size()) {
				loadCategory(category_name, folder_name);
			}
		}
	}
Пример #29
0
bool CController::LoadLayout(void)
{
  if (!m_bLoaded)
  {
    std::string strLayoutXmlPath = LibPath();

    CXBMCTinyXML xmlDoc;
    if (!xmlDoc.LoadFile(strLayoutXmlPath))
    {
      CLog::Log(LOGDEBUG, "Unable to load %s: %s at line %d", strLayoutXmlPath.c_str(), xmlDoc.ErrorDesc(), xmlDoc.ErrorRow());
      return false;
    }

    TiXmlElement* pRootElement = xmlDoc.RootElement();
    if (!pRootElement || pRootElement->NoChildren() || pRootElement->ValueStr() != LAYOUT_XML_ROOT)
    {
      CLog::Log(LOGERROR, "%s: Can't find root <%s> tag", strLayoutXmlPath.c_str(), LAYOUT_XML_ROOT);
      return false;
    }

    CLog::Log(LOGINFO, "Loading controller layout %s", strLayoutXmlPath.c_str());

    if (m_layout.Deserialize(pRootElement, this))
      m_bLoaded = true;
  }

  return m_bLoaded;
}
Пример #30
0
bool CLocalizeStrings::LoadXML(const CStdString &filename, CStdString &encoding, uint32_t offset /* = 0 */)
{
  TiXmlDocument xmlDoc;
  if (!xmlDoc.LoadFile(CSpecialProtocol::TranslatePathConvertCase(filename)))
  {
    CLog::Log(LOGDEBUG, "unable to load %s: %s at line %d", filename.c_str(), xmlDoc.ErrorDesc(), xmlDoc.ErrorRow());
    return false;
  }

  XMLUtils::GetEncoding(&xmlDoc, encoding);

  TiXmlElement* pRootElement = xmlDoc.RootElement();
  if (!pRootElement || pRootElement->NoChildren() ||
       pRootElement->ValueStr()!=CStdString("strings"))
  {
    CLog::Log(LOGERROR, "%s Doesn't contain <strings>", filename.c_str());
    return false;
  }

  const TiXmlElement *pChild = pRootElement->FirstChildElement("string");
  while (pChild)
  {
    // Load new style language file with id as attribute
    const char* attrId=pChild->Attribute("id");
    if (attrId && !pChild->NoChildren())
    {
      int id = atoi(attrId) + offset;
      if (m_strings.find(id) == m_strings.end())
        m_strings[id] = ToUTF8(encoding, pChild->FirstChild()->Value());
    }
    pChild = pChild->NextSiblingElement("string");
  }
  return true;
}