00001 /* 00002 * License Agreement 00003 * 00004 * NOTICE 00005 * This software (or technical data) was produced for the U. S. 00006 * Government under contract W15P7T-05-C-F600, and is 00007 * subject to the Rights in Data-General Clause 52.227-14 (JUNE 1987) 00008 * 00009 * Copyright (C) 2006. The MITRE Corporation (http://www.mitre.org/). 00010 * All Rights Reserved. 00011 * 00012 * Redistribution and use in source and binary forms, with or without 00013 * modification, are permitted provided that the following conditions 00014 * are met: 00015 * 00016 * * Redistributions of source code must retain the above copyright 00017 * notice, this list of conditions and the following disclaimer. 00018 * 00019 * * Redistributions in binary form must reproduce the above copyright 00020 * notice, this list of conditions and the following disclaimer in the 00021 * documentation and/or other materials provided with the distribution. 00022 * 00023 * * The US Government will not be charged any license fee and/or 00024 * royalties related to this software. 00025 * 00026 * * Neither name of The MITRE Corporation; nor the names of its 00027 * contributors may be used to endorse or promote products derived from 00028 * this software without specific prior written permission. 00029 * 00030 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 00031 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 00032 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 00033 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 00034 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 00035 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 00036 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 00037 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00038 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 00039 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 00040 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00041 */ 00042 00043 #ifndef _OASYS_XML_SERIALIZE_H_ 00044 #define _OASYS_XML_SERIALIZE_H_ 00045 00046 #include <vector> 00047 #include <sstream> 00048 #include <sys/time.h> 00049 00050 #include "Serialize.h" 00051 #include "../util/StringBuffer.h" 00052 #include "../xml/XMLDocument.h" 00053 #include "../xml/XMLObject.h" 00054 00055 namespace oasys { 00056 00061 class XMLMarshal : public SerializeAction { 00062 public: 00063 XMLMarshal(ExpandableBuffer *buf, const char *root_tag); 00064 00065 // Virtual process functions inherited from SerializeAction 00066 virtual void end_action(); 00067 virtual void process(const char *name, SerializableObject* object); 00068 virtual void process(const char *name, u_int64_t *i); 00069 virtual void process(const char *name, u_int32_t *i); 00070 virtual void process(const char *name, u_int16_t *i); 00071 virtual void process(const char *name, u_int8_t *i); 00072 virtual void process(const char *name, bool *b); 00073 virtual void process(const char *name, u_char *bp, u_int32_t len); 00074 virtual void process(const char *name, u_char **bp, 00075 u_int32_t *lenp, int flags); 00076 virtual void process(const char *name, std::string *s); 00077 00079 const XMLDocument& doc() const { return doc_; } 00080 00081 protected: 00082 StringBuffer buf_; 00083 XMLDocument doc_; 00084 XMLObject *current_node_; 00085 }; 00086 00091 class XMLUnmarshal : public SerializeAction { 00092 public: 00093 XMLUnmarshal() 00094 : SerializeAction(Serialize::UNMARSHAL, 00095 Serialize::CONTEXT_UNKNOWN) {} 00096 00101 virtual const char * parse(const char *xml_doc) = 0; 00102 }; 00103 00104 } // namespace oasys 00105 00106 #endif // _OASYS_XML_SERIALIZE_H_