GME  13
XercesGroupInfo.cpp
Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  * 
00009  *      http://www.apache.org/licenses/LICENSE-2.0
00010  * 
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 /*
00019  * $Id: XercesGroupInfo.cpp 471747 2006-11-06 14:31:56Z amassari $
00020  */
00021 
00022 // ---------------------------------------------------------------------------
00023 //  Includes
00024 // ---------------------------------------------------------------------------
00025 #include <xercesc/validators/schema/XercesGroupInfo.hpp>
00026 #include <xercesc/validators/common/ContentSpecNode.hpp>
00027 #include <xercesc/validators/schema/XSDLocator.hpp>
00028 
00029 #include <xercesc/internal/XTemplateSerializer.hpp>
00030 
00031 XERCES_CPP_NAMESPACE_BEGIN
00032 
00033 // ---------------------------------------------------------------------------
00034 //  XercesGroupInfo: Constructors and Destructor
00035 // ---------------------------------------------------------------------------
00036 XercesGroupInfo::XercesGroupInfo(MemoryManager* const manager)
00037     : fCheckElementConsistency(true)
00038     , fScope(Grammar::TOP_LEVEL_SCOPE)
00039     , fNameId(0)
00040     , fNamespaceId(0)
00041     , fContentSpec(0)
00042     , fElements(0)
00043     , fBaseGroup(0)
00044     , fLocator(0)
00045 {
00046     fElements = new (manager) RefVectorOf<SchemaElementDecl>(4, false, manager);
00047 }
00048 
00049 XercesGroupInfo::XercesGroupInfo(unsigned int groupNameId,
00050                                  unsigned int groupNamespaceId,
00051                                  MemoryManager* const manager)
00052     : fCheckElementConsistency(true)
00053     , fScope(Grammar::TOP_LEVEL_SCOPE)
00054     , fNameId(groupNameId)
00055     , fNamespaceId(groupNamespaceId)
00056     , fContentSpec(0)
00057     , fElements(0)
00058     , fBaseGroup(0)
00059     , fLocator(0)
00060 {
00061     fElements = new (manager) RefVectorOf<SchemaElementDecl>(4, false, manager);
00062 }
00063 
00064 
00065 XercesGroupInfo::~XercesGroupInfo()
00066 {
00067     delete fElements;
00068     delete fContentSpec;
00069     delete fLocator;
00070 }
00071 
00072 
00073 // ---------------------------------------------------------------------------
00074 //  XercesGroupInfo: Constructors and Destructor
00075 // ---------------------------------------------------------------------------
00076 void XercesGroupInfo::setLocator(XSDLocator* const aLocator) {
00077 
00078     if (fLocator)
00079         delete fLocator;
00080 
00081     fLocator = aLocator;
00082 }
00083 
00084 /***
00085  * Support for Serialization/De-serialization
00086  ***/
00087 
00088 IMPL_XSERIALIZABLE_TOCREATE(XercesGroupInfo)
00089 
00090 void XercesGroupInfo::serialize(XSerializeEngine& serEng)
00091 {
00092     if (serEng.isStoring())
00093     {   
00094         serEng<<fCheckElementConsistency;
00095         serEng<<fScope;
00096         serEng<<fNameId;
00097         serEng<<fNamespaceId;
00098         serEng<<fContentSpec;
00099 
00100         /***
00101          *
00102          * Serialize RefVectorOf<SchemaElementDecl>* fElements;
00103          *
00104          ***/
00105 
00106         XTemplateSerializer::storeObject(fElements, serEng);
00107 
00108         serEng<<fBaseGroup;
00109 
00110         //don't serialize     XSDLocator* fLocator;
00111     }
00112     else
00113     {
00114         serEng>>fCheckElementConsistency;
00115         serEng>>fScope;
00116         serEng>>fNameId;
00117         serEng>>fNamespaceId;
00118         serEng>>fContentSpec;
00119 
00120         /***
00121          * 
00122          * Deserialize RefVectorOf<SchemaElementDecl>*    fElements;
00123          *
00124          ***/
00125         XTemplateSerializer::loadObject(&fElements, 4, false, serEng);
00126 
00127         serEng>>fBaseGroup;
00128 
00129         //don't serialize     XSDLocator* fLocator;
00130         fLocator = 0;
00131     }
00132 
00133 }
00134 
00135 XERCES_CPP_NAMESPACE_END
00136