Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef __SERIALIZABLE_XML_FILE_H__
00011 #define __SERIALIZABLE_XML_FILE_H__
00012
00013 #include "lib/config.h"
00014 #ifdef HAVE_XML
00015
00016 #include "lib/SerializableFile.h"
00017 #include "base/DynArray.h"
00018
00019 #include <libxml/parser.h>
00020 #include <libxml/tree.h>
00021
00022 #define STR_TRUE "true"
00023 #define STR_FALSE "false"
00024
00025 #define STR_ITEM "i"
00026 #define STR_STRING "s"
00027 #define STR_SPARSE "r"
00028
00029 #define STR_PROP_TYPE "type"
00030 #define STR_PROP_IS_NULL "is_null"
00031 #define STR_PROP_INSTANCE_NAME "instance_name"
00032 #define STR_PROP_GENERIC_NAME "generic_name"
00033 #define STR_PROP_VECINDEX "vec_index"
00034 #define STR_PROP_FEATINDEX "feat_index"
00035
00036 namespace shogun
00037 {
00038 #define IGNORE_IN_CLASSLIST
00039 IGNORE_IN_CLASSLIST class CSerializableXmlFile
00040 :public CSerializableFile
00041 {
00042 friend class SerializableXmlReader00;
00043
00044 DynArray<xmlNode*> m_stack_stream;
00045 xmlDocPtr m_doc;
00046 bool m_format;
00047
00048 void init(bool format);
00049 bool push_node(const xmlChar* name);
00050 bool join_node(const xmlChar* name);
00051 bool next_node(const xmlChar* name);
00052 void pop_node(void);
00053
00054 protected:
00055 virtual TSerializableReader* new_reader(
00056 char* dest_version, size_t n);
00057
00058 virtual bool write_scalar_wrapped(
00059 const TSGDataType* type, const void* param);
00060
00061 virtual bool write_cont_begin_wrapped(
00062 const TSGDataType* type, index_t len_real_y,
00063 index_t len_real_x);
00064 virtual bool write_cont_end_wrapped(
00065 const TSGDataType* type, index_t len_real_y,
00066 index_t len_real_x);
00067
00068 virtual bool write_string_begin_wrapped(
00069 const TSGDataType* type, index_t length);
00070 virtual bool write_string_end_wrapped(
00071 const TSGDataType* type, index_t length);
00072
00073 virtual bool write_stringentry_begin_wrapped(
00074 const TSGDataType* type, index_t y);
00075 virtual bool write_stringentry_end_wrapped(
00076 const TSGDataType* type, index_t y);
00077
00078 virtual bool write_sparse_begin_wrapped(
00079 const TSGDataType* type, index_t vec_index,
00080 index_t length);
00081 virtual bool write_sparse_end_wrapped(
00082 const TSGDataType* type, index_t vec_index,
00083 index_t length);
00084
00085 virtual bool write_sparseentry_begin_wrapped(
00086 const TSGDataType* type, const TSparseEntry<char>* first_entry,
00087 index_t feat_index, index_t y);
00088 virtual bool write_sparseentry_end_wrapped(
00089 const TSGDataType* type, const TSparseEntry<char>* first_entry,
00090 index_t feat_index, index_t y);
00091
00092 virtual bool write_item_begin_wrapped(
00093 const TSGDataType* type, index_t y, index_t x);
00094 virtual bool write_item_end_wrapped(
00095 const TSGDataType* type, index_t y, index_t x);
00096
00097 virtual bool write_sgserializable_begin_wrapped(
00098 const TSGDataType* type, const char* sgserializable_name,
00099 EPrimitiveType generic);
00100 virtual bool write_sgserializable_end_wrapped(
00101 const TSGDataType* type, const char* sgserializable_name,
00102 EPrimitiveType generic);
00103
00104 virtual bool write_type_begin_wrapped(
00105 const TSGDataType* type, const char* name,
00106 const char* prefix);
00107 virtual bool write_type_end_wrapped(
00108 const TSGDataType* type, const char* name,
00109 const char* prefix);
00110
00111 public:
00113 explicit CSerializableXmlFile(void);
00114
00121 explicit CSerializableXmlFile(const char* fname, char rw='r',
00122 bool format=false);
00123
00125 virtual ~CSerializableXmlFile();
00126
00128 inline virtual const char* get_name() const {
00129 return "SerializableXmlFile";
00130 }
00131
00132 virtual void close(void);
00133 virtual bool is_opened(void);
00134 };
00135 }
00136 #endif
00137 #endif