summaryrefslogtreecommitdiff
path: root/src/stable/csvreader.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/stable/csvreader.h')
-rw-r--r--src/stable/csvreader.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/stable/csvreader.h b/src/stable/csvreader.h
new file mode 100644
index 0000000..2e9e7b0
--- /dev/null
+++ b/src/stable/csvreader.h
@@ -0,0 +1,45 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#ifndef BU_CSV_READER_H
9#define BU_CSV_READER_H
10
11#include "bu/string.h"
12#include "bu/array.h"
13#include "bu/signals.h"
14
15namespace Bu
16{
17 class Stream;
18 typedef Bu::Array<Bu::String> StrArray;
19
20 class CsvReader
21 {
22 public:
23 typedef Bu::Signal1<Bu::String, Bu::String::iterator &> DecodeSignal;
24 enum Style
25 {
26 styleExcel, ///< Excel style quotes around things that need em
27 styleC ///< Escape things that need it C-style
28 };
29
30 CsvReader( Stream &sIn, Style eStyle=styleExcel );
31 CsvReader( Stream &sIn, DecodeSignal sDecode );
32 virtual ~CsvReader();
33
34 StrArray readLine();
35
36 private:
37 Stream &sIn;
38 DecodeSignal sDecode;
39
40 static Bu::String decodeExcel( Bu::String::iterator &i );
41 static Bu::String decodeC( Bu::String::iterator &i );
42 };
43};
44
45#endif