/usr/include/shogun/io/SerializableFile.h is in libshogun-dev 3.2.0-7.3build4.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 | /*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 3 of the License, or
* (at your option) any later version.
*
* Written (W) 1999-2009 Soeren Sonnenburg
* Copyright (C) 1999-2009 Fraunhofer Institute FIRST and Max-Planck-Society
* Copyright (C) 2010 Berlin Institute of Technology
*/
#ifndef __SERIALIZABLE_FILE_H__
#define __SERIALIZABLE_FILE_H__
#include <stdio.h>
#include <shogun/base/SGObject.h>
#include <shogun/lib/DataType.h>
#include <shogun/lib/SGSparseVector.h>
namespace shogun
{
class CSGObject;
/** @brief serializable file */
class CSerializableFile :public CSGObject
{
public:
/** @brief serializable reader */
struct TSerializableReader :public CSGObject {
/* ******************************************************** */
/* Begin of abstract write methods */
#ifndef DOXYGEN_SHOULD_SKIP_THIS
virtual bool read_scalar_wrapped(
const TSGDataType* type, void* param) = 0;
virtual bool read_cont_begin_wrapped(
const TSGDataType* type, index_t* len_read_y,
index_t* len_read_x) = 0;
virtual bool read_cont_end_wrapped(
const TSGDataType* type, index_t len_read_y,
index_t len_read_x) = 0;
virtual bool read_string_begin_wrapped(
const TSGDataType* type, index_t* length) = 0;
virtual bool read_string_end_wrapped(
const TSGDataType* type, index_t length) = 0;
virtual bool read_stringentry_begin_wrapped(
const TSGDataType* type, index_t y) = 0;
virtual bool read_stringentry_end_wrapped(
const TSGDataType* type, index_t y) = 0;
virtual bool read_sparse_begin_wrapped(
const TSGDataType* type, index_t* length) = 0;
virtual bool read_sparse_end_wrapped(
const TSGDataType* type, index_t length) = 0;
virtual bool read_sparseentry_begin_wrapped(
const TSGDataType* type, SGSparseVectorEntry<char>* first_entry,
index_t* feat_index, index_t y) = 0;
virtual bool read_sparseentry_end_wrapped(
const TSGDataType* type, SGSparseVectorEntry<char>* first_entry,
index_t* feat_index, index_t y) = 0;
virtual bool read_item_begin_wrapped(
const TSGDataType* type, index_t y, index_t x) = 0;
virtual bool read_item_end_wrapped(
const TSGDataType* type, index_t y, index_t x) = 0;
virtual bool read_sgserializable_begin_wrapped(
const TSGDataType* type, char* sgserializable_name,
EPrimitiveType* generic) = 0;
virtual bool read_sgserializable_end_wrapped(
const TSGDataType* type, const char* sgserializable_name,
EPrimitiveType generic) = 0;
virtual bool read_type_begin_wrapped(
const TSGDataType* type, const char* name,
const char* prefix) = 0;
virtual bool read_type_end_wrapped(
const TSGDataType* type, const char* name,
const char* prefix) = 0;
#endif
/* End of abstract write methods */
/* ******************************************************** */
}; /* struct TSerializableReader */
/* public: */
private:
/// reader
TSerializableReader* m_reader;
bool is_task_warn(char rw, const char* name, const char* prefix);
bool false_warn(const char* prefix, const char* name);
protected:
/** file stream */
FILE* m_fstream;
/** task */
char m_task;
/** filename */
char* m_filename;
/** init
* @param fstream
* @param task
* @param filename
*/
void init(FILE* fstream, char task, const char* filename);
/* ************************************************************ */
/* Begin of abstract write methods */
#ifndef DOXYGEN_SHOULD_SKIP_THIS
virtual TSerializableReader* new_reader(
char* dest_version, size_t n) = 0;
virtual bool write_scalar_wrapped(
const TSGDataType* type, const void* param) = 0;
virtual bool write_cont_begin_wrapped(
const TSGDataType* type, index_t len_real_y,
index_t len_real_x) = 0;
virtual bool write_cont_end_wrapped(
const TSGDataType* type, index_t len_real_y,
index_t len_real_x) = 0;
virtual bool write_string_begin_wrapped(
const TSGDataType* type, index_t length) = 0;
virtual bool write_string_end_wrapped(
const TSGDataType* type, index_t length) = 0;
virtual bool write_stringentry_begin_wrapped(
const TSGDataType* type, index_t y) = 0;
virtual bool write_stringentry_end_wrapped(
const TSGDataType* type, index_t y) = 0;
virtual bool write_sparse_begin_wrapped(
const TSGDataType* type, index_t length) = 0;
virtual bool write_sparse_end_wrapped(
const TSGDataType* type, index_t length) = 0;
virtual bool write_sparseentry_begin_wrapped(
const TSGDataType* type, const SGSparseVectorEntry<char>* first_entry,
index_t feat_index, index_t y) = 0;
virtual bool write_sparseentry_end_wrapped(
const TSGDataType* type, const SGSparseVectorEntry<char>* first_entry,
index_t feat_index, index_t y) = 0;
virtual bool write_item_begin_wrapped(
const TSGDataType* type, index_t y, index_t x) = 0;
virtual bool write_item_end_wrapped(
const TSGDataType* type, index_t y, index_t x) = 0;
virtual bool write_sgserializable_begin_wrapped(
const TSGDataType* type, const char* sgserializable_name,
EPrimitiveType generic) = 0;
virtual bool write_sgserializable_end_wrapped(
const TSGDataType* type, const char* sgserializable_name,
EPrimitiveType generic) = 0;
virtual bool write_type_begin_wrapped(
const TSGDataType* type, const char* name,
const char* prefix) = 0;
virtual bool write_type_end_wrapped(
const TSGDataType* type, const char* name,
const char* prefix) = 0;
#endif
/* End of abstract write methods */
/* ************************************************************ */
public:
/** default constructor */
explicit CSerializableFile();
/** constructor
*
* @param fstream already opened file
* @param rw
*/
explicit CSerializableFile(FILE* fstream, char rw);
/** constructor
*
* @param fname filename to open
* @param rw mode, 'r' or 'w'
*/
explicit CSerializableFile(const char* fname, char rw='r');
/** default destructor */
virtual ~CSerializableFile();
/** close */
virtual void close();
/** is opened */
virtual bool is_opened();
/* ************************************************************ */
/* Begin of public wrappers */
#ifndef DOXYGEN_SHOULD_SKIP_THIS
virtual bool write_scalar(
const TSGDataType* type, const char* name, const char* prefix,
const void* param);
virtual bool read_scalar(
const TSGDataType* type, const char* name, const char* prefix,
void* param);
virtual bool write_cont_begin(
const TSGDataType* type, const char* name, const char* prefix,
index_t len_real_y, index_t len_real_x);
virtual bool read_cont_begin(
const TSGDataType* type, const char* name, const char* prefix,
index_t* len_read_y, index_t* len_read_x);
virtual bool write_cont_end(
const TSGDataType* type, const char* name, const char* prefix,
index_t len_real_y, index_t len_real_x);
virtual bool read_cont_end(
const TSGDataType* type, const char* name, const char* prefix,
index_t len_read_y, index_t len_read_x);
virtual bool write_string_begin(
const TSGDataType* type, const char* name, const char* prefix,
index_t length);
virtual bool read_string_begin(
const TSGDataType* type, const char* name, const char* prefix,
index_t* length);
virtual bool write_string_end(
const TSGDataType* type, const char* name, const char* prefix,
index_t length);
virtual bool read_string_end(
const TSGDataType* type, const char* name, const char* prefix,
index_t length);
virtual bool write_stringentry_begin(
const TSGDataType* type, const char* name, const char* prefix,
index_t y);
virtual bool read_stringentry_begin(
const TSGDataType* type, const char* name, const char* prefix,
index_t y);
virtual bool write_stringentry_end(
const TSGDataType* type, const char* name, const char* prefix,
index_t y);
virtual bool read_stringentry_end(
const TSGDataType* type, const char* name, const char* prefix,
index_t y);
virtual bool write_sparse_begin(
const TSGDataType* type, const char* name, const char* prefix,
index_t length);
virtual bool read_sparse_begin(
const TSGDataType* type, const char* name, const char* prefix,
index_t* length);
virtual bool write_sparse_end(
const TSGDataType* type, const char* name, const char* prefix,
index_t length);
virtual bool read_sparse_end(
const TSGDataType* type, const char* name, const char* prefix,
index_t length);
virtual bool write_sparseentry_begin(
const TSGDataType* type, const char* name, const char* prefix,
const SGSparseVectorEntry<char>* first_entry, index_t feat_index,
index_t y);
virtual bool read_sparseentry_begin(
const TSGDataType* type, const char* name, const char* prefix,
SGSparseVectorEntry<char>* first_entry, index_t* feat_index,
index_t y);
virtual bool write_sparseentry_end(
const TSGDataType* type, const char* name, const char* prefix,
const SGSparseVectorEntry<char>* first_entry, index_t feat_index,
index_t y);
virtual bool read_sparseentry_end(
const TSGDataType* type, const char* name, const char* prefix,
SGSparseVectorEntry<char>* first_entry, index_t* feat_index,
index_t y);
virtual bool write_item_begin(
const TSGDataType* type, const char* name, const char* prefix,
index_t y, index_t x);
virtual bool read_item_begin(
const TSGDataType* type, const char* name, const char* prefix,
index_t y, index_t x);
virtual bool write_item_end(
const TSGDataType* type, const char* name, const char* prefix,
index_t y, index_t x);
virtual bool read_item_end(
const TSGDataType* type, const char* name, const char* prefix,
index_t y, index_t x);
virtual bool write_sgserializable_begin(
const TSGDataType* type, const char* name, const char* prefix,
const char* sgserializable_name, EPrimitiveType generic);
virtual bool read_sgserializable_begin(
const TSGDataType* type, const char* name, const char* prefix,
char* sgserializable_name, EPrimitiveType* generic);
virtual bool write_sgserializable_end(
const TSGDataType* type, const char* name, const char* prefix,
const char* sgserializable_name, EPrimitiveType generic);
virtual bool read_sgserializable_end(
const TSGDataType* type, const char* name, const char* prefix,
const char* sgserializable_name, EPrimitiveType generic);
virtual bool write_type_begin(
const TSGDataType* type, const char* name, const char* prefix);
virtual bool read_type_begin(
const TSGDataType* type, const char* name, const char* prefix);
virtual bool write_type_end(
const TSGDataType* type, const char* name, const char* prefix);
virtual bool read_type_end(
const TSGDataType* type, const char* name, const char* prefix);
#endif
/* End of public wrappers */
/* ************************************************************ */
};
}
#endif // __SERIALIZABLE_FILE_H__
|