Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef __STREAMING_ASCIIFILE_H__
00011 #define __STREAMING_ASCIIFILE_H__
00012
00013 #include <shogun/io/AsciiFile.h>
00014 #include <shogun/io/StreamingFile.h>
00015 #include <shogun/features/SparseFeatures.h>
00016
00017 namespace shogun
00018 {
00023 class CStreamingAsciiFile: public CStreamingFile
00024 {
00025 public:
00030 CStreamingAsciiFile();
00031
00038 CStreamingAsciiFile(char* fname, char rw='r');
00039
00043 virtual ~CStreamingAsciiFile();
00044
00052 inline bool str_to_bool(char *str)
00053 {
00054 return (atoi(str)!=0);
00055 }
00056
00057 #define GET_VECTOR_DECL(sg_type) \
00058 virtual void get_vector \
00059 (sg_type*& vector, int32_t& len); \
00060 \
00061 virtual void get_vector_and_label \
00062 (sg_type*& vector, int32_t& len, float64_t& label); \
00063 \
00064 virtual void get_string \
00065 (sg_type*& vector, int32_t& len); \
00066 \
00067 virtual void get_string_and_label \
00068 (sg_type*& vector, int32_t& len, float64_t& label); \
00069 \
00070 virtual void get_sparse_vector \
00071 (SGSparseVectorEntry<sg_type>*& vector, int32_t& len); \
00072 \
00073 virtual void get_sparse_vector_and_label \
00074 (SGSparseVectorEntry<sg_type>*& vector, int32_t& len, float64_t& label);
00075
00076 GET_VECTOR_DECL(bool)
00077 GET_VECTOR_DECL(uint8_t)
00078 GET_VECTOR_DECL(char)
00079 GET_VECTOR_DECL(int32_t)
00080 GET_VECTOR_DECL(float32_t)
00081 GET_VECTOR_DECL(float64_t)
00082 GET_VECTOR_DECL(int16_t)
00083 GET_VECTOR_DECL(uint16_t)
00084 GET_VECTOR_DECL(int8_t)
00085 GET_VECTOR_DECL(uint32_t)
00086 GET_VECTOR_DECL(int64_t)
00087 GET_VECTOR_DECL(uint64_t)
00088 GET_VECTOR_DECL(floatmax_t)
00089 #undef GET_VECTOR_DECL
00090
00092 inline virtual const char* get_name() const
00093 {
00094 return "StreamingAsciiFile";
00095
00096 }
00097
00098 private:
00105 template <class T> void append_item(DynArray<T>* items, char* ptr_data, char* ptr_item);
00106
00108 v_array<substring> words;
00109 };
00110 }
00111 #endif //__STREAMING_ASCIIFILE_H__