summaryrefslogtreecommitdiff
path: root/src/utils
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-03-29 03:51:37 +0300
committerAndrei Karas <akaras@inbox.ru>2012-03-29 03:52:16 +0300
commit3bf4e26b1319295532bb4396cbd6406d85cbcae0 (patch)
tree80a4303b29aafa21683e90e45798283a482bf1d1 /src/utils
parent7f607a0f58a9eba53237955c06bf445c71d57b6c (diff)
downloadplus-3bf4e26b1319295532bb4396cbd6406d85cbcae0.tar.gz
plus-3bf4e26b1319295532bb4396cbd6406d85cbcae0.tar.bz2
plus-3bf4e26b1319295532bb4396cbd6406d85cbcae0.tar.xz
plus-3bf4e26b1319295532bb4396cbd6406d85cbcae0.zip
Replace vectors with strings to short names.
Diffstat (limited to 'src/utils')
-rw-r--r--src/utils/langs.cpp4
-rw-r--r--src/utils/langs.h2
-rw-r--r--src/utils/stringutils.cpp9
-rw-r--r--src/utils/stringutils.h8
-rw-r--r--src/utils/stringvector.h31
-rw-r--r--src/utils/translation/translationmanager.cpp2
-rw-r--r--src/utils/translation/translationmanager.h7
7 files changed, 46 insertions, 17 deletions
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<std::string> getLang()
+LangVect getLang()
{
- std::vector<std::string> 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<std::string> LangVect;
typedef LangVect::const_iterator LangIter;
-std::vector<std::string> 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<std::string> &list)
+unsigned long findI(std::string text, StringVect &list)
{
std::string str = toLower(text);
unsigned long idx;
- for (std::vector<std::string>::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<std::string> splitToStringList(const std::string &text,
return tokens;
}
-void splitToStringVector(std::vector<std::string> &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 <string>
+#include "utils/stringvector.h"
+
#include <sstream>
#include <list>
#include <set>
-#include <vector>
/**
* 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<std::string> &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<int> splitToIntList(const std::string &text, char separator);
std::list<std::string> splitToStringList(const std::string &text,
char separator);
-void splitToStringVector(std::vector<std::string> &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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef UTILS_VECTORSTRING_H
+#define UTILS_VECTORSTRING_H
+
+#include <string>
+#include <vector>
+
+typedef std::vector<std::string> 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<std::string> &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 <string>
-#include <vector>
+#include "utils/stringvector.h"
class PoDict;
class TranslationManager
{
public:
- static PoDict *loadLang(std::vector<std::string> 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<std::string> &lines);
+ StringVect &lines);
};
#endif // UTILS_TRANSLATION_MANAGER_H