From d61161061bd5998ef4b1fc2aaad2cf4bbd78e90d Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 11 Feb 2010 00:38:09 +0000 Subject: 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. --- src/tests/csv.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/tests/csv.cpp (limited to 'src/tests') 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 @@ +#include "bu/optparser.h" +#include "bu/file.h" +#include "bu/newline.h" +#include "bu/csvreader.h" +#include "bu/sio.h" + +using namespace Bu; + +class Options : public OptParser +{ +public: + Options( int argc, char *argv[] ) + { + addOption( slot( this, &Options::onRead ), 'r', "read", + "Read and display a csv file." ); + + addHelpOption(); + + parse( argc, argv ); + } + + int onRead( StrArray aArgs ) + { + File fIn( aArgs[1], File::Read ); + NewLine nlIn( fIn ); + CsvReader rCsv( nlIn ); + while( !fIn.isEos() ) + { + sio << rCsv.readLine() << sio.nl; + } + sio << sio.nl; + return 1; + } +}; + +int main( int argc, char *argv[] ) +{ + Options opts( argc, argv ); + return 0; +} + -- cgit v1.2.3