SHOGUN  v1.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SerializableAsciiFile.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 3 of the License, or
5  * (at your option) any later version.
6  *
7  * Written (W) 2010 Soeren Sonnenburg
8  * Copyright (C) 2010 Berlin Institute of Technology
9  */
10 #ifndef __SERIALIZABLE_ASCII_FILE_H__
11 #define __SERIALIZABLE_ASCII_FILE_H__
12 
14 #include <shogun/base/DynArray.h>
15 
16 #define CHAR_CONT_BEGIN '('
17 #define CHAR_CONT_END ')'
18 #define CHAR_ITEM_BEGIN '{'
19 #define CHAR_ITEM_END '}'
20 #define CHAR_SGSERIAL_BEGIN '['
21 #define CHAR_SGSERIAL_END ']'
22 #define CHAR_STRING_BEGIN CHAR_SGSERIAL_BEGIN
23 #define CHAR_STRING_END CHAR_SGSERIAL_END
24 #define CHAR_SPARSE_BEGIN CHAR_CONT_BEGIN
25 #define CHAR_SPARSE_END CHAR_CONT_END
26 
27 #define CHAR_TYPE_END '\n'
28 
29 #define STR_SGSERIAL_NULL "null"
30 
31 namespace shogun
32 {
35 {
37 
38  DynArray<long> m_stack_fpos;
39 
40  void init();
41  bool ignore();
42 
43 protected:
44 
50  char* dest_version, size_t n);
51 
52 #ifndef DOXYGEN_SHOULD_SKIP_THIS
53  virtual bool write_scalar_wrapped(
54  const TSGDataType* type, const void* param);
55 
56  virtual bool write_cont_begin_wrapped(
57  const TSGDataType* type, index_t len_real_y,
58  index_t len_real_x);
59  virtual bool write_cont_end_wrapped(
60  const TSGDataType* type, index_t len_real_y,
61  index_t len_real_x);
62 
63  virtual bool write_string_begin_wrapped(
64  const TSGDataType* type, index_t length);
65  virtual bool write_string_end_wrapped(
66  const TSGDataType* type, index_t length);
67 
68  virtual bool write_stringentry_begin_wrapped(
69  const TSGDataType* type, index_t y);
70  virtual bool write_stringentry_end_wrapped(
71  const TSGDataType* type, index_t y);
72 
73  virtual bool write_sparse_begin_wrapped(
74  const TSGDataType* type, index_t vec_index,
75  index_t length);
76  virtual bool write_sparse_end_wrapped(
77  const TSGDataType* type, index_t vec_index,
78  index_t length);
79 
80  virtual bool write_sparseentry_begin_wrapped(
81  const TSGDataType* type, const SGSparseVectorEntry<char>* first_entry,
82  index_t feat_index, index_t y);
83  virtual bool write_sparseentry_end_wrapped(
84  const TSGDataType* type, const SGSparseVectorEntry<char>* first_entry,
85  index_t feat_index, index_t y);
86 
87  virtual bool write_item_begin_wrapped(
88  const TSGDataType* type, index_t y, index_t x);
89  virtual bool write_item_end_wrapped(
90  const TSGDataType* type, index_t y, index_t x);
91 
92  virtual bool write_sgserializable_begin_wrapped(
93  const TSGDataType* type, const char* sgserializable_name,
94  EPrimitiveType generic);
95  virtual bool write_sgserializable_end_wrapped(
96  const TSGDataType* type, const char* sgserializable_name,
97  EPrimitiveType generic);
98 
99  virtual bool write_type_begin_wrapped(
100  const TSGDataType* type, const char* name,
101  const char* prefix);
102  virtual bool write_type_end_wrapped(
103  const TSGDataType* type, const char* name,
104  const char* prefix);
105 #endif
106 public:
108  explicit CSerializableAsciiFile();
109 
115  explicit CSerializableAsciiFile(FILE* fstream, char rw);
116 
122  explicit CSerializableAsciiFile(const char* fname, char rw='r');
123 
125  virtual ~CSerializableAsciiFile();
126 
128  inline virtual const char* get_name() const {
129  return "SerializableAsciiFile";
130  }
131 };
132 }
133 
134 #endif /* __SERIALIZABLE_ASCII_FILE_H__ */

SHOGUN Machine Learning Toolbox - Documentation