fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / l10ntools / inc / po.hxx
blobe1a584d9931166fef46848e07c719e3b1be044d5
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #ifndef INCLUDED_L10NTOOLS_INC_PO_HXX
11 #define INCLUDED_L10NTOOLS_INC_PO_HXX
13 #include <fstream>
14 #include <rtl/string.hxx>
15 #include <boost/noncopyable.hpp>
17 class PoOfstream;
18 class PoIfstream;
19 class GenPoEntry;
22 /** Interface to use po entries in localization
24 PoEntry based on GenPoEntry class which stores attributes
25 of general po entry(see po.cxx). It makes easy to get/set
26 all information needed to localize one english(US) string.
27 It contains some basic checkings and some string
28 transformations between po string and string used by
29 localization tools.
31 class PoEntry
33 private:
35 GenPoEntry* m_pGenPo;
36 bool m_bIsInitialized;
38 public:
40 friend class PoOfstream;
41 friend class PoIfstream;
43 enum TYPE { TTEXT, TQUICKHELPTEXT, TTITLE };
44 enum Exception { NOSOURCFILE, NORESTYPE, NOGROUPID, NOSTRING, WRONGHELPTEXT };
46 PoEntry();
47 PoEntry( const OString& rSourceFile, const OString& rResType, const OString& rGroupId,
48 const OString& rLocalId, const OString& rHelpText, const OString& rText,
49 const TYPE eType = TTEXT );
50 ~PoEntry();
52 PoEntry( const PoEntry& rPo );
53 PoEntry& operator=( const PoEntry& rPo );
55 OString getSourceFile() const; ///< Get name of file from which entry is extracted
56 OString getGroupId() const;
57 OString getLocalId() const;
58 OString getResourceType() const; ///< Get the type of component from which entry is extracted
59 TYPE getType() const; ///< Get the type of entry
60 OString getMsgId() const;
61 OString getMsgStr() const;
62 bool isFuzzy() const;
64 /// Check whether po-s belong to the same localization component
65 static bool IsInSameComp(const PoEntry& rPo1,const PoEntry& rPo2);
66 static OString genKeyId(const OString& rGenerator);
70 /** Interface to work with header of po/pot files
72 This class stores information which is in header of
73 a po file. It's main function to generate header to
74 template po files(pot).
76 class PoHeader: private boost::noncopyable
78 private:
80 GenPoEntry* m_pGenPo;
81 bool m_bIsInitialized;
83 public:
85 friend class PoOfstream;
86 friend class PoIfstream;
88 PoHeader( const OString& rExtSrc ); ///< Template Constructor
89 ~PoHeader();
92 /// Interface to write po entry to files as output streams
93 class PoOfstream: private boost::noncopyable
95 private:
97 std::ofstream m_aOutPut;
98 bool m_bIsAfterHeader;
100 public:
102 enum OpenMode { TRUNC, APP };
104 PoOfstream();
105 PoOfstream(const OString& rFileName, OpenMode aMode = TRUNC );
106 ~PoOfstream();
107 bool isOpen() const { return m_aOutPut.is_open(); }
109 void open(const OString& rFileName, OpenMode aMode = TRUNC );
110 void close();
111 void writeHeader(const PoHeader& rHeader);
112 void writeEntry(const PoEntry& rPo);
115 /// Interface to read po entry from files as input streams
116 class PoIfstream: private boost::noncopyable
118 private:
120 std::ifstream m_aInPut;
121 bool m_bEof;
123 public:
125 enum Exception { INVALIDENTRY };
127 PoIfstream();
128 PoIfstream( const OString& rFileName );
129 ~PoIfstream();
130 bool isOpen() const { return m_aInPut.is_open(); }
131 bool eof() const { return m_bEof; }
133 void open(const OString& rFileName);
134 void close();
135 void readEntry(PoEntry& rPo);
138 #endif // INCLUDED_L10NTOOLS_INC_PO_HXX
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */