GCC Code Coverage Report
Directory: src/ Exec Total Coverage
File: src/utils/translation/poparser.h Lines: 2 2 100.0 %
Date: 2017-11-29 Branches: 0 0 0.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
#ifndef UTILS_TRANSLATION_POPARSER_H
22
#define UTILS_TRANSLATION_POPARSER_H
23
24
#include "localconsts.h"
25
26
#include <sstream>
27
28
class PoDict;
29
30
30
class PoParser final
31
{
32
    public:
33
        PoParser();
34
35
        A_DELETE_COPY(PoParser)
36
37
        PoDict *load(const std::string &restrict lang,
38
                     const std::string &restrict fileName = "",
39
                     PoDict *restrict const dict = nullptr);
40
41
        static bool checkLang(const std::string &lang);
42
43
        static PoDict *getEmptyDict();
44
45
    private:
46
        void setLang(const std::string &lang)
47
12
        { mLang = lang; }
48
49
        void openFile(const std::string &name);
50
51
        bool readLine();
52
53
        bool readMsgId();
54
55
        bool readMsgStr();
56
57
        bool checkLine() const;
58
59
        static std::string getFileName(const std::string &lang);
60
61
        PoDict *getDict() const RETURNS_NONNULL A_WARN_UNUSED;
62
63
        static void convertStr(std::string &str);
64
65
        // current lang
66
        std::string mLang;
67
68
        // po file object
69
        std::istringstream mFile;
70
71
        // current line from po file
72
        std::string mLine;
73
74
        std::string mMsgId;
75
76
        std::string mMsgStr;
77
78
        PoDict *mDict;
79
80
        bool mReadingId;
81
82
        bool mReadingStr;
83
84
        bool mSkipId;
85
};
86
87
#endif  // UTILS_TRANSLATION_POPARSER_H