Example #1
0
		void CConfig::CParamItem::load(CXMLElement* pXML)
		{
			CXMLElement* pSub = pXML;
			tstring sRight = m_sName;
			tstring sLeft;
			firtex::string_utils::trim(sRight);			
			tstring::size_type npos = (size_t)-1;	
			tstring::size_type idx;

			while(sRight != "")
			{
				idx = sRight.find('.');
				if(idx ==  npos)
				{
					sLeft = sRight;
					sRight = _T("");
				}
				else 
				{
					sLeft = sRight.substr(0,idx);
					sRight = sRight.substr(idx + 1);
				}

				pSub = pSub->getElementByName(sLeft.c_str());
				if(pSub == NULL)
					return;		
			}
			tstring sType = pSub->getAttributeValue(_T("type"),_T(""));

			if ( !_tcsicmp(sType.c_str(),_T("int32")) )
			{
				_stscanf( pSub->getValue().c_str(),_T("%u"), m_pInt32 );		
			}
			else if ( !_tcsicmp(sType.c_str(),_T("int64")) )
			{
				_stscanf( pSub->getValue().c_str(),_T("%u"), m_pInt64 );		
			}
			else if ( !_tcsicmp(sType.c_str(), _T("float")) )
			{
				_stscanf( pSub->getValue().c_str(),_T("%lf"), m_pFloat );		
			}
			else if ( !_tcsicmp(sType.c_str(), _T("string")) )
			{
				*m_pString = pSub->getValue();		
			}
		}