Moved MAX_SUPPORTED_LANGUAGES constant to defines.hpp

This commit is contained in:
Alex Zolotarev 2011-05-23 17:38:38 +02:00 committed by Alex Zolotarev
parent 1434e75808
commit b44ec9cdfa
5 changed files with 11 additions and 5 deletions

View file

@ -1,5 +1,7 @@
#include "multilang_utf8_string.hpp"
#include "../defines.hpp"
char StringUtf8Multilang::GetLangIndex(string const & lang)
{
static char const * arr[] = { "default",
@ -11,7 +13,7 @@ char StringUtf8Multilang::GetLangIndex(string const & lang)
"kk", "la", "et", "vi", "mn", "mk", "lv", "fur", "gsw", "ja_kana",
"is", "hi", "ku" };
STATIC_ASSERT(ARRAY_SIZE(arr) <= 64);
STATIC_ASSERT(ARRAY_SIZE(arr) == MAX_SUPPORTED_LANGUAGES);
for (size_t i = 0; i < ARRAY_SIZE(arr); ++i)
if (lang == arr[i])

View file

@ -22,3 +22,6 @@
#define SETTINGS_FILE_NAME "settings.ini"
#define DEFAULT_AUTO_UPDATES_ENABLED true
/// How many langs we're supporting on indexing stage
#define MAX_SUPPORTED_LANGUAGES 64

View file

@ -934,6 +934,7 @@ public:
: m_priorities(priorities), m_result(result), m_minPriority(256) {}
bool operator() (char lang, string const & utf8s)
{
ASSERT(lang >= 0 && lang < MAX_SUPPORTED_LANGUAGES, ());
int const priority = m_priorities[static_cast<uint8_t>(lang)];
if (priority == 0)
{
@ -965,7 +966,7 @@ string FeatureType::GetPreferredDrawableName(char const * priorities) const
if (res.empty() && GetFeatureType() == GEOM_AREA)
res = m_Params.house.Get();
return res;
}

View file

@ -1,6 +1,8 @@
#include "languages.hpp"
#include "settings.hpp"
#include "../defines.hpp"
#include "../base/logging.hpp"
#include "../base/string_utils.hpp"
@ -34,7 +36,7 @@ namespace languages
static void SetPreferableLanguages(vector<string> const & langCodes)
{
CHECK_EQUAL(langCodes.size(), 64, ());
CHECK_EQUAL(langCodes.size(), MAX_SUPPORTED_LANGUAGES, ());
for (size_t i = 0; i < langCodes.size(); ++i)
{
char const index = StringUtf8Multilang::GetLangIndex(langCodes[i]);

View file

@ -6,8 +6,6 @@
namespace languages
{
static int const MAX_SUPPORTED_LANGUAGES = 64;
typedef vector<pair<string, string> > CodesAndNamesT;
typedef vector<string> CodesT;