Esempio n. 1
0
/** Get all the language nodes and call TreatOneLanguage for each one
  *
  */
void RainbruRPG::Options::xmlLanguage::treatAllLanguages(){
  TiXmlNode* childNode = root->FirstChild( "Language" );
  if (childNode){
    TiXmlElement* child= childNode->ToElement();
    for( child; child; child=child->NextSiblingElement() ){
      treatOneLanguage(child);
    }

  }
  else{
    LOGW(_("Empty language list found"));
  }

}
Esempio n. 2
0
void zzzSndSystem::LoadSounds()
{
	//read xml & load sets
	DataStreamPtr data = ResourceGroupManager::getSingleton().openResource("sounds.xml");
	String str = data->getAsString();
	TiXmlDocument doc;
	doc.Parse(str.c_str());

	if (!doc.Error())
	{
		TiXmlNode* node;
		node=doc.FirstChild();
		node=node->FirstChild();
		for (;node!=0;node=node->NextSibling()) 
		{
			if (node->Type() == TiXmlNode::ELEMENT)
			{
				//get params
				String name = "";
				String file = "";

				if (strcmp(node->Value(), "sound") == 0)
				{
					TiXmlAttribute* att = node->ToElement()->FirstAttribute();
					while (att)
					{
						if (strcmp(att->Name(), "name") == 0)
						{
							name = att->Value();
						}
						else if (strcmp(att->Name(), "file") == 0)
						{
							file = att->Value();
						}
						att = att->Next();
					}

					if (name.length() > 0)
					{
						SND->LoadSound(name, file);
					}
				}
			}
		}
	}
	else
	{
		throw Exception(Exception::ERR_FILE_NOT_FOUND, std::string(doc.ErrorDesc()) + " : particles.xml", __FUNCTION__);
	}
}
Esempio n. 3
0
void MSBInfo::XMLProcessBackground(TiXmlNode* bg)
{
	if (bg)
	{
		TiXmlNode* child = 0;
		_page->Text = "";
		while((child = bg->IterateChildren(child)))
		{
			if (child->ValueStr().compare("avobject") == 0)
			{
				TiXmlElement* av = child->ToElement();
				_page->Image = av->Attribute("filename");
			}
			if (child->ValueStr().compare("txt") == 0)
			{
				TiXmlElement* txt = child->ToElement();
				_page->Text += txt->GetText();
			}
		}
	}
	else
		Core::Dbg->Log(Warning, "NULL value passed to utterance node handler");
}
/**
 Wczytuje atrybuty algorytmu.
 Wczytana zostaje miedzy innymi nazwa alogrytmu.
 
 @param algo Wskaznik do konfigurowanego algorytmu
*/
void XMLConfigFile::LoadAlgorithmSettings(Algorithm* algo) {
    TRACE( "XMLConfigFile::LoadAlgorithmSettings - Wczytywanie ustawien algorytmu...\n" );
	TiXmlElement* algoXmlElem;
	TiXmlNode* algoXmlNode;
	string algoName;

    TiXmlHandle docHandle( &document );
	algoXmlNode = docHandle.FirstChild( "algorithm" ).Node();
	if(algoXmlElem != NULL) {
       	algoXmlElem = algoXmlNode->ToElement();
		if( algoXmlElem->Attribute("name") )
			algo->SetName( algoXmlElem->Attribute("name") );
	}
}
Esempio n. 5
0
void TiXmlDocument::StreamIn(std::istream * in, TIXML_STRING * tag) {
    // The basic issue with a document is that we don't know what we're
    // streaming. Read something presumed to be a tag (and hope), then
    // identify it, and call the appropriate stream method on the tag.
    //
    // This "pre-streaming" will never read the closing ">" so the
    // sub-tag can orient itself.

    if (!StreamTo(in, '<', tag)) {
        SetError(TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN);
        return;
    }

    while (in->good()) {
        int tagIndex = (int) tag->length();
        while (in->good() && in->peek() != '>') {
            int c = in->get();
            if (c <= 0) {
                SetError(TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN);
                break;
            }
            (*tag) += (char) c;
        }

        if (in->good()) {
            // We now have something we presume to be a node of 
            // some sort. Identify it, and call the node to
            // continue streaming.
            TiXmlNode* node = Identify(tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING);

            if (node) {
                node->StreamIn(in, tag);
                bool isElement = node->ToElement() != 0;
                delete node;
                node = 0;

                // If this is the root element, we're done. Parsing will be
                // done by the >> operator.
                if (isElement) {
                    return;
                }
            } else {
                SetError(TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN);
                return;
            }
        }
    }
    // We should have returned sooner.
    SetError(TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN);
}
Esempio n. 6
0
const String& MimeType::comment(void) {
	// calling without mime loaded do nothing
	if(!(status & MIME_LOADED))
		return mcmt;

	if(status & COMMENT_LOADED)
		return mcmt;

	String ttype = mtype;
	ttype += ".xml";

	const char* p = xdg_mime_find_data(ttype.c_str());
	if(!p)
		return mcmt;

	String path = p;
	
	TiXmlDocument doc(path.c_str());

	if(!doc.LoadFile()) {
		E_DEBUG(E_STRLOC ": MimeType::comment() %s malformed\n", path.c_str());
		return mcmt;
	}

	TiXmlNode* el = doc.FirstChild("mime-type");

	/*
	 * First element which does not have "xml:lang" attribute
	 * is default one. So hunt that one :)
	 *
	 * Btw. TinyXML does not handle XML namespaces and will return
	 * "<namespace>:<attribute>" value. This is not big deal as long
	 * as correctly fetch attribute values.
	 */
	for(el = el->FirstChildElement(); el; el = el->NextSibling()) {
		if(strncmp(el->Value(), "comment", 7) == 0) {
			// TODO: add locale here
			if(!el->ToElement()->Attribute("xml:lang")) {
				TiXmlText* data = el->FirstChild()->ToText();
				if(data) {
					mcmt = data->Value();
					break;
				}
			}
		}
	}

	status |= COMMENT_LOADED;
	return mcmt;
}
Esempio n. 7
0
	TiXmlElement* TiXmlFindElement(TiXmlDocument* doc, const xdl_char* elements) {
		std::vector<std::string> tokens;
		size_t number = xstd::tokenize(elements, tokens, "/");
		TiXmlNode* child = doc;
		size_t count = 0;
		while(count < number) {
			child = child->FirstChild(tokens[count].c_str());
			count++;;
		}
		if(child != NULL)
			return child->ToElement();

		return NULL;
	}
void TiXmlDocument::StreamOut( TIXML_OSTREAM * out ) const
{
	TiXmlNode* node;
	for ( node=FirstChild(); node; node=node->NextSibling() )
	{
		node->StreamOut( out );

		// Special rule for streams: stop after the root element.
		// The stream in code will only read one element, so don't
		// write more than one.
		if ( node->ToElement() )
			break;
	}
}
Esempio n. 9
0
/** Treat all countries of a single language
  *
  */
void RainbruRPG::Options::xmlLanguage::
treatLanguageCountries(TiXmlElement* e, const LanguageListItem& it){
  TiXmlNode* childNode = e->FirstChild( "Country" );
  if (childNode){
    TiXmlElement* child= childNode->ToElement();
    for( child; child; child=child->NextSiblingElement() ){
      treatCountry(child, it);
    }

  }
  else{
    LOGW(_("Empty country list found"));
  }
}
Esempio n. 10
0
const char* CXmlSiblingElemIter::Get(const char* szElemName)const
{
	const char* szText=NULL;

	if (m_pCurNode)
	{
		TiXmlNode* pNode = m_pCurNode->FirstChildElement( szElemName );
		if (pNode)
		{
			szText = pNode->ToElement()->GetText();
		}
	}
	return szText;
}
Esempio n. 11
0
int CXGseScd::FindLNType(TiXmlNode *pLN0Node, const std::string &prefix, const std::string &ln_class, const std::string &ln_inst, const std::string &do_name, std::string &ds_desc, std::string &ln_type)
{
    TiXmlNode *pXmlLNNode = pLN0Node->NextSibling("LN");
    TiXmlElement *pLNElement = NULL;
    while (pXmlLNNode != NULL)
    {
        pLNElement = pXmlLNNode->ToElement();
        if ((ln_class == pLNElement->Attribute("lnClass"))
            && (ln_inst == pLNElement->Attribute("inst"))
            && ((prefix == "")
            || (prefix == pLNElement->Attribute("prefix"))))
        {
            ln_type = pLNElement->Attribute("lnType");
            TiXmlNode *pDONode = pXmlLNNode->FirstChild("DOI");
            while (pDONode != NULL)
            {
                if (pDONode->ToElement()->Attribute("name") == do_name)
                {
                    TiXmlNode *pDANode = pDONode->FirstChild("DAI");
                    while (pDANode != NULL)
                    {
                        if (pDANode->ToElement()->Attribute("name") == std::string("dU"))
                        {
                            ds_desc = pDANode->FirstChildElement("Val")->GetText();
                            break;
                        }
                        pDANode = pDANode->NextSibling();
                    }
                    return J_OK;
                }
                pDONode = pDONode->NextSibling();
            }
        }
        pXmlLNNode = pXmlLNNode->NextSibling("LN");
    }
    return J_NOT_FOUND;
}
Esempio n. 12
0
void GameIntro::save_game(std::string & filename){
	// vytvorit dokument
	TiXmlDocument doc;
	doc.InsertEndChild(TiXmlDeclaration("1.0", "UTF-8", "yes"));
	// element game
	TiXmlNode *node;
	TiXmlElement *el, *rootEl;
	node = doc.InsertEndChild(TiXmlElement("game"));
	if(!node)
		TiXmlError("can't create root element");
	rootEl = node->ToElement();
	rootEl->SetAttribute("episode", cur_episode_);
	rootEl->SetAttribute("level", cur_level_);
	// elementy hracu
	std::string el_name;
	PlayerProperties prop;
	for(Uint16 i = 0 ; i < players_count_ ; ++i){
		el_name = "player"+x2string(i);
		node = rootEl->InsertEndChild(TiXmlElement(el_name.c_str()));
		if(!node)
			TiXmlError("can't create element "+el_name);
		el = node->ToElement();
		// atributy
		gameBase_->get_player(i, prop);
		el->SetAttribute("lives", prop.lives);
		el->SetAttribute("flames", prop.flames);
		el->SetAttribute("bombs", prop.bombs);
		el->SetAttribute("boots", prop.boots);
	}
	// ulozit do souboru
	try {
		TiXmlSaveDocument(doc, filename);
	}
	catch(const std::string & err){
		TiXmlError(filename, err);
	}
}
void BulletMLParserTinyXML::parseImpl(TiXmlDocument& doc) {
	if (doc.Error()) {
#ifdef __EXCEPTIONS
		throw BulletMLError(doc.Value() + ": " + doc.ErrorDesc());
#endif
	}

    TiXmlNode* node;
    for (node = doc.FirstChild(); node; node = node->NextSibling()) {
		if (node->ToElement() != 0) {
			getTree(node);
			break;
		}
    }
}
Esempio n. 14
0
void Config::loadConfig(String configNamespace, String fileName) {
	TiXmlDocument doc(fileName.c_str());
	
	Logger::log("Loading config: %s\n", fileName.c_str());
	
	if(!doc.LoadFile()) {
		Logger::log("Error loading config file...\n");
		Logger::log("Error: %s\n", doc.ErrorDesc());
		return;
	}
	
	TiXmlElement *rootElement = doc.RootElement();
	
	TiXmlNode *pChild;
	ConfigEntry *entry;
	for(pChild = rootElement->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) {
		entry = getEntry(configNamespace, pChild->Value());
		entry->stringVal = pChild->ToElement()->GetText();		
		entry->numVal = atof(pChild->ToElement()->GetText());
		entry->isString = true;
		entry->configNamespace = configNamespace;
	}
	
}
Esempio n. 15
0
/*
	функция считывает  прямоугольники из файла out_r.xml 
	в массив g_rects
*/
void LoadRects(int w, int h)
{
   TiXmlDocument doc("out_r.xml");
   if (!doc.LoadFile())
    return;	

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

   pElem = hDoc.FirstChildElement().Element();
   if (pElem == NULL)
	   return;
   if (strcmp(pElem->Value(), "Rects") != 0)
	   return;
   int count = 0;
   double v = 0;
   for (TiXmlNode* child = pElem->FirstChild(); child; child = child->NextSibling())
   {
	   if (strcmp(child->Value(), "rect") != 0)
		   continue;
	   child->ToElement()->QueryDoubleAttribute("x",&v);
	   g_rects[count].x = (int)(w*v/100.);
	   child->ToElement()->QueryDoubleAttribute("y",&v);
	   g_rects[count].y = (int)(h*v/100.);
	   child->ToElement()->QueryDoubleAttribute("w",&v);
	   g_rects[count].width = (int)(w*v/100.);
	   child->ToElement()->QueryDoubleAttribute("h",&v);
	   g_rects[count].height = (int)(h*v/100.);
	   count++;
	   if (count > C_MAX_OBJECTS)
		   break;
   }
   g_rects_count = count;
   MakeMaskImage(g_mask);
}
Esempio n. 16
0
  Geometry::GeometryList geometries()
  {
    if (geometries_.empty())
    {
      TiXmlElement* element = doc_.RootElement()->FirstChild("library_geometries")->ToElement();

      for(TiXmlNode* child = element->FirstChild(); child != 0; child = child->NextSibling())
      {
        Geometry geometry(child->ToElement());
        geometries_.push_back(geometry);
      }
    }
    
    return geometries_;
  }
Esempio n. 17
0
/** Get the description of the server from the xml file
  *
  * \return The server description
  *
  */
const char* RainbruRPG::Server::xmlServerConf::getServerDesc(){
  TiXmlNode* childNode = root->FirstChild( "Description" );
  if (childNode){
    TiXmlElement* lu= childNode->ToElement();
    if (lu){
      return lu->GetText();
    }
    else{
      return "";
    }
  }
  else{
    return "";
  }
}
Esempio n. 18
0
void StaticObject::Deserialize(TiXmlElement* root)
{
    World* world = World::GetPtr();
    TiXmlNode* node = NULL;
    TiXmlElement* cmeta = NULL;
    TiXmlElement* components = NULL;
    IComponentMeta* com = NULL;
    std::string cname;

    _short = root->Attribute("short");
    _plural = root->Attribute("plural");
    node = root->FirstChild("components");
    if (node)
        {
            components = node->ToElement();
            for (node = components->FirstChild(); node; node = node->NextSibling())
                {
                    cmeta = node->ToElement();
                    cname = cmeta->Attribute("name");
                    com = world->GetComponentFactory()->GetMeta(cname);
                    com->Deserialize(cmeta);
                }
        }
}
Esempio n. 19
0
/** A generic function to get the value of a server's option
  *
  * \param opt The option's name you want
  *
  * \return The option value
  *
  */
const char* RainbruRPG::Server::xmlServerConf::getOption(const char* opt){
  TiXmlNode* childNode = root->FirstChild( "Options" );
  if (childNode){
    TiXmlElement* lu= childNode->ToElement();
    if (lu){
      return lu->Attribute(opt);
    }
    else{
      return "";
    }
  }
  else{
    return "";
  }
}
Esempio n. 20
0
BOOL CQuestSystem::Init(const char* filename)
{
	if (m_mapQuestList.size()!=0)
	{
		return FALSE;
	}

	TiXmlDocument strQuestDoc(filename);
	if( !strQuestDoc.LoadFile() )
	{
		PutDebugString("装载配置文件<QuestList.xml>出错!");
		return FALSE;
	}

	TiXmlNode *pQuestNode = NULL;
	pQuestNode = strQuestDoc.FirstChild("role");
	if( pQuestNode == NULL ) return FALSE;

	TiXmlElement* pElem = pQuestNode->ToElement();
	if( pElem ==NULL) return FALSE;

	TiXmlElement* pAttribute = pElem->FirstChildElement();
	for(; pAttribute != NULL; pAttribute = pAttribute->NextSiblingElement() )
	{
		const char* pStrAttr = pAttribute->Value();
		if( !strcmp(pStrAttr,"Attribute"))
			InitAttribute(pAttribute);

		else if( !strcmp(pStrAttr,"RoleName") )
		{
			int iID = 0;
			int iTextType = 0;
			int iTitleTextID = 0;

			pAttribute->Attribute("ID",&iID);
			pAttribute->Attribute("TextTypeID",&iTextType);
			pAttribute->Attribute("TitleTextID",&iTitleTextID);

			tagQuestList QuestList;
			QuestList.lTextType = iTextType;
			QuestList.lTitleTextID = iTitleTextID;

			InitOneFile(pAttribute->GetText(),QuestList);
			m_mapQuestList[iID] = QuestList;
		}
	}
	return TRUE;
}
Esempio n. 21
0
bool ETHParticleSystem::ReadFromXMLFile(TiXmlElement *pElement)
{
	pElement->QueryIntAttribute(GS_L("particles"), &nParticles);

	allAtOnce = ETHEntityProperties::ReadBooleanPropertyFromXmlElement(pElement, GS_L("allAtOnce"), allAtOnce);

	pElement->QueryIntAttribute(GS_L("alphaMode"), (int*)&alphaMode);
	pElement->QueryIntAttribute(GS_L("repeat"), &repeat);
	pElement->QueryFloatAttribute(GS_L("boundingSphere"), &boundingSphere);
	pElement->QueryFloatAttribute(GS_L("lifeTime"), &lifeTime);
	pElement->QueryFloatAttribute(GS_L("randomLifeTime"), &randomizeLifeTime);
	pElement->QueryFloatAttribute(GS_L("angleDir"), &angleDir);
	pElement->QueryFloatAttribute(GS_L("randAngle"), &randAngle);
	pElement->QueryFloatAttribute(GS_L("size"), &size);
	pElement->QueryFloatAttribute(GS_L("randomizeSize"), &randomizeSize);
	pElement->QueryFloatAttribute(GS_L("growth"), &growth);
	pElement->QueryFloatAttribute(GS_L("minSize"), &minSize);
	pElement->QueryFloatAttribute(GS_L("maxSize"), &maxSize);
	pElement->QueryFloatAttribute(GS_L("angleStart"), &angleStart);
	pElement->QueryFloatAttribute(GS_L("randAngleStart"), &randAngleStart);
	pElement->QueryIntAttribute(GS_L("animationMode"), &animationMode);

	TiXmlNode *pNode;
	TiXmlElement *pStringElement;

	pNode = pElement->FirstChild(GS_L("Bitmap"));
	if (pNode)
	{
		pStringElement = pNode->ToElement();
		if (pStringElement)
		{
			bitmapFile = pStringElement->GetText();
		}
	}

	ETHEntityProperties::ReadVector2PropertyFromXmlElement(pElement, GS_L("Gravity"), gravityVector);
	ETHEntityProperties::ReadVector2PropertyFromXmlElement(pElement, GS_L("Direction"), directionVector);
	ETHEntityProperties::ReadVector2PropertyFromXmlElement(pElement, GS_L("RandomizeDir"), randomizeDir);
	ETHEntityProperties::ReadVector2PropertyFromXmlElement(pElement, GS_L("RandStartPoint"), randStartPoint);
	ETHEntityProperties::ReadVector2iPropertyFromXmlElement(pElement, GS_L("SpriteCut"), spriteCut);

	ETHEntityProperties::ReadVector3PropertyFromXmlElement(pElement, GS_L("StartPoint"), startPoint);

	ETHEntityProperties::ReadColorPropertyFromXmlElement(pElement, GS_L("Color0"), color0);
	ETHEntityProperties::ReadColorPropertyFromXmlElement(pElement, GS_L("Color1"), color1);
	ETHEntityProperties::ReadColorPropertyFromXmlElement(pElement, GS_L("Luminance"), emissive);
	return true;
}
Esempio n. 22
0
int CFieldDataXML::DeleteField(CString strFieldID)
{
	if (!m_bInit)
	{
		if (!myDocument.LoadFile(m_strXML.GetBuffer()))
		{
			return ERROR_OPEN_FILE;
		}
		m_bInit = TRUE;
	}

	//获得根元素
	TiXmlElement *RootElement = myDocument.RootElement();
	//获得第一个field节点。
	TiXmlElement *field = RootElement->FirstChildElement();

	int i=0;
	while(field)
	{
		CString strIDFind = field->Attribute("id");
		if (strIDFind == strFieldID)
		{
			//找到了
			break;
		}

		field = field->NextSiblingElement("field");
	} 
	if (field)
	{
		//找到了
		TiXmlNode *pParNode =  field->Parent();
		if (NULL == pParNode)
		{
			return ERROR_UNKNOW_ERROR;
		}

		TiXmlElement* pParentEle = pParNode->ToElement();
		if (NULL != pParentEle)
		{
			if(pParentEle->RemoveChild(field))
			{
				myDocument.SaveFile();
			}
		}
	}
	return ERROR_OK;
}
Esempio n. 23
0
 void GetCDLTransforms(CDLTransformMap & transformMap,
                       CDLTransformVec & transformVec,
                       TiXmlElement * cccRootElement)
 {
     if(!cccRootElement)
     {
         std::ostringstream os;
         os << "GetCDLTransforms Error. ";
         os << "Null cccRootElement.";
         throw Exception(os.str().c_str());
     }
         
     if(std::string(cccRootElement->Value()) != "ColorCorrectionCollection")
     {
         std::ostringstream os;
         os << "GetCDLTransforms Error. ";
         os << "Root element is type '" << cccRootElement->Value() << "', ";
         os << "ColorCorrectionCollection expected.";
         throw Exception(os.str().c_str());
     }
     
     TiXmlNode * child = cccRootElement->FirstChild("ColorCorrection");
     while(child)
     {
         CDLTransformRcPtr transform = CDLTransform::Create();
         LoadCDL(transform.get(), child->ToElement());
         
         transformVec.push_back(transform);
         
         std::string id = transform->getID();
         if(!id.empty())
         {
             CDLTransformMap::iterator iter = transformMap.find(id);
             if(iter != transformMap.end())
             {
                 std::ostringstream os;
                 os << "Error loading ccc xml. ";
                 os << "Duplicate elements with '" << id << "' found. ";
                 os << "If id is specified, it must be unique.";
                 throw Exception(os.str().c_str());
             }
             
             transformMap[id] = transform;
         }
         
         child = child->NextSibling("ColorCorrection");
     }
 }
void ETHEntityProperties::ReadVector2iPropertyFromXmlElement(
	TiXmlElement *pElement,
	const str_type::string& name,
	Vector2i& value)
{
	TiXmlNode *pNode = pElement->FirstChild(name);
	if (pNode)
	{
		TiXmlElement *pIter = pNode->ToElement();
		if (pIter)
		{
			pIter->QueryIntAttribute(GS_L("x"), &value.x);
			pIter->QueryIntAttribute(GS_L("y"), &value.y);
		}
	}
}
Esempio n. 25
0
/** Get a database attribute
  *
  * \param attrb The attribute name
  *
  * \return The value of the attribute
  *
  */
const char* RainbruRPG::Server::xmlServerConf::
getDbValue(const char* attrb)const{
  TiXmlNode* childNode = root->FirstChild( "Database" );
  if (childNode){
    TiXmlElement* lu= childNode->ToElement();
    if (lu){
      return lu->Attribute(attrb);
    }
    else{
      return "";
    }
  }
  else{
    return "";
  }
}
Esempio n. 26
0
bool CUnitManager::VLoad( TiXmlElement* pXMLData )
{
	TiXmlNode* pXMLUnit = 0;
	CUnit* pUnit;
	bool bLoadOK;
	while( (pXMLUnit = pXMLData->IterateChildren( pXMLUnit ))!= NULL ) {
		pUnit = new CUnit;
		bLoadOK = pUnit->VLoad( pXMLUnit->ToElement() );
		if ( bLoadOK == false ) {
			return false;
		}
		AddUnit( pUnit );
	}

	return true;
}
Esempio n. 27
0
bool Parameter::Write2XML(TiXmlNode& root)
{
	TiXmlElement *elem=NULL;
	if (Type==Const)
	{
		elem = new TiXmlElement("Parameter");
		elem->SetAttribute("Type","Const");
	}
	else elem = root.ToElement();
	if (elem==NULL) return false;
	elem->SetAttribute("name",sName.c_str());
	elem->SetAttribute("Sweep",bSweep);
	elem->SetDoubleAttribute("value",dValue);
	if (Type==Const) root.LinkEndChild(elem);
	return true;
}
Esempio n. 28
0
bool
XMLReader::setToParent() noexcept
{
	assert(_currentNode);

	TiXmlNode* parent = _currentNode->Parent();
	if (parent)
	{
		this->_currentNode = parent->ToElement();
		return true;
	}
	else
	{
		return false;
	}
}
Esempio n. 29
0
bool CSPropLumpedElement::Write2XML(TiXmlNode& root, bool parameterised, bool sparse)
{
	if (CSProperties::Write2XML(root,parameterised,sparse)==false) return false;

	TiXmlElement* prop=root.ToElement();
	if (prop==NULL) return false;

	prop->SetAttribute("Direction",m_ny);
	prop->SetAttribute("Caps",(int)m_Caps);

	WriteTerm(m_R,*prop,"R",parameterised);
	WriteTerm(m_C,*prop,"C",parameterised);
	WriteTerm(m_L,*prop,"L",parameterised);

	return true;
}
Esempio n. 30
0
bool CIRTranslator::LoadIRMap(const std::string &irMapPath)
{
  std::string remoteMapTag;
#ifdef TARGET_POSIX
  remoteMapTag = "lircmap";
#else
  remoteMapTag = "irssmap";
#endif

  // Load our xml file, and fill up our mapping tables
  CXBMCTinyXML xmlDoc;

  // Load the config file
  CLog::Log(LOGINFO, "Loading %s", irMapPath.c_str());
  if (!xmlDoc.LoadFile(irMapPath))
  {
    CLog::Log(LOGERROR, "%s, Line %d\n%s", irMapPath.c_str(), xmlDoc.ErrorRow(), xmlDoc.ErrorDesc());
    return false;
  }

  TiXmlElement* pRoot = xmlDoc.RootElement();
  std::string strValue = pRoot->Value();
  if (strValue != remoteMapTag)
  {
    CLog::Log(LOGERROR, "%s Doesn't contain <%s>", irMapPath.c_str(), remoteMapTag.c_str());
    return false;
  }

  // Run through our window groups
  TiXmlNode* pRemote = pRoot->FirstChild();
  while (pRemote != nullptr)
  {
    if (pRemote->Type() == TiXmlNode::TINYXML_ELEMENT)
    {
      const char *szRemote = pRemote->Value();
      if (szRemote != nullptr)
      {
        TiXmlAttribute* pAttr = pRemote->ToElement()->FirstAttribute();
        if (pAttr != nullptr)
          MapRemote(pRemote, pAttr->Value());
      }
    }
    pRemote = pRemote->NextSibling();
  }

  return true;
}