/usr/include/shogun/io/streaming/StreamingAsciiFile.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 | /*
* 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) 2011 Shashwat Lal Das
* Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society
*/
#ifndef __STREAMING_ASCIIFILE_H__
#define __STREAMING_ASCIIFILE_H__
#include <shogun/io/CSVFile.h>
#include <shogun/io/streaming/StreamingFile.h>
#include <shogun/features/SparseFeatures.h>
namespace shogun
{
/** @brief Class StreamingAsciiFile to read vector-by-vector from ASCII files.
*
* The object must be initialized like a CCSVFile.
*/
class CStreamingAsciiFile: public CStreamingFile
{
public:
/**
* Default constructor
*
*/
CStreamingAsciiFile();
/**
* Constructor taking file name argument
*
* @param fname file name
* @param rw read/write mode
*/
CStreamingAsciiFile(const char* fname, char rw='r');
/**
* Destructor
*/
virtual ~CStreamingAsciiFile();
/** set delimiting character
*
* @param delimiter the character used as delimiter
*/
void set_delimiter(char delimiter);
/**
* Utility function to convert a string to a boolean value
*
* @param str string to convert
*
* @return boolean value
*/
inline bool str_to_bool(char *str)
{
return (atoi(str)!=0);
}
#define GET_VECTOR_DECL(sg_type) \
virtual void get_vector \
(sg_type*& vector, int32_t& len); \
\
virtual void get_vector_and_label \
(sg_type*& vector, int32_t& len, float64_t& label); \
\
virtual void get_string \
(sg_type*& vector, int32_t& len); \
\
virtual void get_string_and_label \
(sg_type*& vector, int32_t& len, float64_t& label); \
\
virtual void get_sparse_vector \
(SGSparseVectorEntry<sg_type>*& vector, int32_t& len); \
\
virtual void get_sparse_vector_and_label \
(SGSparseVectorEntry<sg_type>*& vector, int32_t& len, float64_t& label);
GET_VECTOR_DECL(bool)
GET_VECTOR_DECL(uint8_t)
GET_VECTOR_DECL(char)
GET_VECTOR_DECL(int32_t)
GET_VECTOR_DECL(float32_t)
GET_VECTOR_DECL(float64_t)
GET_VECTOR_DECL(int16_t)
GET_VECTOR_DECL(uint16_t)
GET_VECTOR_DECL(int8_t)
GET_VECTOR_DECL(uint32_t)
GET_VECTOR_DECL(int64_t)
GET_VECTOR_DECL(uint64_t)
GET_VECTOR_DECL(floatmax_t)
#undef GET_VECTOR_DECL
/** @return object name */
virtual const char* get_name() const
{
return "StreamingAsciiFile";
}
private:
/** helper function to read vectors / matrices
*
* @param items dynamic array of values
* @param ptr_data
* @param ptr_item
*/
template <class T> void append_item(DynArray<T>* items, char* ptr_data, char* ptr_item);
/// Helper for parsing
v_array<substring> words;
/** delimiter */
char m_delimiter;
};
}
#endif //__STREAMING_ASCIIFILE_H__
|