SHOGUN  v3.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups 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 length);
75  virtual bool write_sparse_end_wrapped(
76  const TSGDataType* type, index_t length);
77 
78  virtual bool write_sparseentry_begin_wrapped(
79  const TSGDataType* type, const SGSparseVectorEntry<char>* first_entry,
80  index_t feat_index, index_t y);
81  virtual bool write_sparseentry_end_wrapped(
82  const TSGDataType* type, const SGSparseVectorEntry<char>* first_entry,
83  index_t feat_index, index_t y);
84 
85  virtual bool write_item_begin_wrapped(
86  const TSGDataType* type, index_t y, index_t x);
87  virtual bool write_item_end_wrapped(
88  const TSGDataType* type, index_t y, index_t x);
89 
90  virtual bool write_sgserializable_begin_wrapped(
91  const TSGDataType* type, const char* sgserializable_name,
92  EPrimitiveType generic);
93  virtual bool write_sgserializable_end_wrapped(
94  const TSGDataType* type, const char* sgserializable_name,
95  EPrimitiveType generic);
96 
97  virtual bool write_type_begin_wrapped(
98  const TSGDataType* type, const char* name,
99  const char* prefix);
100  virtual bool write_type_end_wrapped(
101  const TSGDataType* type, const char* name,
102  const char* prefix);
103 #endif
104 public:
106  explicit CSerializableAsciiFile();
107 
113  explicit CSerializableAsciiFile(FILE* fstream, char rw);
114 
120  explicit CSerializableAsciiFile(const char* fname, char rw='r');
121 
123  virtual ~CSerializableAsciiFile();
124 
126  virtual const char* get_name() const {
127  return "SerializableAsciiFile";
128  }
129 };
130 }
131 
132 #endif /* __SERIALIZABLE_ASCII_FILE_H__ */

SHOGUN Machine Learning Toolbox - Documentation