diff options
Diffstat (limited to 'src/csvreader.h')
| -rw-r--r-- | src/csvreader.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/csvreader.h b/src/csvreader.h new file mode 100644 index 0000000..d89fabe --- /dev/null +++ b/src/csvreader.h | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | #ifndef BU_CSV_READER_H | ||
| 2 | #define BU_CSV_READER_H | ||
| 3 | |||
| 4 | #include "bu/fstring.h" | ||
| 5 | #include "bu/array.h" | ||
| 6 | #include "bu/signals.h" | ||
| 7 | |||
| 8 | namespace Bu | ||
| 9 | { | ||
| 10 | class Stream; | ||
| 11 | typedef Bu::Array<Bu::FString> StrArray; | ||
| 12 | |||
| 13 | class CsvReader | ||
| 14 | { | ||
| 15 | public: | ||
| 16 | typedef Bu::Signal1<Bu::FString, Bu::FString::iterator &> DecodeSignal; | ||
| 17 | enum Style | ||
| 18 | { | ||
| 19 | styleExcel, ///< Excel style quotes around things that need em | ||
| 20 | styleC ///< Escape things that need it C-style | ||
| 21 | }; | ||
| 22 | |||
| 23 | CsvReader( Stream &sIn, Style eStyle=styleExcel ); | ||
| 24 | CsvReader( Stream &sIn, DecodeSignal sDecode ); | ||
| 25 | virtual ~CsvReader(); | ||
| 26 | |||
| 27 | StrArray readLine(); | ||
| 28 | |||
| 29 | private: | ||
| 30 | Stream &sIn; | ||
| 31 | DecodeSignal sDecode; | ||
| 32 | |||
| 33 | static Bu::FString decodeExcel( Bu::FString::iterator &i ); | ||
| 34 | static Bu::FString decodeC( Bu::FString::iterator &i ); | ||
| 35 | }; | ||
| 36 | }; | ||
| 37 | |||
| 38 | #endif | ||
