Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:14:56

0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one or more
0003  * contributor license agreements.  See the NOTICE file distributed with
0004  * this work for additional information regarding copyright ownership.
0005  * The ASF licenses this file to You under the Apache License, Version 2.0
0006  * (the "License"); you may not use this file except in compliance with
0007  * the License.  You may obtain a copy of the License at
0008  * 
0009  *      http://www.apache.org/licenses/LICENSE-2.0
0010  * 
0011  * Unless required by applicable law or agreed to in writing, software
0012  * distributed under the License is distributed on an "AS IS" BASIS,
0013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
0014  * See the License for the specific language governing permissions and
0015  * limitations under the License.
0016  */
0017 
0018 /*
0019  * $Id$
0020  */
0021 
0022 #if !defined(XERCESC_INCLUDE_GUARD_XSERIALIZABLE_HPP)
0023 #define XERCESC_INCLUDE_GUARD_XSERIALIZABLE_HPP
0024 
0025 #include <xercesc/internal/XSerializeEngine.hpp>
0026 #include <xercesc/internal/XProtoType.hpp>
0027 
0028 XERCES_CPP_NAMESPACE_BEGIN
0029 
0030 class XMLUTIL_EXPORT XSerializable
0031 {
0032 public :
0033 
0034     // -----------------------------------------------------------------------
0035     //  Constructors and Destructor
0036     // -----------------------------------------------------------------------
0037     virtual ~XSerializable() {} ;
0038 
0039     // -----------------------------------------------------------------------
0040     //  Serialization Interface
0041     // -----------------------------------------------------------------------   
0042     virtual bool        isSerializable()               const = 0;
0043 
0044     virtual void        serialize(XSerializeEngine& )        = 0;
0045 
0046     virtual XProtoType* getProtoType()                 const = 0;
0047 
0048 protected:
0049     XSerializable() {}
0050     XSerializable(const XSerializable& ) {}             
0051 
0052 private:
0053     // -----------------------------------------------------------------------
0054     //  Unimplemented assignment operator
0055     // -----------------------------------------------------------------------
0056     XSerializable& operator=(const XSerializable&);
0057 
0058 };
0059 
0060 inline void XSerializable::serialize(XSerializeEngine& )
0061 {
0062 }
0063 
0064 /***
0065  * Macro to be included in XSerializable derivatives'
0066  * declaration's public section
0067  ***/
0068 #define DECL_XSERIALIZABLE(class_name) \
0069 public: \
0070 \
0071 DECL_XPROTOTYPE(class_name) \
0072 \
0073 virtual bool                    isSerializable()                  const ;  \
0074 virtual XProtoType*             getProtoType()                    const;   \
0075 virtual void                    serialize(XSerializeEngine&); \
0076 \
0077 inline friend XSerializeEngine& operator>>(XSerializeEngine& serEng  \
0078                                          , class_name*&      objPtr) \
0079 {objPtr = (class_name*) serEng.read(XPROTOTYPE_CLASS(class_name));   \
0080  return serEng; \
0081 };
0082     
0083 /***
0084  * Macro to be included in the implementation file
0085  * of XSerializable derivatives' which is instantiable
0086  ***/
0087 #define IMPL_XSERIALIZABLE_TOCREATE(class_name) \
0088 IMPL_XPROTOTYPE_TOCREATE(class_name) \
0089 IMPL_XSERIAL(class_name)
0090 
0091 /***
0092  * Macro to be included in the implementation file
0093  * of XSerializable derivatives' which is UN-instantiable
0094  ***/
0095 #define IMPL_XSERIALIZABLE_NOCREATE(class_name) \
0096 IMPL_XPROTOTYPE_NOCREATE(class_name) \
0097 IMPL_XSERIAL(class_name)
0098 
0099 /***
0100  * Helper Macro 
0101  ***/
0102 #define IMPL_XSERIAL(class_name) \
0103 bool        class_name::isSerializable() const \
0104 {return true; } \
0105 XProtoType* class_name::getProtoType()   const \
0106 {return XPROTOTYPE_CLASS(class_name); } 
0107 
0108 #define IS_EQUIVALENT(lptr, rptr) \
0109     if (lptr == rptr)             \
0110         return true;              \
0111     if (( lptr && !rptr) || (!lptr &&  rptr))  \
0112         return false;
0113 
0114 XERCES_CPP_NAMESPACE_END
0115 
0116 #endif
0117