Pyrogenesis trunk
po_parser.hpp
Go to the documentation of this file.
1// tinygettext - A gettext replacement that works directly on .po files
2// Copyright (c) 2009 Ingo Ruhnke <grumbel@gmail.com>
3//
4// This software is provided 'as-is', without any express or implied
5// warranty. In no event will the authors be held liable for any damages
6// arising from the use of this software.
7//
8// Permission is granted to anyone to use this software for any purpose,
9// including commercial applications, and to alter it and redistribute it
10// freely, subject to the following restrictions:
11//
12// 1. The origin of this software must not be misrepresented; you must not
13// claim that you wrote the original software. If you use this software
14// in a product, an acknowledgement in the product documentation would be
15// appreciated but is not required.
16// 2. Altered source versions must be plainly marked as such, and must not be
17// misrepresented as being the original software.
18// 3. This notice may not be removed or altered from any source distribution.
19
20#ifndef HEADER_TINYGETTEXT_PO_PARSER_HPP
21#define HEADER_TINYGETTEXT_PO_PARSER_HPP
22
23#include <iosfwd>
24
25#include "iconv.hpp"
26
27namespace tinygettext {
28
29class Dictionary;
30
32{
33private:
34 std::string filename;
35 std::istream& in;
38
39 bool running;
40 bool eof;
41 bool big5;
42
44 std::string current_line;
45
47
48 POParser(const std::string& filename, std::istream& in_, Dictionary& dict_, bool use_fuzzy = true);
49 ~POParser();
50
51 void parse_header(const std::string& header);
52 void parse();
53 void next_line();
54 std::string get_string(unsigned int skip);
55 void get_string_line(std::ostringstream& str, size_t skip);
56 bool is_empty_line();
57 bool prefix(const char* );
58#ifdef _WIN32
59 void error(const std::string& msg);
60#else
61 void error(const std::string& msg) __attribute__((__noreturn__));
62#endif
63 void warning(const std::string& msg);
64
65public:
66 /** @param filename name of the istream, only used in error messages
67 @param in stream from which the PO file is read.
68 @param dict dictionary to which the strings are written */
69 static void parse(const std::string& filename, std::istream& in, Dictionary& dict);
70 static bool pedantic;
71
72private:
75};
76
77} // namespace tinygettext
78
79#endif
80
81/* EOF */
A simple dictionary class that mimics gettext() behaviour.
Definition: dictionary.hpp:35
Definition: iconv.hpp:79
Definition: po_parser.hpp:32
void parse()
Definition: po_parser.cpp:333
POParser(const POParser &)
bool prefix(const char *)
Definition: po_parser.cpp:327
void next_line()
Definition: po_parser.cpp:90
bool use_fuzzy
Definition: po_parser.hpp:37
bool eof
Definition: po_parser.hpp:40
void warning(const std::string &msg)
Definition: po_parser.cpp:70
Dictionary & dict
Definition: po_parser.hpp:36
bool is_empty_line()
Definition: po_parser.cpp:305
std::string current_line
Definition: po_parser.hpp:44
bool big5
Definition: po_parser.hpp:41
~POParser()
Definition: po_parser.cpp:65
POParser(const std::string &filename, std::istream &in_, Dictionary &dict_, bool use_fuzzy=true)
Definition: po_parser.cpp:51
void get_string_line(std::ostringstream &str, size_t skip)
Definition: po_parser.cpp:98
IConv conv
Definition: po_parser.hpp:46
void parse_header(const std::string &header)
Definition: po_parser.cpp:239
std::istream & in
Definition: po_parser.hpp:35
std::string filename
Definition: po_parser.hpp:34
int line_number
Definition: po_parser.hpp:43
POParser & operator=(const POParser &)
void error(const std::string &msg) __attribute__((__noreturn__))
Definition: po_parser.cpp:77
bool running
Definition: po_parser.hpp:39
std::string get_string(unsigned int skip)
Definition: po_parser.cpp:166
static bool pedantic
Definition: po_parser.hpp:70
static char * skip(char **buf, const char *delimiters)
Definition: mongoose.cpp:753
Definition: L10n.h:36