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


C++ StringTable::Write方法代码示例

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


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

示例1: Write

	void ResourceTable::Write(const lemon::String & locale,IWriter & writer) const
	{
		std::string utf8 = lemon::to_utf8(locale);

		char localeString[5] = {0};

		memset(localeString,0,5);

		size_t localeStringLength = utf8.size();

		if(utf8.size() > 5) localeStringLength = 5;

		memcpy(localeString,utf8.c_str(),localeStringLength);

		writer.Write((const lemon::byte_t*)&localeString,5);

		//i18n -> l10n text table size

		lemon::uint16_t i18nTextTableSize = htons((lemon::uint16_t)_textTable.size());

		writer.Write((const lemon::byte_t*)&i18nTextTableSize,sizeof(i18nTextTableSize));

		//trace message table size

		lemon::uint16_t traceMessageTableSize = htons((lemon::uint16_t)_traceMessageTable.size());

		writer.Write((const lemon::byte_t*)&traceMessageTableSize,sizeof(traceMessageTableSize));

		//trace catalog table size

		lemon::uint16_t traceCatalogTableSize = htons((lemon::uint16_t)_traceCatalogTable.size());

		writer.Write((const lemon::byte_t*)&traceCatalogTableSize,sizeof(traceCatalogTableSize));

		//trace catalog table size

		lemon::uint16_t errorMessageTableSize = htons((lemon::uint16_t)_errorMessageTable.size());

		writer.Write((const lemon::byte_t*)&errorMessageTableSize,sizeof(errorMessageTableSize));

		// string table size

		lemon::uint16_t stringTableSize = htons((lemon::uint16_t)_stringTable.Items());

		writer.Write((const lemon::byte_t*)&stringTableSize,sizeof(stringTableSize));

		//i18n -> l10n text table 
		{
			TextTable::const_iterator iter,end = _textTable.end();

			for(iter = _textTable.begin() ; iter != end; ++ iter)
			{
				const I18nText & text = iter->second;

				lemon::uint32_t index = htonl(text.key);

				writer.Write((const lemon::byte_t*)&index,sizeof(index));

				index = htonl(text.Message);

				writer.Write((const lemon::byte_t*)&index,sizeof(index));
			}
		}

		//trace message table size

		{
			TraceMessageTable::const_iterator iter,end = _traceMessageTable.end();

			for(iter = _traceMessageTable.begin() ; iter != end; ++ iter)
			{
				const TraceMessage & text = iter->second;

				lemon::uint32_t index = htonl(text.Id);

				writer.Write((const lemon::byte_t*)&index,sizeof(index));

				index = htonl(text.Message);

				writer.Write((const lemon::byte_t*)&index,sizeof(index));
			}
		}
		//trace catalog table size

		{
			TraceCatalogTable::const_iterator iter,end = _traceCatalogTable.end();

			for(iter = _traceCatalogTable.begin() ; iter != end; ++ iter)
			{
				const TraceCatalog & text = iter->second;

				lemon::uint32_t index = htonl(text.Value);

				writer.Write((const lemon::byte_t*)&index,sizeof(index));

				index = htonl(text.Name);

				writer.Write((const lemon::byte_t*)&index,sizeof(index));

				index = htonl(text.Description);
//.........这里部分代码省略.........
开发者ID:zeusever,项目名称:lemon-lib,代码行数:101,代码来源:package.cpp


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