GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/utils/translation/podict.cpp Lines: 10 15 66.7 %
Date: 2017-11-29 Branches: 2 8 25.0 %

Line Branch Exec Source
1
/*
2
 *  The ManaPlus Client
3
 *  Copyright (C) 2012-2017  The ManaPlus Developers
4
 *
5
 *  This file is part of The ManaPlus Client.
6
 *
7
 *  This program is free software; you can redistribute it and/or modify
8
 *  it under the terms of the GNU General Public License as published by
9
 *  the Free Software Foundation; either version 2 of the License, or
10
 *  any later version.
11
 *
12
 *  This program is distributed in the hope that it will be useful,
13
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 *  GNU General Public License for more details.
16
 *
17
 *  You should have received a copy of the GNU General Public License
18
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 */
20
21
#include "utils/translation/podict.h"
22
23
#include "debug.h"
24
25
2
std::string empty;
26
27
PoDict *translator = nullptr;
28
PoDict *dictionary = nullptr;
29
PoDict *reverseDictionary = nullptr;
30
#ifdef ENABLE_CUSTOMNLS
31
PoDict *mainTranslator = nullptr;
32
#endif  // ENABLE_CUSTOMNLS
33
34
158
PoDict::PoDict(const std::string &lang) :
35
    mPoLines(),
36
474
    mLang(lang)
37
{
38
158
}
39
40
474
PoDict::~PoDict()
41
{
42
158
}
43
44
780
const std::string PoDict::getStr(const std::string &str)
45
{
46
2340
    if (mPoLines.find(str) == mPoLines.end())
47
        return str;
48
4
    return mPoLines[str];
49
}
50
51
const char *PoDict::getChar(const char *const str)
52
{
53
    if (mPoLines.find(str) == mPoLines.end())
54
        return str;
55
    return mPoLines[str].c_str();
56
}
57
58
bool PoDict::haveStr(const std::string &str) const
59
{
60
    return mPoLines.find(str) != mPoLines.end();
61
4
}