Пример #1
0
bool LocalizableStringManager::ProduceHeaderFile( const BazisLib::String &fp )
{
	File file(fp, FileModes::CreateOrTruncateRW);
	if (!file.Valid())
	{
		_tprintf(_T("ERROR: cannot open %s for writing\n"), fp.c_str());
		return false;
	}
	file.WriteLine(DynamicStringA("#pragma once\r\n//Generated by BazisLib STRGEN.EXE, http://bazislib.sysprogs.org/\r\n\r\n#include<bzshlp/Win32/i18n.h>\r\n#ifndef BAZISLIB_FIRST_LOCALIZABLE_STRING_ID\r\n#define BAZISLIB_FIRST_LOCALIZABLE_STRING_ID 0x1000\r\n#endif\r\n"));
	unsigned id = 0;
	DynamicStringA definitionLine;

	unsigned maxIdLen = 0;

	for each(const std::map<BazisLib::String, StringRecord>::value_type &pair in m_Strings)
		if (pair.first.length() > maxIdLen)
			maxIdLen = pair.first.length();

	DynamicStringA maxSpacing;
	maxSpacing.insert(0, maxIdLen, ' ');

	for each(const std::map<BazisLib::String, StringRecord>::value_type &pair in m_Strings)
	{
		const char *pSpacing = maxSpacing.c_str() + pair.first.length();
		definitionLine.Format("#define %s  %s(BAZISLIB_FIRST_LOCALIZABLE_STRING_ID + 0x%04X)", StringToANSIString(pair.first).c_str(), pSpacing, id++);
		file.WriteLine(definitionLine);
	}

	definitionLine.Format("\r\n#define BAZISLIB_LAST_LOCALIZABLE_STRING_ID \t(BAZISLIB_FIRST_LOCALIZABLE_STRING_ID + 0x%04X)", id - 1);
	file.WriteLine(definitionLine);

	return true;
}
Пример #2
0
bool LocalizableStringManager::ProduceIDTableFile( const BazisLib::String &fp, const String &HeaderFileName )
{
	File file(fp, FileModes::CreateOrTruncateRW);
	if (!file.Valid())
	{
		_tprintf(_T("ERROR: cannot open %s for writing\n"), fp.c_str());
		return false;
	}
	DynamicStringA definitionLine;

	file.WriteLine(DynamicStringA("#include \"stdafx.h\"\r\n#include <bzshlp/Win32/i18n.h>"));
	definitionLine.Format("#include \"%s\"", StringToANSIString(HeaderFileName).c_str());
	file.WriteLine(definitionLine);
	file.WriteLine(DynamicStringA("//Generated by BazisLib STRGEN.EXE, http://bazislib.sysprogs.org/\r\n"));
	file.WriteLine(DynamicStringA("BazisLib::StringIDRecord g_StringIDs[] = {"));
	unsigned id = 0;

	unsigned maxIdLen = 0;

	for each(const std::map<BazisLib::String, StringRecord>::value_type &pair in m_Strings)
		if (pair.first.length() > maxIdLen)
			maxIdLen = pair.first.length();

	DynamicStringA maxSpacing;
	maxSpacing.insert(0, maxIdLen, ' ');

	for each(const std::map<BazisLib::String, StringRecord>::value_type &pair in m_Strings)
	{
		const char *pSpacing = maxSpacing.c_str() + pair.first.length();
		definitionLine.Format("\t{%s%s, _T(\"%s\")},", StringToANSIString(pair.first).c_str(), pSpacing, StringToANSIString(pair.first).c_str());
		file.WriteLine(definitionLine);
	}

	file.WriteLine(DynamicStringA("\t{0, NULL},\r\n};"));

	return true;
}