summaryrefslogtreecommitdiff
path: root/src/tests/csv.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tests/csv.cpp')
-rw-r--r--src/tests/csv.cpp41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/tests/csv.cpp b/src/tests/csv.cpp
new file mode 100644
index 0000000..03e1df8
--- /dev/null
+++ b/src/tests/csv.cpp
@@ -0,0 +1,41 @@
1#include "bu/optparser.h"
2#include "bu/file.h"
3#include "bu/newline.h"
4#include "bu/csvreader.h"
5#include "bu/sio.h"
6
7using namespace Bu;
8
9class Options : public OptParser
10{
11public:
12 Options( int argc, char *argv[] )
13 {
14 addOption( slot( this, &Options::onRead ), 'r', "read",
15 "Read and display a csv file." );
16
17 addHelpOption();
18
19 parse( argc, argv );
20 }
21
22 int onRead( StrArray aArgs )
23 {
24 File fIn( aArgs[1], File::Read );
25 NewLine nlIn( fIn );
26 CsvReader rCsv( nlIn );
27 while( !fIn.isEos() )
28 {
29 sio << rCsv.readLine() << sio.nl;
30 }
31 sio << sio.nl;
32 return 1;
33 }
34};
35
36int main( int argc, char *argv[] )
37{
38 Options opts( argc, argv );
39 return 0;
40}
41