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