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


C++ TObjArray::First方法代码示例

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


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

示例1: OnCharacters

void TBDataParser::OnCharacters(const char *characters)
{	
	if(_currentElement != NULL && !strcmp(_currentElement->Data(),"vector")) {
		TString *string = new TString(characters);
		TObjArray *values = string->Tokenize(", ");

		for(Int_t i = 0; i < values->GetEntries(); i++) {
			TObjString *object = (TObjString *) values->At(i);
			TString value = object->GetString().ReplaceAll("\n", "").ReplaceAll("\t", "").ReplaceAll(" ", "").ReplaceAll("\0", "");
			if(value.IsFloat()) {
				_vector->Fill(value.Atof());
			}
		}

		if(_vectorsStack->GetEntries() == 1) {
			_motherVecEntries = _vector->GetEntries();
		} else if(_currentMethod != NULL && !strcmp(_currentMethod->Data(),"all")) {
			for(Int_t i = 1; i < _motherVecEntries; i++) {
				TObjString *object = (TObjString *) values->First();
				TString value = object->GetString().ReplaceAll("\n", "").ReplaceAll("\t", "").ReplaceAll(" ", "").ReplaceAll("\0", "");
				if(value.IsFloat())
					_vector->Fill(value.Atof());
			}
		} 

		values->Delete();

	}

}
开发者ID:matteodepalo,项目名称:l-zero-trigger-board,代码行数:30,代码来源:TBDataParser.C

示例2: OnStartElement

void TBDataParser::OnStartElement(const char *element, const TList *attributes)
{
	TXMLAttr *attr;
	TIter next(attributes);

	char *name = element;
	_currentElement = new TString(element);
	
	char *method = NULL;

	while ((attr = (TXMLAttr*) next())) {
		char *attrName = attr->GetName();
		char *attrValue = attr->GetValue();

		if(!strcmp(attrName, "name")) {
			name = attrValue; 
		}
		
		if(!strcmp(attrName, "method")) {
			method = attrValue;	
			_currentMethod = new TString(method);
		}
		
	}

	TFolder *currentFolder = _foldersStack->Last();

	if(!strcmp(element, "vector")) {
		TString *nameString = new TString(name);
		vector<float> *values = new vector<float>;
		_values = values;

		nameString->ReplaceAll(" ","_");

		TObjString *currentVector = new TObjString(nameString->Data());

		TObjArray *vectorsStack = _vectorsStack;
		vectorsStack->AddLast(currentVector);

		TString *joinedName = new TString(((TObjString *) vectorsStack->First())->GetString().Data());

		for(Int_t i = 1; i < vectorsStack->GetEntries(); i++) {
			joinedName->Append("_");
			joinedName->Append(((TObjString *) vectorsStack->At(i))->GetString().Data());
		}
		
		TObjString *joinedNameObj = new TObjString(joinedName->Data());
		TObjArray *joinedNameStack = _joinedNameStack;
		
		TNtuple *vector = new TNtuple(joinedName->Data(),joinedName->Data(),"values");
		_vector = vector;
		currentFolder->Add(vector);

		if(joinedNameStack->Contains(joinedName->Data()))
			cout << joinedName->Data() << "Error: " << "vector already exists. Be sure that in your XML file every vector has a unique path + name combination" << endl;
			
		joinedNameStack->Add(joinedNameObj);
			
			
		return;
	}

	_foldersStack->AddLast(currentFolder->AddFolder(name, name));
}
开发者ID:matteodepalo,项目名称:l-zero-trigger-board,代码行数:64,代码来源:TBDataParser.C


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