Bump for 4.0-15
[LibreOffice.git] / l10ntools / inc / cfgmerge.hxx
blob316c9dee218143898698becc601cce7bde80fb6a
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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"
25 #include <fstream>
26 #include <vector>
28 #include "boost/unordered_map.hpp"
30 typedef boost::unordered_map<rtl::OString, rtl::OString, rtl::OStringHash> OStringHashMap;
34 // class CfgStackData
37 class CfgStackData
39 friend class CfgParser;
40 friend class CfgExport;
41 friend class CfgMerge;
42 private:
43 rtl::OString sTagType;
44 rtl::OString sIdentifier;
46 rtl::OString sResTyp;
48 rtl::OString sTextTag;
49 rtl::OString sEndTextTag;
51 OStringHashMap sText;
52 public:
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; }
63 // class CfgStack
66 typedef std::vector< CfgStackData* > CfgStackList;
68 class CfgStack
70 private:
71 CfgStackList maList;
73 public:
74 CfgStack() {}
75 ~CfgStack();
77 CfgStackData *Push(const rtl::OString &rTag, const rtl::OString &rId);
78 CfgStackData *Pop()
80 if (maList.empty())
81 return NULL;
82 CfgStackData* temp = maList.back();
83 maList.pop_back();
84 return temp;
87 CfgStackData *GetStackData();
89 rtl::OString GetAccessPath( size_t nPos );
91 size_t size() const { return maList.size(); }
95 // class CfgParser
98 class CfgParser
100 protected:
101 rtl::OString sCurrentResTyp;
102 rtl::OString sCurrentIsoLang;
103 rtl::OString sCurrentText;
105 rtl::OString sLastWhitespace;
107 CfgStack aStack;
108 CfgStackData *pStackData;
110 sal_Bool bLocalize;
112 virtual void WorkOnText(
113 rtl::OString &rText,
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);
122 private:
123 int ExecuteAnalyzedToken( int nToken, char *pToken );
124 std::vector<rtl::OString> aLanguages;
125 void AddText(
126 rtl::OString &rText,
127 const rtl::OString &rIsoLang,
128 const rtl::OString &rResTyp );
130 sal_Bool IsTokenClosed(const rtl::OString &rToken);
132 public:
133 CfgParser();
134 virtual ~CfgParser();
136 int Execute( int nToken, char * pToken );
140 // class CfgOutputParser
143 class CfgOutputParser : public CfgParser
145 protected:
146 std::ofstream pOutputStream;
147 public:
148 CfgOutputParser(const rtl::OString &rOutputFile);
149 virtual ~CfgOutputParser();
153 // class CfgExport
156 class CfgExport : public CfgOutputParser
158 private:
159 rtl::OString sPrj;
160 rtl::OString sPath;
161 std::vector<rtl::OString> aLanguages;
162 protected:
163 virtual void WorkOnText(
164 rtl::OString &rText,
165 const rtl::OString &rIsoLang
168 void WorkOnResourceEnd();
169 void Output(const rtl::OString& rOutput);
170 public:
171 CfgExport(
172 const rtl::OString &rOutputFile,
173 const rtl::OString &rProject,
174 const rtl::OString &rFilePath
176 ~CfgExport();
180 // class CfgMerge
183 class CfgMerge : public CfgOutputParser
185 private:
186 MergeDataFile *pMergeDataFile;
187 std::vector<rtl::OString> aLanguages;
188 ResData *pResData;
190 rtl::OString sFilename;
191 sal_Bool bEnglish;
193 protected:
194 virtual void WorkOnText(rtl::OString &rText, const rtl::OString &rLangIndex);
196 void WorkOnResourceEnd();
198 void Output(const rtl::OString& rOutput);
199 public:
200 CfgMerge(const rtl::OString &rMergeSource,
201 const rtl::OString &rOutputFile, const rtl::OString &rFilename);
202 ~CfgMerge();
205 #endif
207 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */