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>
30 typedef std::unordered_map
<OString
, OString
, OStringHash
> OStringHashMap
;
39 friend class CfgParser
;
40 friend class CfgExport
;
41 friend class CfgMerge
;
53 CfgStackData(const OString
&rTag
, const OString
&rId
)
54 : sTagType( rTag
), sIdentifier( rId
)
57 const OString
&GetTagType() { return sTagType
; }
58 const OString
&GetIdentifier() { 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;
115 static void Error(const OString
&rError
);
118 int ExecuteAnalyzedToken( int nToken
, char *pToken
);
121 const OString
&rIsoLang
,
122 const OString
&rResTyp
);
124 static bool IsTokenClosed(const OString
&rToken
);
128 virtual ~CfgParser();
130 int Execute( int nToken
, char * pToken
);
133 /// Export strings from *.xcu files
134 class CfgExport
: public CfgParser
138 PoOfstream pOutputStream
;
141 virtual void WorkOnText(
143 const OString
&rIsoLang
146 void WorkOnResourceEnd() SAL_OVERRIDE
;
147 void Output(const OString
& rOutput
) SAL_OVERRIDE
;
150 const OString
&rOutputFile
,
151 const OString
&rFilePath
153 virtual ~CfgExport();
156 /// Merge strings to *.xcu files
157 class CfgMerge
: public CfgParser
160 MergeDataFile
*pMergeDataFile
;
161 std::vector
<OString
> aLanguages
;
167 std::ofstream pOutputStream
;
170 virtual void WorkOnText(OString
&rText
, const OString
&rLangIndex
) SAL_OVERRIDE
;
172 void WorkOnResourceEnd() SAL_OVERRIDE
;
174 void Output(const OString
& rOutput
) SAL_OVERRIDE
;
177 const OString
&rMergeSource
, const OString
&rOutputFile
,
178 const OString
&rFilename
, const OString
&rLanguage
);
184 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */