29 #ifndef DOXYGEN_SHOULD_SKIP_THIS 37 template <
template <
typename >
class ALLOC >
39 const std::string filename,
40 bool fileContainsNames,
41 const std::string delimiter,
42 const char commentmarker,
43 const char quoteMarker,
45 IDBInitializer< ALLOC >(IDBInitializer< ALLOC >::InputType::STRING, alloc),
46 __filename(filename), __delimiter(delimiter),
47 __comment_marker(commentmarker), __quote_marker(quoteMarker),
48 __first_row_has_names(fileContainsNames),
49 __input_stream(__filename,
std::ifstream::in),
50 __parser(__input_stream, delimiter, commentmarker, quoteMarker),
53 if ((__input_stream.rdstate() & std::ifstream::failbit) != 0) {
54 GUM_ERROR(IOError,
"File " << filename <<
" not found");
58 if (fileContainsNames) {
60 __var_names = __parser.current();
68 template <
template <
typename >
class ALLOC >
70 const DBInitializerFromCSV< ALLOC >& from,
73 from.__first_row_has_names,
76 from.__comment_marker,
80 template <
template <
typename >
class ALLOC >
82 const DBInitializerFromCSV< ALLOC >& from) :
86 template <
template <
typename >
class ALLOC >
88 DBInitializerFromCSV< ALLOC >&& from,
91 from.__first_row_has_names,
94 from.__comment_marker,
99 template <
template <
typename >
class ALLOC >
101 DBInitializerFromCSV< ALLOC >&& from) :
106 template <
template <
typename >
class ALLOC >
109 ALLOC< DBInitializerFromCSV< ALLOC > > allocator(alloc);
110 DBInitializerFromCSV< ALLOC >* new_initializer = allocator.allocate(1);
112 allocator.construct(new_initializer, *
this, alloc);
114 allocator.deallocate(new_initializer, 1);
118 return new_initializer;
123 template <
template <
typename >
class ALLOC >
130 template <
template <
typename >
class ALLOC >
137 template <
template <
typename >
class ALLOC >
139 operator=(
const DBInitializerFromCSV< ALLOC >& from) {
142 __filename = from.__filename;
143 __delimiter = from.__delimiter;
144 __comment_marker = from.__comment_marker;
145 __quote_marker = from.__quote_marker;
146 __first_row_has_names = from.__first_row_has_names;
149 __input_stream.close();
150 __input_stream.open(__filename, std::ifstream::in);
153 if ((__input_stream.rdstate() & std::ifstream::failbit) != 0) {
154 GUM_ERROR(IOError,
"File " << __filename <<
" not found");
158 __parser.useNewStream(
159 __input_stream, __delimiter, __comment_marker, __quote_marker);
162 if (__first_row_has_names) {
164 __var_names = __parser.current();
173 template <
template <
typename >
class ALLOC >
175 operator=(DBInitializerFromCSV< ALLOC >&& from) {
181 template <
template <
typename >
class ALLOC >
182 INLINE std::vector< std::string, ALLOC< std::string > >
189 template <
template <
typename >
class ALLOC >
190 INLINE
const std::vector< std::string, ALLOC< std::string > >&
192 return __parser.current();
197 template <
template <
typename >
class ALLOC >
199 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)
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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)