aboutsummaryrefslogtreecommitdiff
path: root/src/tests
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2010-02-11 00:38:09 +0000
committerMike Buland <eichlan@xagasoft.com>2010-02-11 00:38:09 +0000
commitd61161061bd5998ef4b1fc2aaad2cf4bbd78e90d (patch)
treef4ea64381d4f0b3b7a9610758c034183098c2e96 /src/tests
parent79b7b631750b69cbe06daedb0453306595dea6ad (diff)
downloadlibbu++-d61161061bd5998ef4b1fc2aaad2cf4bbd78e90d.tar.gz
libbu++-d61161061bd5998ef4b1fc2aaad2cf4bbd78e90d.tar.bz2
libbu++-d61161061bd5998ef4b1fc2aaad2cf4bbd78e90d.tar.xz
libbu++-d61161061bd5998ef4b1fc2aaad2cf4bbd78e90d.zip
Started working on a CSV reader, it's pretty much done, the CSV writer is just
a shell, but I may finish it soon, and started work on NewLine, a filter that converts newlines in text streams between the different OS standards. Also added some more helper operators to fbasicstring.
Diffstat (limited to '')
-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