1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_L10NTOOLS_INC_CFGMERGE_HXX
21 #define INCLUDED_L10NTOOLS_INC_CFGMERGE_HXX
23 #include <sal/config.h>
26 #include <unordered_map>
33 typedef std::unordered_map
<OString
, OString
> OStringHashMap
;
40 friend class CfgParser
;
41 friend class CfgExport
;
42 friend class CfgMerge
;
54 CfgStackData(OString _sTag
, OString _sId
)
55 : sTagType(std::move( _sTag
)), sIdentifier(std::move( _sId
))
58 const OString
&GetTagType() const { return sTagType
; }
59 const OString
&GetIdentifier() const { return sIdentifier
; }
69 std::vector
< CfgStackData
* > maList
;
75 CfgStackData
*Push(const OString
&rTag
, const OString
&rId
);
85 CfgStackData
*GetStackData();
87 OString
GetAccessPath( size_t nPos
);
89 size_t size() const { return maList
.size(); }
92 /// Parser for *.xcu files
96 OString sCurrentResTyp
;
97 OString sCurrentIsoLang
;
100 OString sLastWhitespace
;
103 CfgStackData
*pStackData
;
107 virtual void WorkOnText(
109 const OString
&rLangIndex
)=0;
111 virtual void WorkOnResourceEnd()=0;
113 virtual void Output(const OString
& rOutput
)=0;
116 void ExecuteAnalyzedToken( int nToken
, char *pToken
);
119 const OString
&rIsoLang
,
120 const OString
&rResTyp
);
122 static bool IsTokenClosed(std::string_view rToken
);
126 virtual ~CfgParser();
128 void Execute( int nToken
, char * pToken
);
131 /// Export strings from *.xcu files
132 class CfgExport
: public CfgParser
136 PoOfstream pOutputStream
;
139 virtual void WorkOnText(
141 const OString
&rIsoLang
144 void WorkOnResourceEnd() override
;
145 void Output(const OString
& rOutput
) override
;
148 const OString
&rOutputFile
,
151 virtual ~CfgExport() override
;
154 /// Merge strings to *.xcu files
155 class CfgMerge
: public CfgParser
158 std::unique_ptr
<MergeDataFile
> pMergeDataFile
;
159 std::vector
<OString
> aLanguages
;
160 std::unique_ptr
<ResData
> pResData
;
165 std::ofstream pOutputStream
;
168 virtual void WorkOnText(OString
&rText
, const OString
&rLangIndex
) override
;
170 void WorkOnResourceEnd() override
;
172 void Output(const OString
& rOutput
) override
;
175 const OString
&rMergeSource
, const OString
&rOutputFile
,
176 OString sFilename
, const OString
&rLanguage
);
177 virtual ~CfgMerge() override
;
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */