当前位置: 首页>>代码示例>>C++>>正文


C++ TiXmlElement::LastAttribute方法代码示例

本文整理汇总了C++中TiXmlElement::LastAttribute方法的典型用法代码示例。如果您正苦于以下问题:C++ TiXmlElement::LastAttribute方法的具体用法?C++ TiXmlElement::LastAttribute怎么用?C++ TiXmlElement::LastAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TiXmlElement的用法示例。


在下文中一共展示了TiXmlElement::LastAttribute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: dumpXML

bool dumpXML(string& fname)
{
    try {
        TiXmlDocument* doc = new TiXmlDocument (fname.c_str());
        doc->LoadFile ();
        TiXmlElement* root = doc->RootElement ();
        
        cout << root->Value () << endl;

        TiXmlElement* version = root->FirstChildElement ();
        TiXmlAttribute* atti_major = version->FirstAttribute ();
        TiXmlAttribute* atti_minor = version->LastAttribute ();

        TiXmlElement* file = version->FirstChildElement ();
        TiXmlAttribute* atti_size = file->FirstAttribute ();
        TiXmlAttribute* atti_date = file->LastAttribute ();

        cout << version->FirstChild ()->Value() << endl;
        cout << atti_major->Name () << ": " << atti_major->Value () << ", " <<
        atti_minor->Name () << ": " << atti_minor->Value () << endl;
        cout << file->FirstChild ()->Value() << endl;
        cout << atti_size->Name () << ": " << atti_size->Value () << ", " << \
        atti_date->Name () << ": " << atti_date->Value () << endl;

    }
    catch (string& e) {
        return (false);
    }

    return true;
}
开发者ID:aeihu,项目名称:hacks,代码行数:31,代码来源:main.cpp

示例2: lastAttribute

// -----------------------------------------------------------------------------
// Obtain the name of the current element's last attribute
// -----------------------------------------------------------------------------
const char* SimXMLDocument::lastAttribute()
{
   // Get the current element
   if(m_paNode.empty())
   {
      return StringTable->EmptyString;
   }
   const int iLastElement = m_paNode.size() - 1;
   TiXmlElement* pNode = m_paNode[iLastElement];
   if(!pNode)
   {
      return StringTable->EmptyString;
   }

   // Gets its last attribute, if any
   m_CurrentAttribute = pNode->LastAttribute();
   if(!m_CurrentAttribute)
   {
      return StringTable->EmptyString;
   }

   return m_CurrentAttribute->Name();
}
开发者ID:greenfire27,项目名称:Torque2D,代码行数:26,代码来源:SimXMLDocument.cpp

示例3: getNumAttributes

//---------------------------------------------------------
int ofxXmlSettings::getNumAttributes(const string& tag, int which){
	vector<string> tokens = tokenize(tag,":");
	TiXmlHandle tagHandle = storedHandle;
	for (int x = 0; x < (int)tokens.size(); x++) {
		if (x == 0)
			tagHandle = tagHandle.ChildElement(tokens.at(x), which);
		else
			tagHandle = tagHandle.FirstChildElement(tokens.at(x));
	}

	if (tagHandle.ToElement()) {
		TiXmlElement* elem = tagHandle.ToElement();

		// Do stuff with the element here
		TiXmlAttribute* first = elem->FirstAttribute();
		if (first) {
			int count = 1;
			for (TiXmlAttribute* curr = first; curr != elem->LastAttribute(); curr = curr->Next())
				count++;
			return count;
		}
	}
	return 0;
}
开发者ID:AnnaKolla,项目名称:openFrameworks,代码行数:25,代码来源:ofxXmlSettings.cpp

示例4: handler

vector<EncodedAttributeInfo*> LoadSavedDataSources::loadCodedAttributesFromMultipleFiles( string dsName,int rowCount,bool limit )
{
	vector<EncodedAttributeInfo*> codedAtts;
	try
	{
		for (int j = 0 ; j < this->saved_file_names.size() ; j++)
		{
			this->_fileName = ConfigurationReader::ReadConfiguration(ConfigurationReader::configutation::SAVE_DATA_FOLDER) + this->_saved_folder + "\\" + this->saved_file_names[j];
			TiXmlDocument *doc_1 = new TiXmlDocument(this->_fileName.c_str());
			doc_1->LoadFile();
			TiXmlHandle handler(doc_1);
			TiXmlElement *dsElement = handler.FirstChild("DataSources").ToElement();
			dsElement = dsElement->FirstChildElement("DataSource");
			if (strcmp(dsElement->Attribute("Name"),dsName.c_str()) == 0)
			{
				dsElement = dsElement->FirstChildElement("CodedAttribute");
				int attID = dsElement->FirstAttribute()->IntValue();
				int attType = atoi(dsElement->Attribute("Type"));
				string attName = dsElement->Attribute("Name");
				int noVStreams = dsElement->LastAttribute()->IntValue();
				EncodedAttributeInfo* attr;
				switch(attType){
					case 0:
						{
							EncodedIntAttribute *intAtt = new EncodedIntAttribute();
							intAtt->setAttID(attID);
							intAtt->setAttName(attName);
							intAtt->setNoOfVBitStreams(noVStreams,rowCount);
							intAtt->setAttType(getAttType(attType));

							BitStreamInfo** bitStreams = new BitStreamInfo*[noVStreams];
							TiXmlElement *vbs = dsElement->FirstChildElement("VBitStreams")->FirstChildElement("vbitstream");
							for (int k = 0 ; k < noVStreams ; k++)
							{
								BitStreamInfo* bitStr = new VBitStream();
								bitStr->setBitCount(rowCount);
								bitStr->setBitStreamAllocAttID(attID);
								bitStr->setBitStreamAllocAttName(attName);
								string bitStream;
								if (limit)
								{
									bitStream = vbs->GetText();
									long offset = rowCount - this->_rowLimit;
									bitStream = bitStream.substr(offset,this->_rowLimit);
								}
								else bitStream = vbs->GetText();
								dynamic_bitset<> temp(bitStream);
								bitStr->convert(temp);
								bitStreams[k] = bitStr;
								vbs = vbs->NextSiblingElement("vbitstream");
							}
							vector<BitStreamInfo*> tempVB(bitStreams , bitStreams + noVStreams);
							intAtt->setVBitStreams(tempVB);
							attr = intAtt;
							codedAtts.push_back(attr);
							break;
						}
					case 1:
						{
							EncodedDoubleAttribute *doubleAtt = new EncodedDoubleAttribute();
							doubleAtt->setAttID(attID);
							doubleAtt->setAttName(attName);
							doubleAtt->setNoOfVBitStreams(noVStreams,rowCount);
							doubleAtt->setAttType(getAttType(attType));

							BitStreamInfo** bitStreams = new BitStreamInfo*[noVStreams];
							TiXmlElement *vbs = dsElement->FirstChildElement("VBitStreams")->FirstChildElement("vbitstream");
							for (int k = 0 ; k < noVStreams ; k++)
							{
								BitStreamInfo* bitStr = new VBitStream();
								bitStr->setBitCount(rowCount);
								bitStr->setBitStreamAllocAttID(attID);
								bitStr->setBitStreamAllocAttName(attName);
								string bitStream;
								if (limit)
								{
									bitStream = vbs->GetText();
									long offset = rowCount - this->_rowLimit;
									bitStream = bitStream.substr(offset,this->_rowLimit);
								}
								else bitStream = vbs->GetText();
								dynamic_bitset<> temp(bitStream);
								bitStr->convert(temp);
								bitStreams[k] = bitStr;
								vbs = vbs->NextSiblingElement("vbitstream");
							}
							vector<BitStreamInfo*> tempVB(bitStreams , bitStreams + noVStreams);
							doubleAtt->setVBitStreams(tempVB);
							attr = doubleAtt;
							codedAtts.push_back(attr);
							break;
						}
					case 3:
						{
							EncodedMultiCatAttribute *catAtt = new EncodedMultiCatAttribute();
							catAtt->setAttID(attID);
							catAtt->setAttName(attName);
							catAtt->setAttType(getAttType(attType));
							catAtt->setNoOfVBitStreams(noVStreams,rowCount);

//.........这里部分代码省略.........
开发者ID:asankaf,项目名称:scalable-data-mining-framework,代码行数:101,代码来源:LoadSavedDataSources.cpp

示例5: loadSavedEncodedDataFromMultipleFiles

DataSources* LoadSavedDataSources::loadSavedEncodedDataFromMultipleFiles( bool limit /*= false*/ )
{
	DataSources *dss = new DataSources();
	string metaDataFile = ConfigurationReader::ReadConfiguration(ConfigurationReader::configutation::SAVE_DATA_FOLDER) + this->_saved_folder + "\\" + this->_metaFile + ".xml";
	if (chdir(ConfigurationReader::ReadConfiguration(ConfigurationReader::configutation::SAVE_DATA_FOLDER).c_str()) == -1)
	{
		error_folder_not_exist ex;
		string err = ExceptionReader::GetError(SM1015);
		err += "-> Saved data folder provided in config file is missing";
		ex << error_message(err);
		ex << error_code(SM1015);
		BOOST_THROW_EXCEPTION(ex);
	}
	
	//string metaDataFile = ConfigurationReader::ReadConfiguration(ConfigurationReader::configutation::SAVE_DATA_FOLDER) + this->_saved_folder + "/" + this->_metaFile + ".xml";
	//string encodedDataFile = "../Reports/" + this->_fileName + ".xml";
	//this->_fileName=encodedDataFile;
	//string metaDataFile = "..\\Reports\\" + this->_metaFile + ".xml";
	try
	{
		TiXmlDocument doc(metaDataFile.c_str());
		bool loaded = doc.LoadFile();
		TiXmlHandle handler( &doc );
		if (loaded)
		{
			TiXmlElement *root = handler.FirstChild("DataSources").ToElement();
			int dataSources = root->FirstAttribute()->IntValue();
			for (int i = 0 ; i < dataSources ; i++)
			{
				TiXmlElement *dsElement = root->FirstChildElement("DataSource");
				string dsName = dsElement->FirstAttribute()->Value();
				dsElement = dsElement->FirstChildElement("noOfAttributes");
				int noAtts = atoi(dsElement->GetText());

				//position where attributes from multiple attribute files are loaded.
				dsElement = dsElement->NextSiblingElement("AttributeFiles");
				TiXmlElement* saved_file_att_element = dsElement->FirstChildElement("att_file");
				this->saved_file_names.resize(noAtts);
				int count_att = 0;
				while (saved_file_att_element)
				{
					this->saved_file_names[count_att++] = saved_file_att_element->GetText();
					saved_file_att_element = saved_file_att_element->NextSiblingElement("att_file");
				}

				dsElement = dsElement->NextSiblingElement("noOfRows");
				int noRows = atoi(dsElement->GetText());
				//Following two lines will load the existance bitmap from the saved file.
				//For older versions of saved data files, this won't be working.
				//So for old data file loading, just comment the following two lines.
				//And also make sure to comment the place where the existance_map is added to wrapdatasource object.
				//string existanceMap = dsElement->NextSiblingElement("existanceBitMap")->GetText();
				//dynamic_bitset<> existance_map(existanceMap);

				vector<EncodedAttributeInfo*> codedAtts = loadCodedAttributesFromMultipleFiles(dsName,noRows,limit);
				if (limit)
				{
					if (this->_rowLimit > noRows)
					{
						this->_rowLimit = noRows;
					}
					noRows = this->_rowLimit;
				}

				dsElement = dsElement->NextSiblingElement("DataSourceType");
				WrapDataSource::DATASOURCE sourceType = getDataSourceType(atoi(dsElement->GetText()));
				WrapDataSource *ds = new WrapDataSource();
				ds->setDSName(dsName);
				ds->noOfAttributes(noAtts);
				ds->noOfRows(noRows);
				ds->setSourceType(sourceType);
				//comment this for loading old saved files. 
				//ds->ExistanceDatabitMap(existance_map);
				dsElement = dsElement->NextSiblingElement("CodedAttributes");
				TiXmlElement *attElement = dsElement->FirstChildElement("Attribute");
				int counter = 0;
				while (attElement && (counter <= noAtts))
				{
					int attType = attElement->LastAttribute()->IntValue();
					int attID = attElement->FirstAttribute()->IntValue();
					switch(attType)
					{
					case 0:
						{
							EncodedIntAttribute* intAtt = static_cast<EncodedIntAttribute*>(codedAtts[counter]);
							TiXmlElement *attEl = attElement->FirstChildElement("maxval");
							intAtt->setMaxVal(atol(attEl->GetText()));
							attEl = attElement->FirstChildElement("minval");
							intAtt->setMinVal(atol(attEl->GetText()));
							attEl = attElement->FirstChildElement("SignBitSet");
							//attEl = attElement->FirstChildElement("SignMapVal");
							// 						vector<bool> signMap;
							// 						if (atol(attEl->GetText()) == 0)
							// 						{						
							// 							signMap.resize(noRows);
							// 						}
							// 						//Set sign Bit Map for negative vals.
							// 						else
							// 						{
							// 							signMap.resize(noRows);
//.........这里部分代码省略.........
开发者ID:asankaf,项目名称:scalable-data-mining-framework,代码行数:101,代码来源:LoadSavedDataSources.cpp


注:本文中的TiXmlElement::LastAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。