本文整理汇总了C++中TiXmlAttribute::Name方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlAttribute::Name方法的具体用法?C++ TiXmlAttribute::Name怎么用?C++ TiXmlAttribute::Name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TiXmlAttribute
的用法示例。
在下文中一共展示了TiXmlAttribute::Name方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateResolutionData
/**
createResolutionData
Create Android resolution file as follow imported resolution file
*/
int CreateResolutionData(RESOLUTION* resolutionResult, int index, TiXmlElement* pSubElement, char* directory) {
/** Get node */
TiXmlHandle hRoot(0);
TiXmlElement* pElement = pSubElement;
TiXmlAttribute* pAttribute = NULL;
/** Set current dept node to root node */
hRoot = TiXmlHandle(pElement);
/** Check has child root */
pElement = hRoot.FirstChildElement().Element();
/** Set xml properties and root node for save file */
TiXmlDocument docArray[RESOLUTION_TYPE_COUNT];
TiXmlDeclaration* dec[RESOLUTION_TYPE_COUNT] = { ENCODING, ENCODING, ENCODING, ENCODING };
for (int i = 0; i < RESOLUTION_TYPE_COUNT; i++) {
docArray[i].LinkEndChild(dec[i]);
}
/** Add root node */
TiXmlElement* pRoot[RESOLUTION_TYPE_COUNT] = { FIRST_NODE, FIRST_NODE, FIRST_NODE, FIRST_NODE };
for (int i = 0; i < RESOLUTION_TYPE_COUNT; i++) {
docArray[i].LinkEndChild(pRoot[i]);
}
/** Add child node */
TiXmlElement* pElementArray[RESOLUTION_TYPE_COUNT];
/** If has child */
if (pElement) {
char* pszNode = NULL; /** For save node */
char* pszAttributeValue = NULL; /** For save attribute's name (key) */
char* pszAttributeName = NULL; /** for save attribute's name (value) */
/** Repeat if has child node */
while (pElement) {
/** Get node */
pszNode = (char*)pElement->Value();
/** Get attribute */
pAttribute = pElement->FirstAttribute();
/** If has attribute */
while (pAttribute) {
pszAttributeValue = (char*)pAttribute->Name();
pszAttributeName = (char*)pAttribute->Value();
pAttribute = pAttribute->Next();
}
/** Get resoultion unit info */
char* pszText = (char*)pElement->GetText();
/** Calculete resolution size */
struct RESOLUTION result;
result = ConvertResolution(pszAttributeName, strtod(pszText, NULL), RESOLUTION_HDPI); //It's HDPI type unconditionally in prototype
resolutionResult[index++] = result;
double resolution_value[RESOLUTION_TYPE_COUNT] = { result.ldpi, result.mdpi, result.hdpi, result.xhdpi };
char temp[100];
for (int i = 0; i < RESOLUTION_TYPE_COUNT; i++) {
/** For create new resolution file */
sprintf_s(temp, sizeof(temp), "%.2lfdp", resolution_value[i]);
pElementArray[i] = new TiXmlElement("dimen");
pElementArray[i]->LinkEndChild(new TiXmlText(temp));
pRoot[i]->LinkEndChild(pElementArray[i]);
pElementArray[i]->SetAttribute("name", pszAttributeName);
}
/** Call self recursively for search child node of current node */
CreateResolutionData(resolutionResult, index, pElement, NULL);
pElement = pElement->NextSiblingElement();
}
}
/** Save file */
if (directory != NULL) {
char savepath[RESOLUTION_TYPE_COUNT][100] = { "_ldpi.xml", "_mdpi.xml", "_hdpi.xml", "_xhdpi.xml" };
for (int i = 0; i < RESOLUTION_TYPE_COUNT; i++) {
char filepath[100] = "";
strncpy_s(filepath, directory, sizeof(filepath));
strcat_s(filepath, sizeof(filepath), savepath[i]);
docArray[i].SaveFile(filepath);
}
AfxMessageBox(_T("Save successfully!"));
}
return index;
}
示例2: ParseResultListXml
bool CGetResultListBG::ParseResultListXml(const CStdString& strHtml, CFileItemList& items)
{
TiXmlDocument xmlDoc;
xmlDoc.Parse(strHtml);
TiXmlElement *pRootElement = xmlDoc.RootElement();
if (!pRootElement)
return false;
if (strcmpi(pRootElement->Value(), "search") != 0)
{
CLog::Log(LOGERROR, "CGetResultListBG::ParseResultListXml, could not parse manual resolution results (manual)");
return false;
}
const TiXmlNode* pTag = 0;
while ((pTag = pRootElement->IterateChildren(pTag)))
{
if (pTag->ValueStr() == "title")
{
const TiXmlNode *pValue = pTag->FirstChild();
CStdString strValue = pValue->ValueStr();
// Find the id attribute, we do not know its name but we know that there are two attributes and it's not the one called 'year'
CStdString idAttributeName;
CStdString idAttributeValue;
TiXmlAttribute* attribute = ((TiXmlElement*)pTag)->FirstAttribute();
while (attribute)
{
if ((strcmpi(attribute->Name(), "year") != 0) && (strcmpi(attribute->Name(), "type") != 0))
{
idAttributeName = attribute->Name();
idAttributeValue = attribute->Value();
}
attribute = attribute->Next();
}
if (idAttributeName.IsEmpty() || idAttributeValue.IsEmpty())
{
// this should not happen, each search result should have an id
CLog::Log(LOGERROR, "CGetResultListBG::ParseResultListXml, search result without id, value = %s (manual)", strValue.c_str());
continue;
}
// Get the year
CStdString strYear = ((TiXmlElement*)pTag)->Attribute("year");
CStdString strType = ((TiXmlElement*)pTag)->Attribute("type");
bool bIsMovie = false;
if (strType == "movie")
{
bIsMovie = true;
}
else if (strType == "tv")
{
bIsMovie = false;
}
else
{
CLog::Log(LOGERROR, "CGetResultListBG::ParseResultListXml, invalid type = %s (manual)", strType.c_str());
continue;
}
CStdString strMovieTypeLabel = "Movie";
CStdString strTvTypeLabel = "TV";
// Format label and create file item
CStdString strLabel;
if (strYear.IsEmpty())
strLabel.Format("%s (%s)", strValue.c_str(), bIsMovie ? strMovieTypeLabel.c_str() : strTvTypeLabel.c_str());
else
strLabel.Format("%s (%s) (%s)", strValue.c_str(), strYear.c_str(), bIsMovie ? strMovieTypeLabel.c_str() : strTvTypeLabel.c_str());
CFileItemPtr resultItem (new CFileItem(strLabel));
resultItem->SetProperty("type", "msearch");
resultItem->SetProperty("manualresolve::Title", strValue);
resultItem->SetProperty("manualresolve::Year", strYear);
resultItem->SetProperty("manualresolve::idName", idAttributeName);
resultItem->SetProperty("manualresolve::idValue", idAttributeValue);
resultItem->SetProperty("manualresolve::isMovie", bIsMovie);
items.Add(resultItem);
CLog::Log(LOGDEBUG, "CGetResultListBG::ParseResultListXml, added item, title = %s, type = %s, year = %s, idName = %s, idValue = %s (manual)",
strValue.c_str(), bIsMovie ? "movie" : "tv", strYear.c_str(), idAttributeName.c_str(), idAttributeValue.c_str());
}
}
return items.Size() > 0;
}
示例3: Parse
const char* TiXmlElement::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding )
{
p = SkipWhiteSpace( p, encoding );
TiXmlDocument* document = GetDocument();
if ( !p || !*p )
{
if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, 0, 0, encoding );
return 0;
}
// TiXmlParsingData data( p, prevData );
if ( data )
{
data->Stamp( p, encoding );
location = data->Cursor();
}
if ( *p != '<' )
{
if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT, p, data, encoding );
return 0;
}
p = SkipWhiteSpace( p+1, encoding );
// Read the name.
const char* pErr = p;
p = ReadName( p, &value, encoding );
if ( !p || !*p )
{
if ( document ) document->SetError( TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, pErr, data, encoding );
return 0;
}
TIXML_STRING endTag ("</");
endTag += value;
endTag += ">";
// Check for and read attributes. Also look for an empty
// tag or an end tag.
while ( p && *p )
{
pErr = p;
p = SkipWhiteSpace( p, encoding );
if ( !p || !*p )
{
if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding );
return 0;
}
if ( *p == '/' )
{
++p;
// Empty tag.
if ( *p != '>' )
{
if ( document ) document->SetError( TIXML_ERROR_PARSING_EMPTY, p, data, encoding );
return 0;
}
return (p+1);
}
else if ( *p == '>' )
{
// Done with attributes (if there were any.)
// Read the value -- which can include other
// elements -- read the end tag, and return.
++p;
p = ReadValue( p, data, encoding ); // Note this is an Element method, and will set the error if one happens.
if ( !p || !*p ) {
// We were looking for the end tag, but found nothing.
// Fix for [ 1663758 ] Failure to report error on bad XML
if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
return 0;
}
// We should find the end tag now
if ( StringEqual( p, endTag.c_str(), false, encoding ) )
{
p += endTag.length();
return p;
}
else
{
if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG, p, data, encoding );
return 0;
}
}
else
{
// Try to read an attribute:
TiXmlAttribute* attrib = new TiXmlAttribute();
if ( !attrib )
{
if ( document ) document->SetError( TIXML_ERROR_OUT_OF_MEMORY, pErr, data, encoding );
return 0;
}
attrib->SetDocument( document );
const char* pErr = p;
//.........这里部分代码省略.........
示例4: ReadXML
bool CGmObjShapeStaticItem::ReadXML( TiXmlNode* poParent, unsigned int uiCounter )
{
if( !poParent )
return false;
static char acTxt_[256];
if( uiCounter == 0 )
{
}
switch ( poParent->Type() )
{
case TiXmlNode::DOCUMENT:
LOG( "XML: Document" );
break;
case TiXmlNode::ELEMENT:
{
const char *pcName = poParent->Value();
//LOG( "name: %s\n", pcName );
if( !strcmp( pcName, "item" ) )
{
LOG( "item:\n" );
TiXmlElement * poElement = poParent->ToElement();
if( poElement )
{
TiXmlAttribute* poAttrib = poElement->FirstAttribute();
while( poAttrib )
{
const char *pcName = poAttrib->Name();
if( !strcmp( pcName, "name" ) )
{
STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() );
LOG( "%s: %s\n", poAttrib->Name(), acTxt_ );
m_oName = acTxt_;
}
if( !strcmp( pcName, "type" ) )
{
STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() );
LOG( "%s: %s\n", poAttrib->Name(), acTxt_ );
if( !strcmp( acTxt_, "weapon" ) )
m_eType = TYPE_WEAPON;
else if( !strcmp( acTxt_, "energy" ) )
m_eType = TYPE_ENERGY;
else if( !strcmp( acTxt_, "ammo" ) )
m_eType = TYPE_AMMO;
else if( !strcmp( acTxt_, "key" ) )
m_eType = TYPE_KEY;
else
m_eType = TYPE_UNDEFINED;
}
if( !strcmp( pcName, "cycle_duration" ) )
{
double dVal;
if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS )
{
LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) );
if( dVal >= 0.0 )
m_iTickDurCycle = int( dVal / m_dTInteractionInterval_ );
else
m_iTickDurCycle = -1;
}
}
if( !strcmp( pcName, "rotation_y_speed" ) )
{
double dVal;
if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS )
{
LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) );
m_fRotationYSpeed = float( dVal * 360.0 );
}
}
if( !strcmp( pcName, "weapon_name" )
&& ( m_eType == TYPE_WEAPON || m_eType == TYPE_AMMO ) )
{
STRING_COPY( acTxt_, sizeof(acTxt_), poAttrib->Value() );
LOG( "%s: %s\n", poAttrib->Name(), acTxt_ );
m_oWeaponName = acTxt_;
}
if( !strcmp( pcName, "energy" ) && m_eType == TYPE_ENERGY )
{
double dVal;
if( poAttrib->QueryDoubleValue( &dVal ) == TIXML_SUCCESS )
{
LOG( "%s: %f\n", poAttrib->Name(), float( dVal ) );
m_fEnergy = float( dVal );
}
}
if( !strcmp( pcName, "ammo" )
&& ( m_eType == TYPE_WEAPON || m_eType == TYPE_AMMO ) )
{
int iVal;
if( poAttrib->QueryIntValue( &iVal ) == TIXML_SUCCESS
&& iVal > 0 )
{
LOG( "%s: %d\n", poAttrib->Name(), iVal );
m_uiAmmo = iVal;
}
}
if( !strcmp( pcName, "key" ) && m_eType == TYPE_ENERGY )
//.........这里部分代码省略.........
示例5: ParseRouter
void HoOrionModelParser::ParseRouter(TiXmlNode* pParent) {
double TmpDouble;
int TmpInt;
string Type;
stringstream Energy;
stringstream Area;
int MaxIn = 0;
int MaxOut = 0;
TiXmlAttribute* Attribute = ( pParent->ToElement())->FirstAttribute() ;
while (Attribute ) {
if (string(Attribute->Name() ) == "type") {
Type = string(Attribute->Value() ) ;
} else if (string(Attribute->Name() ) == "maxin") {
Attribute->QueryIntValue(&TmpInt) ;
MaxIn = TmpInt ;
} else if (string(Attribute->Name() ) == "maxout") {
Attribute->QueryIntValue(&TmpInt) ;
MaxOut = TmpInt ;
} else if (string(Attribute->Name() ) == "maxbw") {
Attribute->QueryDoubleValue(&TmpDouble) ;
//mModel->RouterMaxBw = TmpDouble ;
} else if (string(Attribute->Name() ) == "energy") {
Energy << Attribute->ValueStr() ;
} else if (string(Attribute->Name() ) == "area") {
Area << Attribute->ValueStr() ;
} else {
cout << "Unknown attribute "<< Attribute->Name() << " for wire"
<< endl ;
}
Attribute = Attribute->Next() ;
}
mMaxIn = MaxIn ;
mMaxOut = MaxOut ;
if (Type == "r1ch32") {
mArouter1ch32.resize(MaxIn + 1) ;
mErouter1ch32.resize(MaxIn + 1) ;
mErouterLeak1ch32.resize(MaxIn + 1) ;
mArouter1ch32[0].resize(MaxOut + 1) ;
mErouter1ch32[0].resize(MaxOut + 1) ;
mErouterLeak1ch32[0].resize(MaxOut + 1) ;
for (int i = 1; i <= MaxIn ; i++) {
mArouter1ch32[i].resize(MaxOut + 1) ;
mErouter1ch32[i].resize(MaxOut + 1) ;
mErouterLeak1ch32[i].resize(MaxOut + 1) ;
for (int j = 1; j <= MaxOut ; j++) {
Area >> mArouter1ch32[i][j];
mArouter1ch32[i][j] = mArouter1ch32[i][j]*1e-12;
Energy >> mErouter1ch32[i][j];
Energy >> mErouterLeak1ch32[i][j];
}
}
//handle first rows nad first column
for (int j = 0; j <= MaxOut ; j++) {
mArouter1ch32[0][j] = 0;
mErouter1ch32[0][j] = 0;
mErouterLeak1ch32[0][j] = 0;
}
for (int i = 0; i <= MaxIn ; i++) {
mArouter1ch32[i][0] = 0;
mErouter1ch32[i][0] = 0;
mErouterLeak1ch32[i][0] = 0;
}
} else if (Type == "r4ch32") {
示例6: LoadXmlDoc
int LibraryDetectionManager::LoadXmlDoc( TiXmlDocument& Doc )
{
int loaded = 0;
for ( TiXmlElement* Elem = Doc.FirstChildElement("library");
Elem;
Elem = Elem->NextSiblingElement("library") )
{
// Load the version of this set
int version = 0;
if ( Elem->QueryIntAttribute( "version", &version ) != TIXML_SUCCESS )
version = 0;
// Load shortcode
wxString ShortCode = wxString(Elem->Attribute("short_code"),wxConvUTF8);
if ( ShortCode.IsEmpty() )
continue;
// Load name
wxString Name = wxString( Elem->Attribute("name"), wxConvUTF8 );
if ( Name.IsEmpty() )
continue;
// Check if we already have setting of this library
// I'm to lazy to firbid const_cast here ;)
LibraryDetectionConfigSet* OldSet = const_cast< LibraryDetectionConfigSet* > ( GetLibrary( ShortCode ) );
LibraryDetectionConfigSet* NewSet = 0;
if ( OldSet )
{
// There are detection settings yet, we override only when there's newer
// or same version already
if ( OldSet->Version > version )
continue; // We do not upgrade
OldSet->Categories.Clear();
OldSet->Configurations.clear();
OldSet->LibraryName.Clear();
NewSet = OldSet;
}
else
{
NewSet = new LibraryDetectionConfigSet;
Libraries.Add( NewSet );
}
// Setup configuration set
NewSet->ShortCode = ShortCode;
NewSet->Version = version;
NewSet->LibraryName = Name;
// Read categories of library
for ( TiXmlAttribute* attr = Elem->FirstAttribute();
attr;
attr = attr->Next() )
{
// if ( !strncasecmp(attr->Name(),"category",8) )
if ( !strncmp(attr->Name(),"category",8) )
NewSet->Categories.Add( wxString( attr->Value(),wxConvUTF8 ) );
}
// Check if there's corresponding pkg-config entry
if ( IsPkgConfigEntry(ShortCode) )
{
LibraryDetectionConfig Config;
Config.PkgConfigVar = ShortCode;
Config.Description = NewSet->LibraryName + _T(" (pkg-config)");
LibraryDetectionFilter Filter;
Filter.Type = LibraryDetectionFilter::PkgConfig;
Filter.Value = ShortCode;
Config.Filters.push_back(Filter);
loaded += AddConfig(Config,NewSet) ? 1 : 0;
}
// Load libraries
LibraryDetectionConfig Initial;
loaded += LoadXml( Elem, Initial, NewSet );
}
return loaded;
}
示例7: ReadOneXmlItem
bool StoryDataCenter::ReadOneXmlItem(TiXmlElement* pElement)
{
if (pElement == 0)
{
return false;
}
unsigned int taskID = 0;
StroyData storyData;
// Note: Parse TaskID
TiXmlAttribute* pAttribute = pElement->FirstAttribute();
while(pAttribute)
{
std::string strName(pAttribute->Name());
std::string content = pElement->Attribute(strName.c_str());
if (strName == "task_ID")
{
unsigned int task_id = atoi(content.c_str());
taskID = task_id;
storyData.setTaskId(task_id);
}
else if (strName == "instance_ID")
{
unsigned int task_id = atoi(content.c_str());
taskID = task_id;
storyData.setTaskId(task_id);
}
else if (strName == "map_ID")
{
unsigned int map_id = atoi(content.c_str());
storyData.setMapId(map_id);
}
else if (strName == "camera")
{
float posx = 0;
float posy = 0;
if (SplitPosFromContent(content,posx,posy))
{
storyData.setCameraPos(ccp(posx,posy));
}
}
else if (strName == "end_frame")
{
int endFrame = atoi(content.c_str());
storyData.setEndFrame(endFrame);
}
else if (strName == "when")
{
int nWhen = atoi(content.c_str());
storyData.setHappendAtWhen(nWhen);
}
else if (std::string::npos != strName.find("set_role_position_"))
{
unsigned int roleIndex = 0;
if (SplitRoleID(strName,roleIndex))
{
std::vector<std::string> vecContent;
SplitContent(content,vecContent);
size_t vecSize = vecContent.size();
for (size_t index = 0;index<vecSize;index++)
{
unsigned int frameIndex = 0;
float posx = 0;
float posy = 0;
if(SplitFrameAndPosFromContent(vecContent[index],frameIndex,posx,posy))
{
storyData.InsertRolePosAtFrame(roleIndex,frameIndex,ccp(posx,posy));
}
}
}
}
else if (std::string::npos != strName.find("set_role_act_"))
{
unsigned int roleIndex = 0;
if (SplitRoleID(strName,roleIndex))
{
std::vector<std::string> vecContent;
SplitContent(content,vecContent);
size_t vecSize = vecContent.size();
for (size_t index = 0;index<vecSize;index++)
{
unsigned int frameIndex = 0;
int actorId = 0;
if (SplitFrameAndActorIdFromContent(vecContent[index],frameIndex,actorId))
{
storyData.InsertRoleActorAtFrame(roleIndex,frameIndex,actorId);
}
}
}
}
else if (std::string::npos != strName.find("role_dialog_"))
{
unsigned int roleIndex = 0;
if (SplitRoleID(strName,roleIndex))
{
std::vector<unsigned int> vecFrameIndex;
std::vector<std::string> vecTextId;
if (SplitFrameAndTextIdFromContent(content,vecFrameIndex,vecTextId))
{
//.........这里部分代码省略.........
示例8: Parse
const char* TiXmlElement::Parse( const char* p )
{
p = SkipWhiteSpace( p );
TiXmlDocument* document = GetDocument();
if ( !p || !*p || *p != '<' )
{
if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT );
return false;
}
p = SkipWhiteSpace( p+1 );
// Read the name.
p = ReadName( p, &value );
if ( !p || !*p )
{
if ( document ) document->SetError( TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME );
return false;
}
string endTag = "</";
endTag += value;
endTag += ">";
// Check for and read attributes. Also look for an empty
// tag or an end tag.
while ( p && *p )
{
p = SkipWhiteSpace( p );
if ( !p || !*p )
{
if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES );
return 0;
}
if ( *p == '/' )
{
++p;
// Empty tag.
if ( *p != '>' )
{
if ( document ) document->SetError( TIXML_ERROR_PARSING_EMPTY );
return 0;
}
return (p+1);
}
else if ( *p == '>' )
{
// Done with attributes (if there were any.)
// Read the value -- which can include other
// elements -- read the end tag, and return.
++p;
p = ReadValue( p ); // Note this is an Element method, and will set the error if one happens.
if ( !p || !*p )
return 0;
// We should find the end tag now
if ( StringEqual( p, endTag.c_str(), false ) )
{
p += endTag.length();
return p;
}
else
{
if ( document ) document->SetError( TIXML_ERROR_READING_END_TAG );
return 0;
}
}
else
{
// Try to read an element:
TiXmlAttribute attrib;
attrib.SetDocument( document );
p = attrib.Parse( p );
if ( !p || !*p )
{
if ( document ) document->SetError( TIXML_ERROR_PARSING_ELEMENT );
return 0;
}
SetAttribute( attrib.Name(), attrib.Value() );
}
}
return p;
}
示例9: Load
bool XMLControlInterface::Load(const char * filepath)
{
try
{
m_configure = new TiXmlDocument(filepath);
m_configure->LoadFile();
TiXmlElement *l_root = m_configure->RootElement();
//------------------------------------------------
TiXmlElement* l_LeftElement = NULL;
TiXmlElement* l_IndexitemElement = NULL;
SERVER_INFO_ svrinfo_;
string strTxt,strVal;
strVal=l_root->Value();
//strVal=l_root->GetText();
if(!l_root || strcmp(l_root->Value(), "I_hosts"))
return false;
/*if(const TiXmlElement *updates=l_root->FirstChildElement("address"))
{
//GetChild(updates, "ip",strTxt);
TiXmlAttribute *IDAttribute = (TiXmlAttribute *)updates->FirstAttribute();
strTxt=IDAttribute->Value();
for (TiXmlAttribute * nextID=IDAttribute->Next();nextID;)
{
strTxt=nextID->Value();
nextID=nextID->Next();
}
}*/
for( l_LeftElement = l_root->FirstChildElement();
l_LeftElement!=NULL;
l_LeftElement = l_LeftElement->NextSiblingElement() )
{
strTxt=l_LeftElement->Value();
//for( l_IndexitemElement = l_LeftElement->FirstChildElement();
//l_IndexitemElement!=NULL;
//l_IndexitemElement = l_IndexitemElement->NextSiblingElement() )
//{
TiXmlAttribute *IDAttribute = (TiXmlAttribute *)l_LeftElement->FirstAttribute();
for (;IDAttribute;IDAttribute=IDAttribute->Next())
{
strTxt=IDAttribute->Name();
if( 0 == strncmp( "ip" ,IDAttribute->Name(), 2 ) )
{
svrinfo_._ip=IDAttribute->Value();
}
else if(0 == strncmp( "port" ,IDAttribute->Name(), 4 ))
{
svrinfo_._port=IDAttribute->Value();
}
else if(0 == strncmp( "root" ,IDAttribute->Name() , 4 ))
{
svrinfo_._root =IDAttribute->Value();
}
else if(0 == strncmp( "redirect" ,IDAttribute->Name() , 8 ))
{
svrinfo_._redirect=IDAttribute->Value();
}
}
/*strTxt=nextID->Value();
nextID=nextID->Next();
strTxt=l_IndexitemElement->Value();
strVal=l_IndexitemElement->GetText();
if( 0 == strncmp( "ip" , l_IndexitemElement->Value() , 2 ) )
{
svrinfo_._ip= l_IndexitemElement->GetText();
}
else if(0 == strncmp( "port" , l_IndexitemElement->Value() , 2 ))
{
svrinfo_._port= l_IndexitemElement->GetText();
}
else if(0 == strncmp( "root" , l_IndexitemElement->Value() , 3 ))
{
svrinfo_._root =l_IndexitemElement->GetText();
}
else if(0 == strncmp( "redirect" , l_IndexitemElement->Value() , 8 ))
{
svrinfo_._redirect= l_IndexitemElement->GetText();
}*/
//}
//.........这里部分代码省略.........
示例10: ReadFromXMLElement
// static
HeeksObj* HDimension::ReadFromXMLElement(TiXmlElement* pElem)
{
double m[16];
wxString text;
HeeksColor c;
double p0[3] = {0, 0, 0};
double p1[3] = {0, 0, 0};
double p2[3] = {0, 0, 0};
double scale=1;
DimensionMode mode = TwoPointsDimensionMode;
DimensionUnits units = DimensionUnitsGlobal;
// get the attributes
for(TiXmlAttribute* a = pElem->FirstAttribute(); a; a = a->Next())
{
std::string name(a->Name());
if(name == "col"){c = HeeksColor((long)(a->IntValue()));}
else if(name == "m0"){m[0] = a->DoubleValue();}
else if(name == "m1"){m[1] = a->DoubleValue();}
else if(name == "m2"){m[2] = a->DoubleValue();}
else if(name == "m3"){m[3] = a->DoubleValue();}
else if(name == "m4"){m[4] = a->DoubleValue();}
else if(name == "m5"){m[5] = a->DoubleValue();}
else if(name == "m6"){m[6] = a->DoubleValue();}
else if(name == "m7"){m[7] = a->DoubleValue();}
else if(name == "m8"){m[8] = a->DoubleValue();}
else if(name == "m9"){m[9] = a->DoubleValue();}
else if(name == "ma"){m[10]= a->DoubleValue();}
else if(name == "mb"){m[11]= a->DoubleValue();}
else if(name == "scale"){scale= a->DoubleValue();}
else if(name == "mode"){mode = (DimensionMode)(a->IntValue());}
else if(name == "units"){
const char* str = a->Value();
switch(str[0])
{
case 'm':
units = DimensionUnitsMM;
break;
case 'i':
units = DimensionUnitsInches;
break;
}
}
}
HDimension* new_object = new HDimension(make_matrix(m), make_point(p0), make_point(p1), make_point(p2), mode, units, &c);
new_object->ReadBaseXML(pElem);
new_object->m_scale = scale;
if(new_object->GetNumChildren()>3)
{
//This is a new style line, with children points
new_object->Remove(new_object->A);
new_object->Remove(new_object->B);
new_object->Remove(new_object->m_p2);
delete new_object->A;
delete new_object->B;
delete new_object->m_p2;
new_object->A = (HPoint*)new_object->GetFirstChild();
new_object->B = (HPoint*)new_object->GetNextChild();
new_object->m_p2 = (HPoint*)new_object->GetNextChild();
new_object->A->m_draw_unselected = false;
new_object->B->m_draw_unselected = false;
new_object->m_p2->m_draw_unselected = false;
new_object->A->SetSkipForUndo(true);
new_object->B->SetSkipForUndo(true);
new_object->m_p2->SetSkipForUndo(true);
}
return new_object;
}
示例11: navigateChildren
void XMLParser::navigateChildren (int depth, XMLElement *parent, TiXmlElement *element)
{
#ifdef defAPI_TINY_XML
TiXmlElement *xeElm = element;
xeElm = xeElm->FirstChildElement ();
while (xeElm != 0)
{
XMLElement *xmlElment = new XMLElement ();
const char *cParentValue = (const char *)element->Value ();
const char *cValue = (const char *)xeElm->Value ();
const char *cContent = 0;
std::string strParentValue = "";
std::string strValue = "";
std::string strContent = "";
if (xeElm->NoChildren () == false)
{
TiXmlNode *xeChild = xeElm->FirstChild ();
if (xeChild != 0)
cContent = xeChild->Value ();
}
if (cParentValue != 0)
strParentValue = cParentValue;
if (cValue != 0)
strValue = cValue;
if (cContent != 0)
strContent = cContent;
std::vector<std::string> aryAttributeNames;
std::vector<std::string> aryAttributeValues;
TiXmlAttribute *xaAtt = xeElm->FirstAttribute ();
while (xaAtt != 0)
{
const char *cAttributeName = (const char *)xaAtt->Name ();
std::string strAttributeName = "";
const char *cAttributeValue = (const char *)xaAtt->Value ();
std::string strAttributeValue = "";
if (cAttributeName != 0)
strAttributeName = cAttributeName;
if (cAttributeValue != 0)
strAttributeValue = cAttributeValue;
aryAttributeNames.push_back (strAttributeName);
aryAttributeValues.push_back (strAttributeValue);
xaAtt = xaAtt->Next ();
}
xmlElment->parent = parent;
xmlElment->tag = strValue;
for (unsigned int iIdx = 0; iIdx < aryAttributeNames.size (); iIdx++)
xmlElment->aryAttributeNames.push_back (aryAttributeNames.at (iIdx));
for (unsigned int iIdx = 0; iIdx < aryAttributeValues.size (); iIdx++)
xmlElment->aryAttributeValues.push_back (aryAttributeValues.at (iIdx));
xmlElment->content = strContent;
xmlElment->parentParser = this;
if (parent == 0)
aryElements->push_back (xmlElment);
else
parent->children->push_back (xmlElment);
if (xeElm->NoChildren () == false)
navigateChildren (depth++, xmlElment, xeElm);
xeElm = xeElm->NextSiblingElement ();
}
#endif
}
示例12: ResolveIncludesForNode
void CGUIIncludes::ResolveIncludesForNode(TiXmlElement *node, std::map<int, bool>* xmlIncludeConditions /* = NULL */)
{
// we have a node, find any <include file="fileName">tagName</include> tags and replace
// recursively with their real includes
if (!node) return;
// First add the defaults if this is for a control
CStdString type;
if (node->ValueStr() == "control")
{
type = node->Attribute("type");
map<CStdString, TiXmlElement>::const_iterator it = m_defaults.find(type);
if (it != m_defaults.end())
{
const TiXmlElement &element = (*it).second;
const TiXmlElement *tag = element.FirstChildElement();
while (tag)
{
// we insert at the end of block
node->InsertEndChild(*tag);
tag = tag->NextSiblingElement();
}
}
}
TiXmlElement *include = node->FirstChildElement("include");
while (include && include->FirstChild())
{
// have an include tag - grab it's tag name and replace it with the real tag contents
const char *file = include->Attribute("file");
if (file)
{ // we need to load this include from the alternative file
LoadIncludes(g_SkinInfo->GetSkinPath(file));
}
const char *condition = include->Attribute("condition");
if (condition)
{ // check this condition
int conditionID = g_infoManager.Register(condition);
bool value = g_infoManager.GetBoolValue(conditionID);
if (xmlIncludeConditions)
(*xmlIncludeConditions)[conditionID] = value;
if (!value)
{
include = include->NextSiblingElement("include");
continue;
}
}
CStdString tagName = include->FirstChild()->Value();
map<CStdString, TiXmlElement>::const_iterator it = m_includes.find(tagName);
if (it != m_includes.end())
{ // found the tag(s) to include - let's replace it
const TiXmlElement &element = (*it).second;
const TiXmlElement *tag = element.FirstChildElement();
while (tag)
{
// we insert before the <include> element to keep the correct
// order (we render in the order given in the xml file)
node->InsertBeforeChild(include, *tag);
tag = tag->NextSiblingElement();
}
// remove the <include>tagName</include> element
node->RemoveChild(include);
include = node->FirstChildElement("include");
}
else
{ // invalid include
CLog::Log(LOGWARNING, "Skin has invalid include: %s", tagName.c_str());
include = include->NextSiblingElement("include");
}
}
// run through this element's attributes, resolving any constants
TiXmlAttribute *attribute = node->FirstAttribute();
while (attribute)
{ // check the attribute against our set
if (m_constantAttributes.count(attribute->Name()))
attribute->SetValue(ResolveConstant(attribute->ValueStr()));
attribute = attribute->Next();
}
// also do the value
if (node->FirstChild() && node->FirstChild()->Type() == TiXmlNode::TINYXML_TEXT && m_constantNodes.count(node->ValueStr()))
node->FirstChild()->SetValue(ResolveConstant(node->FirstChild()->ValueStr()));
}
示例13: OnProjectLoadingHook
/*!
\brief Load / save project hook.
When CodeBlocks loads and saves a file, we hook into the process here and load or save
our parameters.
\param project CodeBlocks project instance.
\param elem XML element of root node.
\param loading Flag set whether load / save, true = loading, false = saving.
*/
void OpenOCDDriver::OnProjectLoadingHook(cbProject* project, TiXmlElement* elem, bool loading)
{
if (loading) {
TiXmlElement* node = elem->FirstChildElement("gdbremote");
if (node) {
TiXmlElement *device = node->FirstChildElement("hardware");
m_Interface = cbC2U(device->Attribute("interface"));
m_Option = cbC2U(device->Attribute("option"));
m_JTAGSpeed = cbC2U(device->Attribute("jtagspeed"));
m_GDBPort = atoi(device->Attribute("gdbport"));
m_ConfigFile = cbC2U(device->Attribute("configfile"));
wxString strAuto = cbC2U(device->Attribute("auto"));
m_TelnetPort = atoi(device->Attribute("telnetport"));
m_TCLPort = atoi(device->Attribute("tclport"));
if (strAuto == _T("true"))
m_Auto = true;
else
m_Auto = false;
// Now get advanced options.
TiXmlElement *advopts = node->FirstChildElement("advintopts");
if (advopts) {
TiXmlAttribute *attr = advopts->FirstAttribute();
while (attr) {
// Populate hash map with attributes.
wxString key = cbC2U(attr->Name());
wxString value = cbC2U(attr->Value());
m_AdvOpts[key] = value;
attr = attr->Next();
}
}
} else {
m_Interface = _T("parport");
m_Option = _T("wiggler");
m_JTAGSpeed = _T("0");
m_ConfigFile = _T("openocd.cfg");
m_Auto = true;
m_TelnetPort = 4444;
m_GDBPort = 2000;
m_TCLPort = 6666;
m_AdvOpts.clear();
}
} else {
TiXmlElement* node = elem->FirstChildElement("gdbremote");
if (!node)
node = elem->InsertEndChild(TiXmlElement("gdbremote"))->ToElement();
node->Clear();
TiXmlElement *device = node->InsertEndChild(TiXmlElement("hardware"))->ToElement();
device->SetAttribute("interface", cbU2C(m_Interface));
device->SetAttribute("option", cbU2C(m_Option));
device->SetAttribute("jtagspeed", cbU2C(m_JTAGSpeed));
device->SetAttribute("gdbport", m_GDBPort);
device->SetAttribute("configfile", cbU2C(m_ConfigFile));
if (m_Auto == true)
device->SetAttribute("auto", "true");
else
device->SetAttribute("auto", "false");
device->SetAttribute("telnetport", m_TelnetPort);
device->SetAttribute("tclport", m_TCLPort);
// Write advanced options
TiXmlElement *advopts = node->InsertEndChild(TiXmlElement("advintopts"))->ToElement();
AdvOptsHash::iterator it;
for( it = m_AdvOpts.begin(); it != m_AdvOpts.end(); ++it )
{
wxString key = it->first, value = it->second;
// do something useful with key and value
advopts->SetAttribute(cbU2C(key), cbU2C(value));
}
}
}
示例14: _Decode
static int _Decode( sqbind::CSqMulti *out, TiXmlElement *in, int bIndexed, int nDepth = 0 )
{_STT();
// Sanity check
if ( !out || !in || nDepth > CSqXml::eMaxParseDepth )
return 0;
int nDecoded = 0;
int nIdx = 0;
// Add child elements
do
{
// Only element types
if ( in->Type() != TiXmlNode::TINYXML_ELEMENT )
continue;
// Apply some sane limit
int nMax = CSqXml::eMaxParseElements;
// Grab the tag name
const char *pName = in->Value();
sqbind::stdString sName;
if ( pName && *pName )
sName = oexMbToStrPtr( pName );
sqbind::CSqMulti *r = oexNULL;
if ( bIndexed )
{
// Use numeric index
r = &(*out)[ oexMks( nIdx++ ).Ptr() ];
// Save name if valid
if ( sName.length() )
(*r)[ oexT( "$" ) ].set( oexMbToStrPtr( pName ) );
} // end if
else
{
// Ensure valid name and that it exists
if ( !sName.length() || (*out).isset( sName ) )
continue;
// Use name as index
r = &(*out)[ sName ];
} // end else
if ( !r )
continue;
// First add the attributes
TiXmlAttribute *pAttrib = in->FirstAttribute();
while ( nMax-- && pAttrib )
{
// Get name and value
const char *pAtt = pAttrib->Name();
const char *pValue = pAttrib->Value();
if ( pAtt && *pAtt && pValue && *pValue )
{ sqbind::stdString sAtt = oexMbToStrPtr( pAtt );
if ( !r->isset( sAtt ) )
nDecoded++, (*r)[ sAtt ].set( oexMbToStrPtr( pValue ) );
} // end if
// Next attribute
pAttrib = pAttrib->Next();
} // end while
// Default value?
const char *pText = in->GetText();
if ( pText && *pText )
{ nDecoded++;
r->set( oexMbToStrPtr( pText ) );
} // end if
// Child elements?
if ( in->FirstChildElement() )
nDecoded += _Decode( r, in->FirstChildElement(), bIndexed, nDepth + 1 );
} while ( ( in = in->NextSiblingElement() ) );
return nDecoded;
}
示例15: searchXMLData
void searchXMLData(TiXmlElement* pElem, vector<no> &objects, string &file, string &path)
{
TiXmlHandle hRoot(0);
TiXmlElement* pSubElem = pElem;
TiXmlAttribute* pAttrib = NULL;
//Set current node to root node and determine childe node is exist or not
hRoot = TiXmlHandle(pSubElem);
pSubElem = hRoot.FirstChildElement().Element();
if (!pSubElem) return;
char* pszNode = NULL;
char* pszAttrib = NULL;
char* pszText = NULL;
while (pSubElem)
{
//node
pszNode = (char*)pSubElem->Value();
//Attribute
pAttrib = pSubElem->FirstAttribute();
no buffer;
if(!strcmp(pszNode,"rect"))buffer.nome += "rect";
else if(!strcmp(pszNode,"circle"))buffer.nome += "circle";
bool flag = false;
while (pAttrib)
{
char* pszAttrib = (char*)pAttrib->Name();
char* pszText = (char*)pAttrib->Value();
if(buffer.nome == "rect" || buffer.nome == "circle")
{
flag = true;
if(!strcmp(pszAttrib,"x") || !strcmp(pszAttrib,"cx"))
{
buffer.x = atoi(pszText);
}
else
if(!strcmp(pszAttrib,"y") || !strcmp(pszAttrib,"cy"))
{
buffer.y = atoi(pszText);
}
else
if(!strcmp(pszAttrib,"fill"))
{
buffer.fill += pszText;
}
else
if(!strcmp(pszAttrib,"id"))
{
buffer.id += pszText;
}
}
if(buffer.nome == "rect")
{
if(!strcmp(pszAttrib,"width"))
{
buffer.width = atoi(pszText);
}
else
if(!strcmp(pszAttrib,"height"))
{
buffer.height = atoi(pszText);
}
else
if(!strcmp(pszAttrib,"stroke-width"))
{
buffer.stroke_width = atoi(pszText);
}
else
if(!strcmp(pszAttrib,"stroke"))
{
buffer.stroke += pszText;
}
}
else
{
if(buffer.nome == "circle")
{
if(!strcmp(pszAttrib,"r"))buffer.r = atoi(pszText);
}
}
if(!strcmp(pszNode,"arquivoDaArena"))
{
if(!strcmp(pszAttrib,"nome"))
{
file += pszText;
}
else
{
if(!strcmp(pszAttrib,"tipo") && !file.empty())
{
file+='.';
file+=pszText;
}
else
//.........这里部分代码省略.........