Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef __SERIALIZABLE_ASCII_FILE_H__
00011 #define __SERIALIZABLE_ASCII_FILE_H__
00012
00013 #include <shogun/io/SerializableFile.h>
00014 #include <shogun/base/DynArray.h>
00015
00016 #define CHAR_CONT_BEGIN '('
00017 #define CHAR_CONT_END ')'
00018 #define CHAR_ITEM_BEGIN '{'
00019 #define CHAR_ITEM_END '}'
00020 #define CHAR_SGSERIAL_BEGIN '['
00021 #define CHAR_SGSERIAL_END ']'
00022 #define CHAR_STRING_BEGIN CHAR_SGSERIAL_BEGIN
00023 #define CHAR_STRING_END CHAR_SGSERIAL_END
00024 #define CHAR_SPARSE_BEGIN CHAR_CONT_BEGIN
00025 #define CHAR_SPARSE_END CHAR_CONT_END
00026
00027 #define CHAR_TYPE_END '\n'
00028
00029 #define STR_SGSERIAL_NULL "null"
00030
00031 namespace shogun
00032 {
00034 class CSerializableAsciiFile :public CSerializableFile
00035 {
00036 friend class SerializableAsciiReader00;
00037
00038 DynArray<long> m_stack_fpos;
00039
00040 void init();
00041 bool ignore();
00042
00043 protected:
00044
00049 virtual TSerializableReader* new_reader(
00050 char* dest_version, size_t n);
00051
00052 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00053 virtual bool write_scalar_wrapped(
00054 const TSGDataType* type, const void* param);
00055
00056 virtual bool write_cont_begin_wrapped(
00057 const TSGDataType* type, index_t len_real_y,
00058 index_t len_real_x);
00059 virtual bool write_cont_end_wrapped(
00060 const TSGDataType* type, index_t len_real_y,
00061 index_t len_real_x);
00062
00063 virtual bool write_string_begin_wrapped(
00064 const TSGDataType* type, index_t length);
00065 virtual bool write_string_end_wrapped(
00066 const TSGDataType* type, index_t length);
00067
00068 virtual bool write_stringentry_begin_wrapped(
00069 const TSGDataType* type, index_t y);
00070 virtual bool write_stringentry_end_wrapped(
00071 const TSGDataType* type, index_t y);
00072
00073 virtual bool write_sparse_begin_wrapped(
00074 const TSGDataType* type, index_t length);
00075 virtual bool write_sparse_end_wrapped(
00076 const TSGDataType* type, index_t length);
00077
00078 virtual bool write_sparseentry_begin_wrapped(
00079 const TSGDataType* type, const SGSparseVectorEntry<char>* first_entry,
00080 index_t feat_index, index_t y);
00081 virtual bool write_sparseentry_end_wrapped(
00082 const TSGDataType* type, const SGSparseVectorEntry<char>* first_entry,
00083 index_t feat_index, index_t y);
00084
00085 virtual bool write_item_begin_wrapped(
00086 const TSGDataType* type, index_t y, index_t x);
00087 virtual bool write_item_end_wrapped(
00088 const TSGDataType* type, index_t y, index_t x);
00089
00090 virtual bool write_sgserializable_begin_wrapped(
00091 const TSGDataType* type, const char* sgserializable_name,
00092 EPrimitiveType generic);
00093 virtual bool write_sgserializable_end_wrapped(
00094 const TSGDataType* type, const char* sgserializable_name,
00095 EPrimitiveType generic);
00096
00097 virtual bool write_type_begin_wrapped(
00098 const TSGDataType* type, const char* name,
00099 const char* prefix);
00100 virtual bool write_type_end_wrapped(
00101 const TSGDataType* type, const char* name,
00102 const char* prefix);
00103 #endif
00104 public:
00106 explicit CSerializableAsciiFile();
00107
00113 explicit CSerializableAsciiFile(FILE* fstream, char rw);
00114
00120 explicit CSerializableAsciiFile(const char* fname, char rw='r');
00121
00123 virtual ~CSerializableAsciiFile();
00124
00126 virtual const char* get_name() const {
00127 return "SerializableAsciiFile";
00128 }
00129 };
00130 }
00131
00132 #endif