LibreOffice Module l10ntools (master) 1
xrmmerge.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 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#ifndef INCLUDED_L10NTOOLS_INC_XRMMERGE_HXX
21#define INCLUDED_L10NTOOLS_INC_XRMMERGE_HXX
22
23#include <memory>
24#include <sal/config.h>
25
26#include <fstream>
27#include <string_view>
28
29#include <rtl/string.hxx>
30
31#include "export.hxx"
32#include "po.hxx"
33
36{
37private:
38 OString sGID;
39
40 bool bError;
41 bool bText;
42
45 OString sCurrentText;
46protected:
47 static OString GetAttribute( const OString &rToken, std::string_view rAttribute );
48 static void Error( const OString &rError );
49
50 virtual void Output( const OString& rOutput )=0;
51 virtual void WorkOnDesc(
52 const OString &rOpenTag,
53 OString &rText
54 )=0;
55 virtual void WorkOnText(
56 const OString &rOpenTag,
57 OString &rText
58 )=0;
59 virtual void EndOfText(
60 const OString &rOpenTag,
61 const OString &rCloseTag
62 )=0;
63
64 const OString& GetGID() const { return sGID; }
65
66public:
68 virtual ~XRMResParser();
69
70 void Execute( int nToken, char * pToken );
71
72 void SetError() { bError = true; }
73 bool GetError() const { return bError; }
74};
75
76
78class XRMResExport final : public XRMResParser
79{
80private:
81 std::unique_ptr<ResData> pResData;
82 OString sPath;
84
85 void WorkOnDesc(
86 const OString &rOpenTag,
87 OString &rText
88 ) override;
89 void WorkOnText(
90 const OString &rOpenTag,
91 OString &rText
92 ) override;
93 void EndOfText(
94 const OString &rOpenTag,
95 const OString &rCloseTag
96 ) override;
97 void Output( const OString& rOutput ) override;
98
99public:
101 const OString &rOutputFile,
102 OString sFilePath
103 );
104 virtual ~XRMResExport() override;
105};
106
107
109class XRMResMerge final : public XRMResParser
110{
111private:
112 std::unique_ptr<MergeDataFile> pMergeDataFile;
113 OString sFilename;
114 std::unique_ptr<ResData> pResData;
115 std::ofstream pOutputStream;
116 std::vector<OString> aLanguages;
117
118 void WorkOnDesc(
119 const OString &rOpenTag,
120 OString &rText
121 ) override;
122 void WorkOnText(
123 const OString &rOpenTag,
124 OString &rText
125 ) override;
126 void EndOfText(
127 const OString &rOpenTag,
128 const OString &rCloseTag
129 ) override;
130 void Output( const OString& rOutput ) override;
131public:
133 const OString &rMergeSource,
134 const OString &rOutputFile,
135 OString sFilename
136 );
137 virtual ~XRMResMerge() override;
138};
139
140#endif // INCLUDED_L10NTOOLS_INC_XRMMERGE_HXX
141
142/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Interface to write po entry to files as output streams.
Definition: po.hxx:101
Export strings from *.xrm and description.xml files.
Definition: xrmmerge.hxx:79
XRMResExport(const OString &rOutputFile, OString sFilePath)
Definition: xrmmerge.cxx:278
void WorkOnDesc(const OString &rOpenTag, OString &rText) override
Definition: xrmmerge.cxx:296
void EndOfText(const OString &rOpenTag, const OString &rCloseTag) override
Definition: xrmmerge.cxx:329
OString sPath
Definition: xrmmerge.hxx:82
void Output(const OString &rOutput) override
Definition: xrmmerge.cxx:294
std::unique_ptr< ResData > pResData
Definition: xrmmerge.hxx:81
void WorkOnText(const OString &rOpenTag, OString &rText) override
Definition: xrmmerge.cxx:316
PoOfstream pOutputStream
Definition: xrmmerge.hxx:83
virtual ~XRMResExport() override
Definition: xrmmerge.cxx:289
Merge strings to *.xrm and description.xml files.
Definition: xrmmerge.hxx:110
void Output(const OString &rOutput) override
Definition: xrmmerge.cxx:447
std::vector< OString > aLanguages
Definition: xrmmerge.hxx:116
void WorkOnDesc(const OString &rOpenTag, OString &rText) override
Definition: xrmmerge.cxx:373
std::unique_ptr< MergeDataFile > pMergeDataFile
Definition: xrmmerge.hxx:112
std::ofstream pOutputStream
Definition: xrmmerge.hxx:115
void WorkOnText(const OString &rOpenTag, OString &rText) override
Definition: xrmmerge.cxx:437
void EndOfText(const OString &rOpenTag, const OString &rCloseTag) override
Definition: xrmmerge.cxx:453
virtual ~XRMResMerge() override
Definition: xrmmerge.cxx:368
OString sFilename
Definition: xrmmerge.hxx:113
XRMResMerge(const OString &rMergeSource, const OString &rOutputFile, OString sFilename)
Definition: xrmmerge.cxx:348
std::unique_ptr< ResData > pResData
Definition: xrmmerge.hxx:114
Parser for *.xrm and description.xml files.
Definition: xrmmerge.hxx:36
void SetError()
Definition: xrmmerge.hxx:72
bool GetError() const
Definition: xrmmerge.hxx:73
virtual void EndOfText(const OString &rOpenTag, const OString &rCloseTag)=0
virtual void WorkOnDesc(const OString &rOpenTag, OString &rText)=0
OString sGID
Definition: xrmmerge.hxx:38
OString sCurrentCloseTag
Definition: xrmmerge.hxx:44
static void Error(const OString &rError)
Definition: xrmmerge.cxx:270
const OString & GetGID() const
Definition: xrmmerge.hxx:64
static OString GetAttribute(const OString &rToken, std::string_view rAttribute)
Definition: xrmmerge.cxx:257
OString sCurrentText
Definition: xrmmerge.hxx:45
virtual void WorkOnText(const OString &rOpenTag, OString &rText)=0
virtual ~XRMResParser()
Definition: xrmmerge.cxx:147
virtual void Output(const OString &rOutput)=0
void Execute(int nToken, char *pToken)
Definition: xrmmerge.cxx:151
OString sCurrentOpenTag
Definition: xrmmerge.hxx:43