1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 #ifndef UDKSERVICE_XML_CDIM_HXX 29 #define UDKSERVICE_XML_CDIM_HXX 30 31 32 #include "xml_cd.hxx" 33 #include <tools/string.hxx> 34 35 36 37 38 39 /** Represents one of the Component descriptions in an XML file. 40 Implements ComponentDescription and does part of the parsing for class CompDescrsFromAnXmlFile. 41 **/ 42 class ComponentDescriptionImpl : public ComponentDescription 43 { 44 public: 45 class ValueList : public std::vector< ByteString > 46 { 47 public: 48 // LIFECYCLE 49 ValueList( 50 E_Tag i_eTag ) 51 : eTag(i_eTag) {} 52 // INQUIRY 53 const char * BeginTag() const; 54 BOOL MatchesEndTag( 55 const char * i_pTextPosition ) const; 56 INT32 EndTagLength() const; 57 58 static const ValueList & 59 Null_(); 60 private: 61 E_Tag eTag; 62 }; 63 64 // LIFECYCLE 65 ComponentDescriptionImpl(); 66 virtual ~ComponentDescriptionImpl(); 67 68 // OPERATIONS 69 ValueList * GetBeginTag( 70 ByteString & o_sValue, 71 const char * & io_pStartOfTag ) const; 72 static void ParseUntilStartOfDescription( 73 const char * & io_pBufferPosition ); 74 static BOOL CheckEndOfDescription( 75 const char * & io_pBufferPosition ); 76 // INQUIRY 77 static INT32 DescriptionEndTagSize(); 78 79 // INTERFACE ComponentDescription 80 // INQUIRY 81 virtual const std::vector< ByteString > & 82 DataOf( /// @return All values of this tag. 83 ComponentDescription::E_Tag 84 i_eTag ) const; 85 virtual ByteString DatumOf( /// @return The only or the first value of this tag. 86 ComponentDescription::E_Tag 87 i_eTag ) const; 88 private: 89 // DATA 90 static const char C_sTagDescription[]; 91 static const char C_sStatus[]; 92 static const char * C_sSubTags[ComponentDescription::tag_MAX]; 93 friend class ValueList; 94 95 std::vector< ValueList* > // Dynamic allocated pointers. 96 aTags; 97 }; 98 99 100 inline BOOL 101 ComponentDescriptionImpl::CheckEndOfDescription( const char * & io_pBufferPosition ) 102 { return strnicmp(io_pBufferPosition + 2, C_sTagDescription, strlen(C_sTagDescription)) == 0 103 && strncmp(io_pBufferPosition, "</", 2) == 0 104 && * (io_pBufferPosition + 2 + strlen(C_sTagDescription)) == '>'; } 105 106 inline INT32 107 ComponentDescriptionImpl::DescriptionEndTagSize() 108 { return strlen(C_sTagDescription) + 3; } 109 110 111 #endif 112 113 114