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


C++ IReader::readStrT方法代码示例

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


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

示例1: parse


//.........这里部分代码省略.........
	}

	if (!contentHandler.startDocument())
		return false;

	if (publicIdentifierId == 0) {
		wstring dtdPair;
		if (!reader.getStrT(dtdIndex, dtdPair))
			return false;
		if (debug) cout << " : dtdPair";
		size_t space = dtdPair.find(' ');
		if (space == string::npos) {
			cout << endl << "DTD specifier does not contain 'space'"<< endl;
			exit(1);
		}
		wstring name = dtdPair.substr(0, space);
		wstring dtd = dtdPair.substr(space+1);

		istream* resolverStream = resolver.resolveEntity(name,L"" , dtd);
		if (resolverStream != NULL) {
			// FIXME, use the resolver stream
			cout << endl << "Entity Resolver NOT Used." << endl;
		}
	}

	unsigned char id;
	while (reader.readByte(id)) {
		switch (id) {
			case WBXML::SWITCH_PAGE:
			if (debug) cout << " : Switch Page";
			if (!reader.readByte(tagPage)) return false;
			if (debug) cout << " : TagPage: " << (unsigned int)tagPage;
			break;

			case WBXML::END: {
				unsigned int tagID;
				if (stack.empty()) return false;
				tagID = stack.top();
				stack.pop();
				if (debug) cout << " : </" << tagHandler.getTag(tagID) << ">";
				if (!contentHandler.endElement(tagID)) return false;
				break;
			}
			case WBXML::ENTITY:
			if (debug) cout << " : Entity";
			if (!reader.readMultiByteInt((unsigned int&)entityBuf)) return false;
			if (debug) cout << " : " << entityBuf;
			if (!contentHandler.characters(&entityBuf, 0, 1)) return false;
			break;

			case WBXML::STR_I: {
				if (debug) cout << " : STR_I";
				wstring s;
				if (!reader.readStrI(s)) return false;
				if (!contentHandler.characters(s, 0, s.length())) return false;
				break;
			}
			case WBXML::EXT_I_0:
			case WBXML::EXT_I_1:
			case WBXML::EXT_I_2:
			case WBXML::EXT_T_0:
			case WBXML::EXT_T_1:
			case WBXML::EXT_T_2:
			case WBXML::EXT_0:
			case WBXML::EXT_1:
			case WBXML::EXT_2:
			case WBXML::OPAQUE: {
				MutableAttributes result;
				vector<wstring> value;
				if (!handleExtensions(reader, id, stack.top(), -1, result, value)) return false;
				break;
			}
			case WBXML::PI:
				if (debug) cout << " : PI";
			return false;
			//				throw new SAXException("PI Not Supported");
			break;

			case WBXML::STR_T: {
				if (debug) cout << " : STR_T";
				wstring s;
				unsigned int pos;
				if (!reader.readStrT(s, pos)) return false;
				if (!contentHandler.characters(s, 0, s.size())) return false;
				break;
			}
			default:
			if (!readElement(reader, id)) return false;
			break;
		}
	}

	if (!stack.empty()) {
		cout << endl << "Stack not empty " << stack.size();
		return false;
		//	throw new SAXException("unclosed elements: " + stack);
	}

	return contentHandler.endDocument();
}
开发者ID:,项目名称:,代码行数:101,代码来源:

示例2: readAttr

bool Parser::readAttr(IReader& reader, unsigned int tagID, MutableAttributes& atts) {
	int intResult;
	bool hasIntResult = false;
	wchar_t charResult;
	int hasCharResult = false;

	unsigned char id;
	if (!reader.readByte(id))
		return false;
	int attributeID = -1;
	while (id != WBXML::END) {
		// attribute start
		while (id == WBXML::SWITCH_PAGE) {
			if (debug) cout << " : Switch Page";
			if (!reader.readByte(attributePage))
				return false;
			if (debug) cout << " : AttributePage: " << (unsigned int)attributePage;
			if (!reader.readByte(id))
				return false;
		}
		attributeID = getAttributeId(id);

		if (debug) cout << " : AttributeID (0x" << hex << attributeID << "): " << tagHandler.getAttribute(attributeID);

		vector<wstring> value;

		// attribute value(s)
		if (!reader.readByte(id))
			return false;
		while (id > 128|| id == WBXML::SWITCH_PAGE || id == WBXML::ENTITY || id
				== WBXML::STR_I || id == WBXML::STR_T|| (id >= WBXML::EXT_I_0
				&& id <= WBXML::EXT_I_2)|| (id >= WBXML::EXT_T_0 && id
				<= WBXML::EXT_T_2)) {

			switch (id) {
			case WBXML::SWITCH_PAGE:
				if (debug) cout << " : Switch Page";
				if (!reader.readByte(attributePage))
					return false;
				if (debug) cout << " : AttributePage: " << (unsigned int)attributePage;
				break;

			case WBXML::ENTITY:
				if (debug) cout << " : Entity";
				if (!reader.readMultiByteInt((unsigned int&)charResult))
					return false;
				if (debug) cout << " : " << charResult;
				hasCharResult = true;
				value.push_back(&charResult);
				break;

			case WBXML::STR_I: {
				if (debug) cout << " : STR_I";
				wstring s;
				if (!reader.readStrI(s))
					return false;
				value.push_back(s);
				break;
			}
			case WBXML::EXT_I_0:
			case WBXML::EXT_I_1:
			case WBXML::EXT_I_2:
			case WBXML::EXT_T_0:
			case WBXML::EXT_T_1:
			case WBXML::EXT_T_2:
			case WBXML::EXT_0:
			case WBXML::EXT_1:
			case WBXML::EXT_2:
			case WBXML::OPAQUE:
				if (!handleExtensions(reader, id, tagID, attributeID, atts,
						value))
					return false;
				break;

			case WBXML::STR_T: {
				if (debug) cout << " : STR_T";
				wstring s;
				unsigned int pos;
				if (!reader.readStrT(s, pos))
					return false;
				value.push_back(s);
				break;
			}
			default:
				intResult = getAttributeId(id);
				hasIntResult = true;
				wstringstream s;
				s << intResult;
				value.push_back(s.str());
				break;
			}
			if (!reader.readByte(id))
				return false;
		}
		
		switch (value.size()) {
		case 0:
			// already handled
			break;
		case 1:
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


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