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>
31 typedef std::unordered_map
<OString
, OString
> OStringHashMap
;
38 friend class CfgParser
;
39 friend class CfgExport
;
40 friend class CfgMerge
;
52 CfgStackData(const OString
&rTag
, const OString
&rId
)
53 : sTagType( rTag
), sIdentifier( rId
)
56 const OString
&GetTagType() const { return sTagType
; }
57 const OString
&GetIdentifier() const { return sIdentifier
; }
67 std::vector
< CfgStackData
* > maList
;
73 CfgStackData
*Push(const OString
&rTag
, const OString
&rId
);
83 CfgStackData
*GetStackData();
85 OString
GetAccessPath( size_t nPos
);
87 size_t size() const { return maList
.size(); }
90 /// Parser for *.xcu files
94 OString sCurrentResTyp
;
95 OString sCurrentIsoLang
;
98 OString sLastWhitespace
;
101 CfgStackData
*pStackData
;
105 virtual void WorkOnText(
107 const OString
&rLangIndex
)=0;
109 virtual void WorkOnResourceEnd()=0;
111 virtual void Output(const OString
& rOutput
)=0;
114 void ExecuteAnalyzedToken( int nToken
, char *pToken
);
117 const OString
&rIsoLang
,
118 const OString
&rResTyp
);
120 static bool IsTokenClosed(const OString
&rToken
);
124 virtual ~CfgParser();
126 void Execute( int nToken
, char * pToken
);
129 /// Export strings from *.xcu files
130 class CfgExport
: public CfgParser
134 PoOfstream pOutputStream
;
137 virtual void WorkOnText(
139 const OString
&rIsoLang
142 void WorkOnResourceEnd() override
;
143 void Output(const OString
& rOutput
) override
;
146 const OString
&rOutputFile
,
147 const OString
&rFilePath
149 virtual ~CfgExport() override
;
152 /// Merge strings to *.xcu files
153 class CfgMerge
: public CfgParser
156 std::unique_ptr
<MergeDataFile
> pMergeDataFile
;
157 std::vector
<OString
> aLanguages
;
158 std::unique_ptr
<ResData
> pResData
;
163 std::ofstream pOutputStream
;
166 virtual void WorkOnText(OString
&rText
, const OString
&rLangIndex
) override
;
168 void WorkOnResourceEnd() override
;
170 void Output(const OString
& rOutput
) override
;
173 const OString
&rMergeSource
, const OString
&rOutputFile
,
174 const OString
&rFilename
, const OString
&rLanguage
);
175 virtual ~CfgMerge() override
;
180 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */