Version 3.4.2.3, tag libreoffice-3.4.2.3 (3.4.2-rc3)
[LibreOffice.git] / l10ntools / inc / cfgmerge.hxx
blob9308d0c727a86bc6d3e69f42012df71782c2bfeb
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #ifndef _CFG_MERGE_HXX
30 #define _CFG_MERGE_HXX
32 #include <tools/string.hxx>
33 #include <boost/unordered_map.hpp>
34 #include <vector>
36 typedef boost::unordered_map<ByteString , ByteString , hashByteString,equalByteString>
37 ByteStringHashMap;
41 // class CfgStackData
44 class CfgStackData
46 friend class CfgParser;
47 friend class CfgExport;
48 friend class CfgMerge;
49 private:
50 ByteString sTagType;
51 ByteString sIdentifier;
53 ByteString sResTyp;
55 ByteString sTextTag;
56 ByteString sEndTextTag;
58 ByteStringHashMap sText;
59 public:
60 CfgStackData( const ByteString &rTag, const ByteString &rId )
61 : sTagType( rTag ), sIdentifier( rId ) {};
63 ByteString &GetTagType() { return sTagType; }
64 ByteString &GetIdentifier() { return sIdentifier; }
69 // class CfgStack
72 typedef ::std::vector< CfgStackData* > CfgStackList;
74 class CfgStack
76 private:
77 CfgStackList maList;
79 public:
80 CfgStack() {}
81 ~CfgStack();
83 size_t Push( CfgStackData *pStackData );
84 CfgStackData *Push( const ByteString &rTag, const ByteString &rId );
85 CfgStackData *Pop()
87 if ( maList.empty() ) return NULL;
88 CfgStackData* temp = maList.back();
89 maList.pop_back();
90 return temp;
93 CfgStackData *GetStackData( size_t nPos = LIST_APPEND );
95 ByteString GetAccessPath( size_t nPos = LIST_APPEND );
97 size_t size() const { return maList.size(); }
101 // class CfgParser
104 class CfgParser
106 protected:
107 ByteString sCurrentResTyp;
108 ByteString sCurrentIsoLang;
109 ByteString sCurrentText;
111 ByteString sLastWhitespace;
113 CfgStack aStack;
114 CfgStackData *pStackData;
116 sal_Bool bLocalize;
118 virtual void WorkOnText(
119 ByteString &rText,
120 const ByteString &nLangIndex )=0;
122 virtual void WorkOnRessourceEnd()=0;
124 virtual void Output( const ByteString& rOutput )=0;
126 void Error( const ByteString &rError );
128 private:
129 int ExecuteAnalyzedToken( int nToken, char *pToken );
130 std::vector<ByteString> aLanguages;
131 void AddText(
132 ByteString &rText,
133 const ByteString &rIsoLang,
134 const ByteString &rResTyp );
136 sal_Bool IsTokenClosed( const ByteString &rToken );
138 public:
139 CfgParser();
140 virtual ~CfgParser();
142 int Execute( int nToken, char * pToken );
146 // class CfgOutputParser
149 class CfgOutputParser : public CfgParser
151 protected:
152 SvFileStream *pOutputStream;
153 public:
154 CfgOutputParser ( const ByteString &rOutputFile );
155 virtual ~CfgOutputParser();
159 // class CfgExport
162 class CfgExport : public CfgOutputParser
164 private:
165 ByteString sPrj;
166 ByteString sPath;
167 std::vector<ByteString> aLanguages;
168 protected:
169 void WorkOnText(
170 ByteString &rText,
171 const ByteString &rIsoLang
174 void WorkOnRessourceEnd();
175 void Output( const ByteString& rOutput );
176 public:
177 CfgExport(
178 const ByteString &rOutputFile,
179 const ByteString &rProject,
180 const ByteString &rFilePath
182 ~CfgExport();
186 // class CfgMerge
189 class CfgMerge : public CfgOutputParser
191 private:
192 MergeDataFile *pMergeDataFile;
193 std::vector<ByteString> aLanguages;
194 ResData *pResData;
196 ByteString sFilename;
197 sal_Bool bEnglish;
199 protected:
200 void WorkOnText(
201 ByteString &rText,
202 const ByteString &nLangIndex );
204 void WorkOnRessourceEnd();
206 void Output( const ByteString& rOutput );
207 public:
208 CfgMerge(
209 const ByteString &rMergeSource,
210 const ByteString &rOutputFile,
211 ByteString &rFilename
213 ~CfgMerge();
216 #endif
218 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */