xref: /AOO41X/main/xml2cmp/source/x2cclass/xml_cdim.hxx (revision dd7bc091be5d2f779fa787352b100cd34d3a1c9c)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef UDKSERVICE_XML_CDIM_HXX
25 #define UDKSERVICE_XML_CDIM_HXX
26 
27 
28 #include "xml_cd.hxx"
29 #include <tools/string.hxx>
30 
31 
32 
33 
34 
35 /** Represents one of the Component descriptions in an XML file.
36     Implements ComponentDescription and does part of the parsing for class CompDescrsFromAnXmlFile.
37 **/
38 class ComponentDescriptionImpl : public ComponentDescription
39 {
40   public:
41     class ValueList : public std::vector< ByteString >
42     {
43       public:
44         // LIFECYCLE
ValueList(E_Tag i_eTag)45                             ValueList(
46                                 E_Tag               i_eTag )
47                                 : eTag(i_eTag) {}
48         // INQUIRY
49         const char *        BeginTag() const;
50         BOOL                MatchesEndTag(
51                                 const char *        i_pTextPosition ) const;
52         INT32               EndTagLength() const;
53 
54         static const ValueList &
55                             Null_();
56       private:
57         E_Tag               eTag;
58     };
59 
60     // LIFECYCLE
61                         ComponentDescriptionImpl();
62     virtual             ~ComponentDescriptionImpl();
63 
64     // OPERATIONS
65     ValueList *         GetBeginTag(
66                             ByteString &            o_sValue,
67                             const char * &          io_pStartOfTag ) const;
68     static void         ParseUntilStartOfDescription(
69                             const char * & io_pBufferPosition );
70     static BOOL         CheckEndOfDescription(
71                             const char * & io_pBufferPosition );
72     // INQUIRY
73     static INT32        DescriptionEndTagSize();
74 
75   // INTERFACE ComponentDescription
76     // INQUIRY
77     virtual const std::vector< ByteString > &
78                         DataOf(                     /// @return All values of this tag.
79                             ComponentDescription::E_Tag
80                                                     i_eTag ) const;
81     virtual ByteString  DatumOf(                    /// @return The only or the first value of this tag.
82                             ComponentDescription::E_Tag
83                                                     i_eTag ) const;
84   private:
85     // DATA
86     static const char   C_sTagDescription[];
87     static const char   C_sStatus[];
88     static const char * C_sSubTags[ComponentDescription::tag_MAX];
89     friend class ValueList;
90 
91     std::vector< ValueList* >       // Dynamic allocated pointers.
92                         aTags;
93 };
94 
95 
96 inline BOOL
CheckEndOfDescription(const char * & io_pBufferPosition)97 ComponentDescriptionImpl::CheckEndOfDescription( const char * & io_pBufferPosition )
98     { return strnicmp(io_pBufferPosition + 2, C_sTagDescription, strlen(C_sTagDescription)) == 0
99              && strncmp(io_pBufferPosition, "</", 2) == 0
100              && * (io_pBufferPosition + 2 + strlen(C_sTagDescription)) == '>'; }
101 
102 inline INT32
DescriptionEndTagSize()103 ComponentDescriptionImpl::DescriptionEndTagSize()
104     { return strlen(C_sTagDescription) + 3; }
105 
106 
107 #endif
108 
109 
110