summaryrefslogtreecommitdiff
path: root/src/newline.cpp
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/newline.cpp
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 'src/newline.cpp')
-rw-r--r--src/newline.cpp56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/newline.cpp b/src/newline.cpp
new file mode 100644
index 0000000..0dbbae5
--- /dev/null
+++ b/src/newline.cpp
@@ -0,0 +1,56 @@
1#include "bu/newline.h"
2
3Bu::NewLine::NewLine( Bu::Stream &rNext ) :
4 Bu::Filter( rNext ),
5 bExChar( false )
6{
7}
8
9Bu::NewLine::~NewLine()
10{
11}
12
13void Bu::NewLine::start()
14{
15}
16
17size_t Bu::NewLine::stop()
18{
19 return 0;
20}
21
22size_t Bu::NewLine::read( void *pBuf, size_t iAmnt )
23{
24 size_t iRead = rNext.read( pBuf, iAmnt );
25 size_t iOffset = 0;
26
27 for( size_t i = 0; i < iRead; i++ )
28 {
29 if( pBuf[i] == '\r' )
30 {
31 pBuf[i+iOffset] = '\n';
32 if( pBuf[j+1] == '\n' )
33 {
34 iOffset--;
35 }
36 }
37 else if( pBuf[i] == '\n' )
38 {
39 if( pBuf[j+1] == '\r' )
40 {
41 iOffset--;
42 }
43 }
44 else if( iOffset )
45 {
46 pBuf[i+iOffset] = pBuf[i];
47 }
48 }
49
50 iRead += iOffset;
51}
52
53size_t Bu::NewLine::write( const void *pBuf, size_t iAmnt )
54{
55}
56