GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/utils/translation/podict.cpp Lines: 10 15 66.7 %
Date: 2021-03-17 Branches: 2 6 33.3 %

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