GME
13
|
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: Grammar.cpp 471747 2006-11-06 14:31:56Z amassari $ 00020 */ 00021 00022 #include <xercesc/validators/common/Grammar.hpp> 00023 00024 //since we need to dynamically created each and every derivatives 00025 //during deserialization by XSerializeEngine>>Derivative, we got 00026 //to include all hpp 00027 00028 #include <xercesc/validators/DTD/DTDGrammar.hpp> 00029 #include <xercesc/validators/schema/SchemaGrammar.hpp> 00030 #include <xercesc/framework/psvi/XSAnnotation.hpp> 00031 00032 XERCES_CPP_NAMESPACE_BEGIN 00033 00034 /*** 00035 * Support for Serialization/De-serialization 00036 ***/ 00037 00038 IMPL_XSERIALIZABLE_NOCREATE(Grammar) 00039 00040 void Grammar::serialize(XSerializeEngine&) 00041 { 00042 //no data 00043 } 00044 00045 void Grammar::storeGrammar(XSerializeEngine& serEng 00046 , Grammar* const grammar) 00047 { 00048 if (grammar) 00049 { 00050 serEng<<(int) grammar->getGrammarType(); 00051 serEng<<grammar; 00052 } 00053 else 00054 { 00055 serEng<<(int) UnKnown; 00056 } 00057 00058 } 00059 00060 Grammar* Grammar::loadGrammar(XSerializeEngine& serEng) 00061 { 00062 00063 int type; 00064 serEng>>type; 00065 00066 switch((GrammarType)type) 00067 { 00068 case DTDGrammarType: 00069 DTDGrammar* dtdGrammar; 00070 serEng>>dtdGrammar; 00071 return dtdGrammar; 00072 case SchemaGrammarType: 00073 SchemaGrammar* schemaGrammar; 00074 serEng>>schemaGrammar; 00075 return schemaGrammar; 00076 case UnKnown: 00077 return 0; 00078 default: //we treat this same as UnKnown 00079 return 0; 00080 } 00081 00082 } 00083 00084 XERCES_CPP_NAMESPACE_END