Index: src/libictranslate/ResourceManager.cpp =================================================================== diff -u -r4eceec553f29c0ba93452ffeb52a647204dc9fce -r9d10e42a5ed39ac9a7dddd973679296994c9bf0e --- src/libictranslate/ResourceManager.cpp (.../ResourceManager.cpp) (revision 4eceec553f29c0ba93452ffeb52a647204dc9fce) +++ src/libictranslate/ResourceManager.cpp (.../ResourceManager.cpp) (revision 9d10e42a5ed39ac9a7dddd973679296994c9bf0e) @@ -22,6 +22,7 @@ #include "../libicpf/cfg.h" #include "../libicpf/crc32.h" #include +#include #ifdef _DEBUG #define new DEBUG_NEW @@ -31,6 +32,90 @@ #define EMPTY_STRING _t("") +CFormat::CFormat(const tchar_t* pszFormat) : + m_strText(pszFormat) +{ +} + +CFormat::~CFormat() +{ +} + +void CFormat::SetFormat(const tchar_t* pszFormat) +{ + m_strText = pszFormat; +} + +CFormat& CFormat::SetParam(PCTSTR pszName, PCTSTR pszText) +{ + assert(pszName); + if(!pszName) + return *this; + + size_t stLen = _tcslen(pszName); + tstring_t::size_type stPos = 0; + while((stPos = m_strText.find(pszName)) != tstring_t::npos) + { + m_strText.replace(stPos, stLen, pszText); + } + + return *this; +} + +CFormat& CFormat::SetParam(PCTSTR pszName, ull_t ullData) +{ + tchar_t szBuffer[64]; + _sntprintf(szBuffer, 63, ULLFMT, ullData); + szBuffer[63] = _t('\0'); + + return SetParam(pszName, szBuffer); +} + +CFormat& CFormat::SetParam(PCTSTR pszName, ll_t llData) +{ + tchar_t szBuffer[64]; + _sntprintf(szBuffer, 63, LLFMT, llData); + szBuffer[63] = _t('\0'); + + return SetParam(pszName, szBuffer); +} + +CFormat& CFormat::SetParam(PCTSTR pszName, ulong_t ulData) +{ + tchar_t szBuffer[64]; + _sntprintf(szBuffer, 63, ULFMT, ulData); + szBuffer[63] = _t('\0'); + + return SetParam(pszName, szBuffer); +} + +CFormat& CFormat::SetParam(PCTSTR pszName, uint_t uiData) +{ + tchar_t szBuffer[64]; + _sntprintf(szBuffer, 63, UIFMT, uiData); + szBuffer[63] = _t('\0'); + + return SetParam(pszName, szBuffer); +} + +CFormat& CFormat::SetParam(PCTSTR pszName, int_t iData) +{ + tchar_t szBuffer[64]; + _sntprintf(szBuffer, 63, IFMT, iData); + szBuffer[63] = _t('\0'); + + return SetParam(pszName, szBuffer); +} + +CFormat& CFormat::SetParam(PCTSTR pszName, bool bData) +{ + tchar_t szBuffer[64]; + _sntprintf(szBuffer, 63, USFMT, (ushort_t)bData); + szBuffer[63] = _t('\0'); + + return SetParam(pszName, szBuffer); +} + CTranslationItem::CTranslationItem() : m_pszText(NULL), m_uiChecksum(0), Index: src/libictranslate/ResourceManager.h =================================================================== diff -u -r4eceec553f29c0ba93452ffeb52a647204dc9fce -r9d10e42a5ed39ac9a7dddd973679296994c9bf0e --- src/libictranslate/ResourceManager.h (.../ResourceManager.h) (revision 4eceec553f29c0ba93452ffeb52a647204dc9fce) +++ src/libictranslate/ResourceManager.h (.../ResourceManager.h) (revision 9d10e42a5ed39ac9a7dddd973679296994c9bf0e) @@ -38,6 +38,29 @@ typedef void(*PFNNOTIFYCALLBACK)(uint_t); +class LIBICTRANSLATE_API CFormat +{ +public: + CFormat() {}; + CFormat(const tchar_t* pszFormat); + ~CFormat(); + + void SetFormat(const tchar_t* pszFormat); + + CFormat& SetParam(PCTSTR pszName, PCTSTR pszText); + CFormat& SetParam(PCTSTR pszName, ull_t ullData); + CFormat& SetParam(PCTSTR pszName, ll_t llData); + CFormat& SetParam(PCTSTR pszName, ulong_t ulData); + CFormat& SetParam(PCTSTR pszName, uint_t uiData); + CFormat& SetParam(PCTSTR pszName, int_t iData); + CFormat& SetParam(PCTSTR pszName, bool bData); + + operator const tchar_t*() const { return m_strText.c_str(); } + +protected: + tstring_t m_strText; +}; + /////////////////////////////////////////////////////////// // language description structure class LIBICTRANSLATE_API CTranslationItem