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


C++ Section::GetEntryRef方法代码示例

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


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

示例1: Execute

void ActionModifyBatch::Execute()
{
	// Find the section to modify
	size_t len = selection->GetCount();
	String sectionName = section;
	if (sectionName.IsEmpty()) sectionName = entries[0]->GetDefaultGroup();
	Section sect = GetSection(sectionName);

	// For each line...
	for (size_t i=0;i<len;i++) {
		if (i < deltas.size() && deltas[i]) {
			Entry &ref = sect->GetEntryRef(selection->GetLine(i));
			ref->GetDeltaCoder()->ApplyDelta(deltas[i],ref);
		}
		else sect->GetEntryRef(selection->GetLine(i)) = entries[i];
	}
}
开发者ID:Aegisub,项目名称:Athenasub,代码行数:17,代码来源:action.cpp

示例2: GetAntiAction

Action ActionModifyBatch::GetAntiAction() const
{
	// Old, slow method
	if (false) {
		// Get section
		Section sect = GetSection(section);
		size_t len = selection->GetCount();
		std::vector<VoidPtr> _deltas(len);
		std::vector<Entry> oldEntries(len);

		// For each line...
		for (size_t i=0;i<len;i++) {
			// Get old entry
			Entry& oldEntry = sect->GetEntryRef(selection->GetLine(i));

			// Try to get a delta
			DeltaCoder deltaCoder = oldEntry->GetDeltaCoder();
			if (deltaCoder) {
				if (i < deltas.size() && deltas[i]) _deltas[i] = deltaCoder->EncodeReverseDelta(deltas[i],oldEntry);
				_deltas[i] = deltaCoder->EncodeDelta(entries[i],oldEntry,!noTextFields);
			}

			// Store the whole original line
			else oldEntries[i] = oldEntry;
		}

		return Action(new ActionModifyBatch(GetModel(),oldEntries,_deltas,selection,section,noTextFields));
	}

	else {
		// Get section
		Section sect = GetSection(section);
		size_t len = selection->GetCount();

		// OK, this block warrants some explanation:
		// Copying smart pointers around all the time is quite slow, so I just create them once and
		// access the final copies.
		ActionModifyBatch* antiPtr = new ActionModifyBatch(GetModel(),selection,section,noTextFields);
		Action anti = Action(antiPtr);
		std::vector<VoidPtr>& _deltas = antiPtr->deltas;
		std::vector<Entry>& oldEntries = antiPtr->entries;
		_deltas.resize(len);
		oldEntries.resize(len);

		// For each line...
		for (size_t i=0;i<len;i++) {
			// Get old entry
			Entry& oldEntry = sect->GetEntryRef(selection->GetLine(i));

			// Try to get a delta
			DeltaCoder deltaCoder = oldEntry->GetDeltaCoder();
			if (deltaCoder) {
				if (i < deltas.size() && deltas[i]) _deltas[i] = deltaCoder->EncodeReverseDelta(deltas[i],oldEntry);
				_deltas[i] = deltaCoder->EncodeDelta(entries[i],oldEntry,!noTextFields);
			}

			// Store the whole original line
			else oldEntries[i] = oldEntry;
		}

		return anti;
	}
}
开发者ID:Aegisub,项目名称:Athenasub,代码行数:63,代码来源:action.cpp


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