26 #ifndef DOXYGEN_SHOULD_SKIP_THIS 34 template <
template <
typename >
class ALLOC >
36 const std::string filename,
37 bool fileContainsNames,
38 const std::string delimiter,
39 const char commentmarker,
40 const char quoteMarker,
42 IDBInitializer< ALLOC >(IDBInitializer< ALLOC >::InputType::STRING, alloc),
43 __filename(filename), __delimiter(delimiter),
44 __comment_marker(commentmarker), __quote_marker(quoteMarker),
45 __first_row_has_names(fileContainsNames),
46 __input_stream(__filename,
std::ifstream::in),
47 __parser(__input_stream, delimiter, commentmarker, quoteMarker),
50 if ((__input_stream.rdstate() & std::ifstream::failbit) != 0) {
51 GUM_ERROR(IOError,
"File " << filename <<
" not found");
55 if (fileContainsNames) {
57 __var_names = __parser.current();
65 template <
template <
typename >
class ALLOC >
67 const DBInitializerFromCSV< ALLOC >& from,
70 from.__first_row_has_names,
73 from.__comment_marker,
77 template <
template <
typename >
class ALLOC >
79 const DBInitializerFromCSV< ALLOC >& from) :
83 template <
template <
typename >
class ALLOC >
85 DBInitializerFromCSV< ALLOC >&& from,
88 from.__first_row_has_names,
91 from.__comment_marker,
96 template <
template <
typename >
class ALLOC >
98 DBInitializerFromCSV< ALLOC >&& from) :
103 template <
template <
typename >
class ALLOC >
106 ALLOC< DBInitializerFromCSV< ALLOC > > allocator(alloc);
107 DBInitializerFromCSV< ALLOC >* new_initializer = allocator.allocate(1);
109 allocator.construct(new_initializer, *
this, alloc);
111 allocator.deallocate(new_initializer, 1);
115 return new_initializer;
120 template <
template <
typename >
class ALLOC >
127 template <
template <
typename >
class ALLOC >
134 template <
template <
typename >
class ALLOC >
136 operator=(
const DBInitializerFromCSV< ALLOC >& from) {
139 __filename = from.__filename;
140 __delimiter = from.__delimiter;
141 __comment_marker = from.__comment_marker;
142 __quote_marker = from.__quote_marker;
143 __first_row_has_names = from.__first_row_has_names;
146 __input_stream.close();
147 __input_stream.open(__filename, std::ifstream::in);
150 if ((__input_stream.rdstate() & std::ifstream::failbit) != 0) {
151 GUM_ERROR(IOError,
"File " << __filename <<
" not found");
155 __parser.useNewStream(
156 __input_stream, __delimiter, __comment_marker, __quote_marker);
159 if (__first_row_has_names) {
161 __var_names = __parser.current();
170 template <
template <
typename >
class ALLOC >
172 operator=(DBInitializerFromCSV< ALLOC >&& from) {
178 template <
template <
typename >
class ALLOC >
179 INLINE std::vector< std::string, ALLOC< std::string > >
186 template <
template <
typename >
class ALLOC >
187 INLINE
const std::vector< std::string, ALLOC< std::string > >&
189 return __parser.current();
194 template <
template <
typename >
class ALLOC >
196 return __parser.next();
virtual std::vector< std::string, ALLOC< std::string > > _variableNames() final
returns the names of the variables
virtual ~DBInitializerFromCSV()
destructor
DBInitializerFromCSV(const std::string filename, bool fileContainsNames=true, const std::string delimiter=",", const char commentmarker='#', const char quoteMarker='"', const allocator_type& alloc = allocator_type())
default constructor
DBInitializerFromCSV< ALLOC > & operator=(const DBInitializerFromCSV< ALLOC > &from)
copy operator
allocator_type getAllocator() const
returns the allocator used
virtual DBInitializerFromCSV< ALLOC > * clone() const
virtual copy constructor
virtual bool _nextRow() final
indicates whether there is a next row to read (and point on it)
gum is the global namespace for all aGrUM entities
IDBInitializer< ALLOC > & operator=(const IDBInitializer< ALLOC > &from)
copy operator
virtual const std::vector< std::string, ALLOC< std::string > > & _currentStringRow() final
returns the content of the current row using strings
ALLOC< std::string > allocator_type
type for the allocators passed in arguments of methods
#define GUM_ERROR(type, msg)