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 _CFG_MERGE_HXX
21 #define _CFG_MERGE_HXX
23 #include "sal/config.h"
28 #include "boost/unordered_map.hpp"
31 typedef boost::unordered_map
<OString
, OString
, OStringHash
> OStringHashMap
;
40 friend class CfgParser
;
41 friend class CfgExport
;
42 friend class CfgMerge
;
54 CfgStackData(const OString
&rTag
, const OString
&rId
)
55 : sTagType( rTag
), sIdentifier( rId
)
58 const OString
&GetTagType() { return sTagType
; }
59 const OString
&GetIdentifier() { return sIdentifier
; }
70 std::vector
< CfgStackData
* > maList
;
76 CfgStackData
*Push(const OString
&rTag
, const OString
&rId
);
81 CfgStackData
* temp
= maList
.back();
86 CfgStackData
*GetStackData();
88 OString
GetAccessPath( size_t nPos
);
90 size_t size() const { return maList
.size(); }
93 /// Parser for *.xcu files
97 OString sCurrentResTyp
;
98 OString sCurrentIsoLang
;
101 OString sLastWhitespace
;
104 CfgStackData
*pStackData
;
108 virtual void WorkOnText(
110 const OString
&rLangIndex
)=0;
112 virtual void WorkOnResourceEnd()=0;
114 virtual void Output(const OString
& rOutput
)=0;
116 void Error(const OString
&rError
);
119 int ExecuteAnalyzedToken( int nToken
, char *pToken
);
122 const OString
&rIsoLang
,
123 const OString
&rResTyp
);
125 sal_Bool
IsTokenClosed(const OString
&rToken
);
129 virtual ~CfgParser();
131 int Execute( int nToken
, char * pToken
);
134 /// Export strings from *.xcu files
135 class CfgExport
: public CfgParser
139 PoOfstream pOutputStream
;
142 virtual void WorkOnText(
144 const OString
&rIsoLang
147 void WorkOnResourceEnd();
148 void Output(const OString
& rOutput
);
151 const OString
&rOutputFile
,
152 const OString
&rFilePath
157 /// Merge strings to *.xcu files
158 class CfgMerge
: public CfgParser
161 MergeDataFile
*pMergeDataFile
;
162 std::vector
<OString
> aLanguages
;
168 std::ofstream pOutputStream
;
171 virtual void WorkOnText(OString
&rText
, const OString
&rLangIndex
);
173 void WorkOnResourceEnd();
175 void Output(const OString
& rOutput
);
178 const OString
&rMergeSource
, const OString
&rOutputFile
,
179 const OString
&rFilename
, const OString
&rLanguage
);
185 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */