added to Locale:
const std::wstring & GetReplace(const wchar_t * key, Types ... types) key is a string pattern which has %0, %1 parameters which will be replaced with 'types' git-svn-id: svn://ttmath.org/publicrep/winix/branches/0.7.x@1164 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
#include "space/spaceparser.h"
|
||||
#include "textstream/textstream.h"
|
||||
#include "core/winixbase.h"
|
||||
#include "convert/patternreplacer.h"
|
||||
|
||||
|
||||
namespace Winix
|
||||
@@ -109,6 +110,40 @@ public:
|
||||
const std::wstring & Get(const PT::TextStreamBase<char_type, stack_size, heap_block_size> & key,
|
||||
bool try_default_too = true);
|
||||
|
||||
template<typename ... Types>
|
||||
const std::wstring & GetReplace(const wchar_t * key, Types ... types)
|
||||
{
|
||||
const std::wstring & pattern = Get(key, true);
|
||||
pattern_replacer.ReplaceToString(pattern, pattern_value, types...);
|
||||
return pattern_value;
|
||||
}
|
||||
|
||||
|
||||
template<typename ... Types>
|
||||
const std::wstring & GetReplaceForLang(const wchar_t * key, size_t lang_id, Types ... types)
|
||||
{
|
||||
const std::wstring & pattern = Get(key, lang_id, true);
|
||||
pattern_replacer.ReplaceToString(pattern, pattern_value, types...);
|
||||
return pattern_value;
|
||||
}
|
||||
|
||||
template<typename ... Types>
|
||||
const std::wstring & GetReplace(const std::wstring & key, Types ... types) const
|
||||
{
|
||||
const std::wstring & pattern = Get(key, true);
|
||||
pattern_replacer.ReplaceToString(pattern, pattern_value, types...);
|
||||
return pattern_value;
|
||||
}
|
||||
|
||||
template<typename ... Types>
|
||||
const std::wstring & GetReplaceForLang(const std::wstring & key, size_t lang_id, Types ... types) const
|
||||
{
|
||||
const std::wstring & pattern = Get(key, lang_id, true);
|
||||
pattern_replacer.ReplaceToString(pattern, pattern_value, types...);
|
||||
return pattern_value;
|
||||
}
|
||||
|
||||
|
||||
// lists
|
||||
// current limitation:
|
||||
// we are looking only in 'space.table' so lists with only one item are not found
|
||||
@@ -213,6 +248,9 @@ private:
|
||||
// current locale index (index to locale_indexes)
|
||||
size_t current_lang;
|
||||
|
||||
PT::WPatternReplacer pattern_replacer;
|
||||
|
||||
|
||||
// vectors of characters substitution (sort by 'from')
|
||||
std::vector<SubstItem> subst_url; // for url substitution
|
||||
std::vector<SubstItem> subst_smalllet; // changing from small to capital
|
||||
@@ -228,6 +266,7 @@ private:
|
||||
const std::wstring empty; // used when returning a non existing key from loc_tab (or in LangToFileName)
|
||||
const std::vector<std::wstring> empty_list; // the same as above
|
||||
std::string adir1, adir2;
|
||||
std::wstring pattern_value;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user