source: icXML/icXML-devel/src/icxercesc/framework/XMLElementDecl.cpp @ 3103

Last change on this file since 3103 was 3103, checked in by cameron, 6 years ago

Initial imports for icXML v0.9

File size: 4.5 KB
Line 
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *      http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/**
19 * $Id: XMLElementDecl.cpp 679359 2008-07-24 11:15:19Z borisk $
20 */
21
22
23// ---------------------------------------------------------------------------
24//  Includes
25// ---------------------------------------------------------------------------
26#include <icxercesc/framework/XMLElementDecl.hpp>
27#include <xercesc/util/XMLUniDefs.hpp>
28#include <xercesc/util/XMLUni.hpp>
29#include <xercesc/validators/schema/SchemaElementDecl.hpp>
30#include <icxercesc/validators/DTD/DTDElementDecl.hpp>
31#include <icxmlc/XMLConfig.hpp>
32
33XERCES_CPP_NAMESPACE_BEGIN
34
35// ---------------------------------------------------------------------------
36//  XMLElementDecl: Public, static data
37// ---------------------------------------------------------------------------
38const unsigned int  XMLElementDecl::fgInvalidElemId    = 0xFFFFFFFE;
39const unsigned int  XMLElementDecl::fgPCDataElemId     = 0xFFFFFFFF;
40const XMLCh         XMLElementDecl::fgPCDataElemName[] =
41{
42                chPound, chLatin_P, chLatin_C, chLatin_D, chLatin_A
43        ,   chLatin_T, chLatin_A, chNull
44};
45
46
47
48// ---------------------------------------------------------------------------
49//  XMLElementDecl: Destructor
50// ---------------------------------------------------------------------------
51XMLElementDecl::~XMLElementDecl()
52{
53    if (fElementName) delete fElementName;
54}
55
56// ---------------------------------------------------------------------------
57//  XMLElementDecl: Setter Methods
58// ---------------------------------------------------------------------------
59void
60XMLElementDecl::setElementName(const XMLCh* const       prefix
61                                                        , const XMLCh* const        localPart
62                                                        , const int                 uriId )
63{
64        fElementName = new (fMemoryManager) QName(prefix, localPart, uriId, fMemoryManager);
65        fUriId = uriId;
66}
67
68void
69XMLElementDecl::setElementName(const XMLCh* const       rawName
70                                                        , const int                 uriId )
71{
72        fElementName = new (fMemoryManager) QName(rawName, uriId, fMemoryManager);
73        fUriId = uriId;
74}
75
76void
77XMLElementDecl::setElementName(const QName* const elementName)
78{
79        fElementName = const_cast<QName*>(elementName);
80        fUriId = elementName->getURI();
81}
82
83// ---------------------------------------------------------------------------
84//  ElementDecl: Hidden constructors
85// ---------------------------------------------------------------------------
86XMLElementDecl::XMLElementDecl(MemoryManager* const manager) :
87
88        fMemoryManager(manager)
89        , fElementName(0)
90        , fCreateReason(XMLElementDecl::NoReason)
91        , fId(XMLElementDecl::fgInvalidElemId)
92        , fExternalElement(false)
93{
94
95}
96
97/***
98 * Support for Serialization/De-serialization
99 ***/
100
101IMPL_XSERIALIZABLE_NOCREATE(XMLElementDecl)
102
103void XMLElementDecl::serialize(XSerializeEngine& serEng)
104{
105#if 0
106        if (serEng.isStoring())
107        {
108                serEng<<fElementName;
109                serEng<<(int) fCreateReason;
110                serEng.writeSize (fId);
111                serEng<<fExternalElement;
112        }
113        else
114        {
115                serEng>>fElementName;
116
117                int i;
118                serEng>>i;
119                fCreateReason=(CreateReasons)i;
120
121                serEng.readSize (fId);
122                serEng>>fExternalElement;
123        }
124#else
125        DEPRECATED_FEATURE_IN_ICXML;
126#endif
127}
128
129void
130XMLElementDecl::storeElementDecl(XSerializeEngine&        serEng
131                                                           , XMLElementDecl*    const element)
132{
133#if 0
134        if (element)
135        {
136                serEng<<(int) element->getObjectType();
137                serEng<<element;
138        }
139        else
140        {
141                serEng<<(int) UnKnown;
142        }
143#else
144        DEPRECATED_FEATURE_IN_ICXML;
145#endif
146}
147
148XMLElementDecl*
149XMLElementDecl::loadElementDecl(XSerializeEngine& serEng)
150{
151#if 0
152        int type;
153        serEng>>type;
154
155        switch((XMLElementDecl::objectType)type)
156        {
157          case Schema:
158                  SchemaElementDecl* schemaElementDecl;
159                  serEng>>schemaElementDecl;
160                  return schemaElementDecl;
161          case DTD:
162                  DTDElementDecl* dtdElementDecl;
163                  serEng>>dtdElementDecl;
164                  return dtdElementDecl;
165          case UnKnown:
166                   //fall through
167          default:
168                  return 0;
169        }
170#else
171        DEPRECATED_FEATURE_IN_ICXML;
172#endif
173}
174
175XERCES_CPP_NAMESPACE_END
Note: See TracBrowser for help on using the repository browser.