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"
30 typedef boost::unordered_map
<rtl::OString
, rtl::OString
, rtl::OStringHash
> OStringHashMap
;
39 friend class CfgParser
;
40 friend class CfgExport
;
41 friend class CfgMerge
;
43 rtl::OString sTagType
;
44 rtl::OString sIdentifier
;
48 rtl::OString sTextTag
;
49 rtl::OString sEndTextTag
;
53 CfgStackData(const rtl::OString
&rTag
, const rtl::OString
&rId
)
54 : sTagType( rTag
), sIdentifier( rId
)
57 const rtl::OString
&GetTagType() { return sTagType
; }
58 const rtl::OString
&GetIdentifier() { return sIdentifier
; }
66 typedef std::vector
< CfgStackData
* > CfgStackList
;
77 CfgStackData
*Push(const rtl::OString
&rTag
, const rtl::OString
&rId
);
82 CfgStackData
* temp
= maList
.back();
87 CfgStackData
*GetStackData();
89 rtl::OString
GetAccessPath( size_t nPos
);
91 size_t size() const { return maList
.size(); }
101 rtl::OString sCurrentResTyp
;
102 rtl::OString sCurrentIsoLang
;
103 rtl::OString sCurrentText
;
105 rtl::OString sLastWhitespace
;
108 CfgStackData
*pStackData
;
112 virtual void WorkOnText(
114 const rtl::OString
&rLangIndex
)=0;
116 virtual void WorkOnResourceEnd()=0;
118 virtual void Output(const rtl::OString
& rOutput
)=0;
120 void Error(const rtl::OString
&rError
);
123 int ExecuteAnalyzedToken( int nToken
, char *pToken
);
124 std::vector
<rtl::OString
> aLanguages
;
127 const rtl::OString
&rIsoLang
,
128 const rtl::OString
&rResTyp
);
130 sal_Bool
IsTokenClosed(const rtl::OString
&rToken
);
134 virtual ~CfgParser();
136 int Execute( int nToken
, char * pToken
);
140 // class CfgOutputParser
143 class CfgOutputParser
: public CfgParser
146 std::ofstream pOutputStream
;
148 CfgOutputParser(const rtl::OString
&rOutputFile
);
149 virtual ~CfgOutputParser();
156 class CfgExport
: public CfgOutputParser
161 std::vector
<rtl::OString
> aLanguages
;
163 virtual void WorkOnText(
165 const rtl::OString
&rIsoLang
168 void WorkOnResourceEnd();
169 void Output(const rtl::OString
& rOutput
);
172 const rtl::OString
&rOutputFile
,
173 const rtl::OString
&rProject
,
174 const rtl::OString
&rFilePath
183 class CfgMerge
: public CfgOutputParser
186 MergeDataFile
*pMergeDataFile
;
187 std::vector
<rtl::OString
> aLanguages
;
190 rtl::OString sFilename
;
194 virtual void WorkOnText(rtl::OString
&rText
, const rtl::OString
&rLangIndex
);
196 void WorkOnResourceEnd();
198 void Output(const rtl::OString
& rOutput
);
200 CfgMerge(const rtl::OString
&rMergeSource
,
201 const rtl::OString
&rOutputFile
, const rtl::OString
&rFilename
);
207 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */