1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cfgmerge.hxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CFG_MERGE_HXX
32 #define _CFG_MERGE_HXX
34 #include <tools/string.hxx>
35 #include <tools/list.hxx>
38 typedef std::hash_map
<ByteString
, ByteString
, hashByteString
,equalByteString
>
48 friend class CfgParser
;
49 friend class CfgExport
;
50 friend class CfgMerge
;
53 ByteString sIdentifier
;
58 ByteString sEndTextTag
;
60 ByteStringHashMap sText
;
62 CfgStackData( const ByteString
&rTag
, const ByteString
&rId
)
63 : sTagType( rTag
), sIdentifier( rId
) {};
65 ByteString
&GetTagType() { return sTagType
; }
66 ByteString
&GetIdentifier() { return sIdentifier
; }
74 DECLARE_LIST( CfgStackList
, CfgStackData
* )
76 class CfgStack
: public CfgStackList
79 CfgStack() : CfgStackList( 10, 10 ) {}
82 ULONG
Push( CfgStackData
*pStackData
);
83 CfgStackData
*Push( const ByteString
&rTag
, const ByteString
&rId
);
84 CfgStackData
*Pop() { return Remove( Count() - 1 ); }
86 CfgStackData
*GetStackData( ULONG nPos
= LIST_APPEND
);
88 ByteString
GetAccessPath( ULONG nPos
= LIST_APPEND
);
98 ByteString sCurrentResTyp
;
99 ByteString sCurrentIsoLang
;
100 ByteString sCurrentText
;
102 ByteString sLastWhitespace
;
105 CfgStackData
*pStackData
;
109 virtual void WorkOnText(
111 const ByteString
&nLangIndex
)=0;
113 virtual void WorkOnRessourceEnd()=0;
115 virtual void Output( const ByteString
& rOutput
)=0;
117 void Error( const ByteString
&rError
);
120 int ExecuteAnalyzedToken( int nToken
, char *pToken
);
121 std::vector
<ByteString
> aLanguages
;
124 const ByteString
&rIsoLang
,
125 const ByteString
&rResTyp
);
127 BOOL
IsTokenClosed( const ByteString
&rToken
);
131 virtual ~CfgParser();
133 int Execute( int nToken
, char * pToken
);
137 // class CfgOutputParser
140 class CfgOutputParser
: public CfgParser
143 SvFileStream
*pOutputStream
;
145 CfgOutputParser ( const ByteString
&rOutputFile
);
146 virtual ~CfgOutputParser();
153 class CfgExport
: public CfgOutputParser
158 std::vector
<ByteString
> aLanguages
;
162 const ByteString
&rIsoLang
165 void WorkOnRessourceEnd();
166 void Output( const ByteString
& rOutput
);
169 const ByteString
&rOutputFile
,
170 const ByteString
&rProject
,
171 const ByteString
&rFilePath
180 class CfgMerge
: public CfgOutputParser
183 MergeDataFile
*pMergeDataFile
;
184 std::vector
<ByteString
> aLanguages
;
188 ByteString sFilename
;
194 const ByteString
&nLangIndex
);
196 void WorkOnRessourceEnd();
198 void Output( const ByteString
& rOutput
);
201 const ByteString
&rMergeSource
,
202 const ByteString
&rOutputFile
,
203 ByteString
&rFilename