LibreOffice Module l10ntools (master) 1
po.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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 */
9
10#ifndef INCLUDED_L10NTOOLS_INC_PO_HXX
11#define INCLUDED_L10NTOOLS_INC_PO_HXX
12
13#include <fstream>
14#include <memory>
15#include <string_view>
16
17#include <rtl/string.hxx>
18
19class PoOfstream;
20class PoIfstream;
21class GenPoEntry;
22
23
34{
35private:
36
37 std::unique_ptr<GenPoEntry> m_pGenPo;
39
40public:
41
42 friend class PoOfstream;
43 friend class PoIfstream;
44
47
48 PoEntry();
49 PoEntry( std::string_view rSourceFile, std::string_view rResType, std::string_view rGroupId,
50 std::string_view rLocalId, std::string_view rHelpText, const OString& rText,
51 const TYPE eType );
52 ~PoEntry();
53
54 PoEntry( const PoEntry& rPo );
55 PoEntry& operator=( const PoEntry& rPo );
56 PoEntry& operator=( PoEntry&& rPo ) noexcept;
57
58 OString const & getSourceFile() const;
59 OString getGroupId() const;
60 OString getLocalId() const;
61 OString getResourceType() const;
62 TYPE getType() const;
63 OString const & getMsgCtxt() const;
64 OString const & getMsgId() const;
65 OString const & getMsgStr() const;
66 bool isFuzzy() const;
67
69 static bool IsInSameComp(const PoEntry& rPo1,const PoEntry& rPo2);
70 static OString genKeyId(const OString& rGenerator);
71
72};
73
81{
82private:
83
84 std::unique_ptr<GenPoEntry> m_pGenPo;
86
87public:
88
89 friend class PoOfstream;
90 friend class PoIfstream;
91
92 PoHeader( std::string_view rExtSrc );
93 PoHeader( std::string_view rExtSrc, const OString& rPoHeaderMsgStr );
94 ~PoHeader();
95 PoHeader(const PoHeader&) = delete;
96 PoHeader& operator=(const PoHeader&) = delete;
97};
98
101{
102private:
103
104 std::ofstream m_aOutPut;
106
107public:
108
109 enum OpenMode { TRUNC, APP };
110
111 PoOfstream();
112 PoOfstream(const OString& rFileName, OpenMode aMode );
113 ~PoOfstream();
114 PoOfstream(const PoOfstream&) = delete;
115 PoOfstream& operator=(const PoOfstream&) = delete;
116 bool isOpen() const { return m_aOutPut.is_open(); }
117
118 void open(const OString& rFileName, OpenMode aMode = TRUNC );
119 void close();
120 void writeHeader(const PoHeader& rHeader);
121 void writeEntry(const PoEntry& rPo);
122};
123
126{
127private:
128
129 std::ifstream m_aInPut;
130 bool m_bEof;
131
132public:
133
134 class Exception final : public std::exception { };
135
136 PoIfstream();
137 PoIfstream( const OString& rFileName );
138 ~PoIfstream();
139 PoIfstream(const PoIfstream&) = delete;
140 PoIfstream& operator=(const PoIfstream&) = delete;
141 bool isOpen() const { return m_aInPut.is_open(); }
142 bool eof() const { return m_bEof; }
143
144 void open(const OString& rFileName);
145 void open(const OString& rFileName, OString& sPoHeader);
146 void close();
147 void readEntry(PoEntry& rPo);
148};
149
150#endif // INCLUDED_L10NTOOLS_INC_PO_HXX
151
152/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Container of po entry.
Definition: po.cxx:32
Interface to use po entries in localization.
Definition: po.hxx:34
OString const & getMsgId() const
Definition: po.cxx:392
OString const & getMsgCtxt() const
Definition: po.cxx:384
OString getResourceType() const
Get the type of component from which entry is extracted.
Definition: po.cxx:352
OString getGroupId() const
Definition: po.cxx:336
TYPE
Definition: po.hxx:45
@ TQUICKHELPTEXT
Definition: po.hxx:45
@ TTITLE
Definition: po.hxx:45
@ TTEXT
Definition: po.hxx:45
std::unique_ptr< GenPoEntry > m_pGenPo
Definition: po.hxx:37
PoEntry & operator=(const PoEntry &rPo)
Definition: po.cxx:298
OString const & getSourceFile() const
Get name of file from which entry is extracted.
Definition: po.cxx:330
OString const & getMsgStr() const
Definition: po.cxx:399
bool isFuzzy() const
Definition: po.cxx:377
~PoEntry()
Definition: po.cxx:288
bool m_bIsInitialized
Definition: po.hxx:38
static OString genKeyId(const OString &rGenerator)
Definition: po.cxx:415
static bool IsInSameComp(const PoEntry &rPo1, const PoEntry &rPo2)
Check whether po-s belong to the same localization component.
Definition: po.cxx:406
Exception
Definition: po.hxx:46
@ NOSTRING
Definition: po.hxx:46
@ NOGROUPID
Definition: po.hxx:46
@ NOSOURCFILE
Definition: po.hxx:46
@ NORESTYPE
Definition: po.hxx:46
@ WRONGHELPTEXT
Definition: po.hxx:46
PoEntry()
Definition: po.cxx:237
OString getLocalId() const
Definition: po.cxx:342
TYPE getType() const
Get the type of entry.
Definition: po.cxx:362
Interface to work with header of po/pot files.
Definition: po.hxx:81
std::unique_ptr< GenPoEntry > m_pGenPo
Definition: po.hxx:84
PoHeader(const PoHeader &)=delete
~PoHeader()
Definition: po.cxx:475
bool m_bIsInitialized
Definition: po.hxx:85
PoHeader(std::string_view rExtSrc)
Template Constructor.
Definition: po.cxx:454
PoHeader & operator=(const PoHeader &)=delete
Interface to read po entry from files as input streams.
Definition: po.hxx:126
PoIfstream & operator=(const PoIfstream &)=delete
bool eof() const
Definition: po.hxx:142
void open(const OString &rFileName)
Definition: po.cxx:591
~PoIfstream()
Definition: po.cxx:561
bool isOpen() const
Definition: po.hxx:141
void close()
Definition: po.cxx:606
std::ifstream m_aInPut
Definition: po.hxx:129
PoIfstream(const PoIfstream &)=delete
bool m_bEof
Definition: po.hxx:130
void readEntry(PoEntry &rPo)
Definition: po.cxx:612
PoIfstream()
Definition: po.cxx:550
Interface to write po entry to files as output streams.
Definition: po.hxx:101
PoOfstream()
Definition: po.cxx:479
void open(const OString &rFileName, OpenMode aMode=TRUNC)
Definition: po.cxx:498
bool isOpen() const
Definition: po.hxx:116
std::ofstream m_aOutPut
Definition: po.hxx:104
PoOfstream(const PoOfstream &)=delete
bool m_bIsAfterHeader
Definition: po.hxx:105
void writeHeader(const PoHeader &rHeader)
Definition: po.cxx:521
~PoOfstream()
Definition: po.cxx:490
void close()
Definition: po.cxx:515
void writeEntry(const PoEntry &rPo)
Definition: po.cxx:528
OpenMode
Definition: po.hxx:109
@ TRUNC
Definition: po.hxx:109
@ APP
Definition: po.hxx:109
PoOfstream & operator=(const PoOfstream &)=delete