From 3bf4e26b1319295532bb4396cbd6406d85cbcae0 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Thu, 29 Mar 2012 03:51:37 +0300 Subject: Replace vectors with strings to short names. --- src/utils/langs.cpp | 4 ++-- src/utils/langs.h | 2 +- src/utils/stringutils.cpp | 9 ++++---- src/utils/stringutils.h | 8 +++---- src/utils/stringvector.h | 31 ++++++++++++++++++++++++++++ src/utils/translation/translationmanager.cpp | 2 +- src/utils/translation/translationmanager.h | 7 +++---- 7 files changed, 46 insertions(+), 17 deletions(-) create mode 100644 src/utils/stringvector.h (limited to 'src/utils') diff --git a/src/utils/langs.cpp b/src/utils/langs.cpp index c1f9f7ecf..1aa3e472d 100644 --- a/src/utils/langs.cpp +++ b/src/utils/langs.cpp @@ -30,9 +30,9 @@ #include "debug.h" -std::vector getLang() +LangVect getLang() { - std::vector langs; + LangVect langs; std::string lang = config.getValue("lang", "").c_str(); if (lang.empty()) diff --git a/src/utils/langs.h b/src/utils/langs.h index 67c13d8ee..5cde62927 100644 --- a/src/utils/langs.h +++ b/src/utils/langs.h @@ -30,7 +30,7 @@ typedef std::vector LangVect; typedef LangVect::const_iterator LangIter; -std::vector getLang(); +LangVect getLang(); std::string getLangSimple(); diff --git a/src/utils/stringutils.cpp b/src/utils/stringutils.cpp index 5a7ea87fd..b1e464005 100644 --- a/src/utils/stringutils.cpp +++ b/src/utils/stringutils.cpp @@ -203,12 +203,11 @@ unsigned long findI(std::string str, std::string subStr) return str.find(subStr); } -unsigned long findI(std::string text, std::vector &list) +unsigned long findI(std::string text, StringVect &list) { std::string str = toLower(text); unsigned long idx; - for (std::vector::const_iterator i = list.begin(); - i != list.end(); ++i) + for (StringVectCIter i = list.begin(); i != list.end(); ++ i) { std::string subStr = *i; subStr = toLower(subStr); @@ -447,8 +446,8 @@ std::list splitToStringList(const std::string &text, return tokens; } -void splitToStringVector(std::vector &tokens, - const std::string &text, char separator) +void splitToStringVector(StringVect &tokens, const std::string &text, + char separator) { std::stringstream ss(text); std::string item; diff --git a/src/utils/stringutils.h b/src/utils/stringutils.h index 31ee6d51f..9fdc0d2f6 100644 --- a/src/utils/stringutils.h +++ b/src/utils/stringutils.h @@ -23,11 +23,11 @@ #ifndef UTILS_STRINGUTILS_H #define UTILS_STRINGUTILS_H -#include +#include "utils/stringvector.h" + #include #include #include -#include /** * Trims spaces off the end and the beginning of the given string. @@ -136,7 +136,7 @@ bool isWordSeparator(char chr); unsigned long findI(std::string str, std::string subStr); -unsigned long findI(std::string text, std::vector &list); +unsigned long findI(std::string text, StringVect &list); const std::string encodeStr(unsigned int value, unsigned int size = 0); @@ -179,7 +179,7 @@ std::list splitToIntList(const std::string &text, char separator); std::list splitToStringList(const std::string &text, char separator); -void splitToStringVector(std::vector &tokens, +void splitToStringVector(StringVect &tokens, const std::string &text, char separator); std::string combineDye(std::string file, std::string dye); diff --git a/src/utils/stringvector.h b/src/utils/stringvector.h new file mode 100644 index 000000000..c254bd5de --- /dev/null +++ b/src/utils/stringvector.h @@ -0,0 +1,31 @@ +/* + * The ManaPlus Client + * Copyright (C) 2012 The ManaPlus Developers + * + * This file is part of The ManaPlus Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef UTILS_VECTORSTRING_H +#define UTILS_VECTORSTRING_H + +#include +#include + +typedef std::vector StringVect; +typedef StringVect::iterator StringVectIter; +typedef StringVect::const_iterator StringVectCIter; + +#endif diff --git a/src/utils/translation/translationmanager.cpp b/src/utils/translation/translationmanager.cpp index 03dd6d100..2a962913a 100644 --- a/src/utils/translation/translationmanager.cpp +++ b/src/utils/translation/translationmanager.cpp @@ -88,7 +88,7 @@ PoDict *TranslationManager::loadLang(LangVect lang, bool TranslationManager::translateFile(const std::string &fileName, PoDict *dict, - std::vector &lines) + StringVect &lines) { if (!dict || fileName.empty()) return false; diff --git a/src/utils/translation/translationmanager.h b/src/utils/translation/translationmanager.h index 842c5620b..debb555ea 100644 --- a/src/utils/translation/translationmanager.h +++ b/src/utils/translation/translationmanager.h @@ -23,15 +23,14 @@ #include "localconsts.h" -#include -#include +#include "utils/stringvector.h" class PoDict; class TranslationManager { public: - static PoDict *loadLang(std::vector lang, + static PoDict *loadLang(StringVect lang, std::string subName, PoDict *dict = nullptr); @@ -43,7 +42,7 @@ class TranslationManager static bool translateFile(const std::string &fileName, PoDict *dict, - std::vector &lines); + StringVect &lines); }; #endif // UTILS_TRANSLATION_MANAGER_H -- cgit v1.2.3-70-g09d2