1*3334a7e6SAndrew Rist /************************************************************** 2*3334a7e6SAndrew Rist * 3*3334a7e6SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*3334a7e6SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*3334a7e6SAndrew Rist * distributed with this work for additional information 6*3334a7e6SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*3334a7e6SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*3334a7e6SAndrew Rist * "License"); you may not use this file except in compliance 9*3334a7e6SAndrew Rist * with the License. You may obtain a copy of the License at 10*3334a7e6SAndrew Rist * 11*3334a7e6SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*3334a7e6SAndrew Rist * 13*3334a7e6SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*3334a7e6SAndrew Rist * software distributed under the License is distributed on an 15*3334a7e6SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*3334a7e6SAndrew Rist * KIND, either express or implied. See the License for the 17*3334a7e6SAndrew Rist * specific language governing permissions and limitations 18*3334a7e6SAndrew Rist * under the License. 19*3334a7e6SAndrew Rist * 20*3334a7e6SAndrew Rist *************************************************************/ 21*3334a7e6SAndrew Rist 22cdf0e10cSrcweir #ifndef _XMLCONFIG_HXX_ 23cdf0e10cSrcweir #define _XMLCONFIG_HXX_ 24cdf0e10cSrcweir 25cdf0e10cSrcweir #include <map> 26cdf0e10cSrcweir #include <list> 27cdf0e10cSrcweir #include <boost/shared_ptr.hpp> 28cdf0e10cSrcweir 29cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 30cdf0e10cSrcweir 31cdf0e10cSrcweir enum ElementConfigType { ECT_HEXDUMP, ECT_BYTE, ECT_UINT, ECT_UNISTRING, ETC_FLOAT, ETC_CONTAINER }; 32cdf0e10cSrcweir 33cdf0e10cSrcweir class ElementConfig 34cdf0e10cSrcweir { 35cdf0e10cSrcweir public: ElementConfig()36cdf0e10cSrcweir ElementConfig() : mnType( ECT_HEXDUMP ) {} ElementConfig(const rtl::OUString & rName,ElementConfigType rType)37cdf0e10cSrcweir ElementConfig( const rtl::OUString& rName, ElementConfigType rType ) : maName( rName ), mnType( rType ) {} ElementConfig(const rtl::OUString & rName)38cdf0e10cSrcweir ElementConfig( const rtl::OUString& rName ) : maName( rName ) {} ElementConfig(ElementConfigType rType)39cdf0e10cSrcweir ElementConfig( ElementConfigType rType ) : mnType( rType ) {} 40cdf0e10cSrcweir 41cdf0e10cSrcweir virtual rtl::OUString format( SvStream& rStream, sal_Size& nLength ) const; 42cdf0e10cSrcweir getName() const43cdf0e10cSrcweir const rtl::OUString& getName() const { return maName; } getType() const44cdf0e10cSrcweir ElementConfigType getType() const { return mnType; } 45cdf0e10cSrcweir 46cdf0e10cSrcweir static rtl::OUString dump_hex( SvStream& rStream, sal_Size& nLength ); 47cdf0e10cSrcweir static rtl::OUString dump_byte( SvStream& rStream, sal_Size& nLength ); 48cdf0e10cSrcweir static rtl::OUString dump_uint( SvStream& rStream, sal_Size& nLength ); 49cdf0e10cSrcweir static rtl::OUString dump_unistring( SvStream& rStream, sal_Size& nLength ); 50cdf0e10cSrcweir static rtl::OUString dump_float( SvStream& rStream, sal_Size& nLength ); 51cdf0e10cSrcweir private: 52cdf0e10cSrcweir rtl::OUString maName; 53cdf0e10cSrcweir ElementConfigType mnType; 54cdf0e10cSrcweir }; 55cdf0e10cSrcweir typedef boost::shared_ptr< ElementConfig > ElementConfigPtr; 56cdf0e10cSrcweir typedef std::list< ElementConfigPtr > ElementConfigList; 57cdf0e10cSrcweir 58cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 59cdf0e10cSrcweir 60cdf0e10cSrcweir class ElementValueConfig : public ElementConfig 61cdf0e10cSrcweir { 62cdf0e10cSrcweir public: ElementValueConfig(const rtl::OUString & rName,const rtl::OUString & rValue)63cdf0e10cSrcweir ElementValueConfig( const rtl::OUString& rName, const rtl::OUString& rValue ) : ElementConfig( rName ), maValue( rValue ) {} 64cdf0e10cSrcweir getValue() const65cdf0e10cSrcweir const rtl::OUString& getValue() const { return maValue; } 66cdf0e10cSrcweir 67cdf0e10cSrcweir private: 68cdf0e10cSrcweir rtl::OUString maValue; 69cdf0e10cSrcweir }; 70cdf0e10cSrcweir 71cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 72cdf0e10cSrcweir 73cdf0e10cSrcweir class ElementConfigContainer : public ElementConfig 74cdf0e10cSrcweir { 75cdf0e10cSrcweir public: ElementConfigContainer()76cdf0e10cSrcweir ElementConfigContainer() : ElementConfig( ETC_CONTAINER ) {} ElementConfigContainer(const::rtl::OUString & rName,ElementConfigType rType)77cdf0e10cSrcweir ElementConfigContainer( const ::rtl::OUString& rName, ElementConfigType rType ) : ElementConfig( rName, rType ) {} ElementConfigContainer(const::rtl::OUString & rName)78cdf0e10cSrcweir ElementConfigContainer( const ::rtl::OUString& rName ) : ElementConfig( rName, ETC_CONTAINER ) {} ElementConfigContainer(ElementConfigType rType)79cdf0e10cSrcweir ElementConfigContainer( ElementConfigType rType ) : ElementConfig( rType ) {} 80cdf0e10cSrcweir 81cdf0e10cSrcweir virtual rtl::OUString format( SvStream& rStream, sal_Size& nLength ) const; 82cdf0e10cSrcweir addElementConfig(ElementConfigPtr p)83cdf0e10cSrcweir void addElementConfig( ElementConfigPtr p ) { maElementConfigList.push_back( p ); } 84cdf0e10cSrcweir 85cdf0e10cSrcweir protected: 86cdf0e10cSrcweir ElementConfigList maElementConfigList; 87cdf0e10cSrcweir }; 88cdf0e10cSrcweir 89cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 90cdf0e10cSrcweir 91cdf0e10cSrcweir class CaseElementConfig : public ElementConfigContainer 92cdf0e10cSrcweir { 93cdf0e10cSrcweir public: CaseElementConfig(const rtl::OUString & rValue)94cdf0e10cSrcweir CaseElementConfig( const rtl::OUString& rValue ) : maValue( rValue ) {} 95cdf0e10cSrcweir getValue() const96cdf0e10cSrcweir const rtl::OUString& getValue() const { return maValue; } 97cdf0e10cSrcweir 98cdf0e10cSrcweir private: 99cdf0e10cSrcweir rtl::OUString maValue; 100cdf0e10cSrcweir }; 101cdf0e10cSrcweir 102cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 103cdf0e10cSrcweir 104cdf0e10cSrcweir class SwitchElementConfig : public ElementConfigContainer 105cdf0e10cSrcweir { 106cdf0e10cSrcweir public: SwitchElementConfig(ElementConfigType rType)107cdf0e10cSrcweir SwitchElementConfig( ElementConfigType rType ) : ElementConfigContainer( rType ) {} 108cdf0e10cSrcweir 109cdf0e10cSrcweir virtual rtl::OUString format( SvStream& rStream, sal_Size& nLength ) const; 110cdf0e10cSrcweir }; 111cdf0e10cSrcweir 112cdf0e10cSrcweir /////////////////////////////////////////////////////////////////////// 113cdf0e10cSrcweir 114cdf0e10cSrcweir class AtomConfig : public ElementConfigContainer 115cdf0e10cSrcweir { 116cdf0e10cSrcweir public: AtomConfig(const::rtl::OUString & rName,bool bIsContainer)117cdf0e10cSrcweir AtomConfig( const ::rtl::OUString& rName, bool bIsContainer ) : ElementConfigContainer( rName ), mbIsContainer( bIsContainer ) {} 118cdf0e10cSrcweir isContainer() const119cdf0e10cSrcweir bool isContainer() const { return mbIsContainer; } 120cdf0e10cSrcweir 121cdf0e10cSrcweir protected: 122cdf0e10cSrcweir bool mbIsContainer; 123cdf0e10cSrcweir }; 124cdf0e10cSrcweir 125cdf0e10cSrcweir typedef std::map< UINT16, ElementConfigPtr > AtomConfigMap; 126cdf0e10cSrcweir 127cdf0e10cSrcweir extern AtomConfigMap gAtomConfigMap; 128cdf0e10cSrcweir 129cdf0e10cSrcweir #endif 130