diff options
author | Mike Buland <eichlan@xagasoft.com> | 2012-11-05 22:41:51 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2012-11-05 22:41:51 +0000 |
commit | ec05778d5718a7912e506764d443a78d6a6179e3 (patch) | |
tree | 78a9a01532180030c095acefc45763f07c14edb8 /src/stable/csvreader.cpp | |
parent | b20414ac1fe80a71a90601f4cd1767fa7014a9ba (diff) | |
download | libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.gz libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.bz2 libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.tar.xz libbu++-ec05778d5718a7912e506764d443a78d6a6179e3.zip |
Converted tabs to spaces with tabconv.
Diffstat (limited to 'src/stable/csvreader.cpp')
-rw-r--r-- | src/stable/csvreader.cpp | 118 |
1 files changed, 59 insertions, 59 deletions
diff --git a/src/stable/csvreader.cpp b/src/stable/csvreader.cpp index ddc68f0..c27c8ee 100644 --- a/src/stable/csvreader.cpp +++ b/src/stable/csvreader.cpp | |||
@@ -12,24 +12,24 @@ | |||
12 | using namespace Bu; | 12 | using namespace Bu; |
13 | 13 | ||
14 | Bu::CsvReader::CsvReader( Bu::Stream &sIn, Bu::CsvReader::Style eStyle ) : | 14 | Bu::CsvReader::CsvReader( Bu::Stream &sIn, Bu::CsvReader::Style eStyle ) : |
15 | sIn( sIn ) | 15 | sIn( sIn ) |
16 | { | 16 | { |
17 | switch( eStyle ) | 17 | switch( eStyle ) |
18 | { | 18 | { |
19 | case styleExcel: | 19 | case styleExcel: |
20 | sDecode = Bu::slot( &decodeExcel ); | 20 | sDecode = Bu::slot( &decodeExcel ); |
21 | break; | 21 | break; |
22 | 22 | ||
23 | case styleC: | 23 | case styleC: |
24 | sDecode = Bu::slot( &decodeC ); | 24 | sDecode = Bu::slot( &decodeC ); |
25 | break; | 25 | break; |
26 | } | 26 | } |
27 | } | 27 | } |
28 | 28 | ||
29 | Bu::CsvReader::CsvReader( Bu::Stream &sIn, | 29 | Bu::CsvReader::CsvReader( Bu::Stream &sIn, |
30 | Bu::CsvReader::DecodeSignal sDecode ) : | 30 | Bu::CsvReader::DecodeSignal sDecode ) : |
31 | sIn( sIn ), | 31 | sIn( sIn ), |
32 | sDecode( sDecode ) | 32 | sDecode( sDecode ) |
33 | { | 33 | { |
34 | } | 34 | } |
35 | 35 | ||
@@ -39,61 +39,61 @@ Bu::CsvReader::~CsvReader() | |||
39 | 39 | ||
40 | Bu::StrArray Bu::CsvReader::readLine() | 40 | Bu::StrArray Bu::CsvReader::readLine() |
41 | { | 41 | { |
42 | Bu::StrArray aVals; | 42 | Bu::StrArray aVals; |
43 | 43 | ||
44 | Bu::String sLine = sIn.readLine(); | 44 | Bu::String sLine = sIn.readLine(); |
45 | 45 | ||
46 | if( !sLine.isSet() ) | 46 | if( !sLine.isSet() ) |
47 | return Bu::StrArray(); | 47 | return Bu::StrArray(); |
48 | 48 | ||
49 | Bu::String::iterator i = sLine.begin(); | 49 | Bu::String::iterator i = sLine.begin(); |
50 | 50 | ||
51 | aVals.append( sDecode( i ) ); | 51 | aVals.append( sDecode( i ) ); |
52 | 52 | ||
53 | while( i ) | 53 | while( i ) |
54 | { | 54 | { |
55 | if( *i == ',' ) | 55 | if( *i == ',' ) |
56 | { | 56 | { |
57 | i++; | 57 | i++; |
58 | if( !i ) | 58 | if( !i ) |
59 | { | 59 | { |
60 | aVals.append(""); | 60 | aVals.append(""); |
61 | break; | 61 | break; |
62 | } | 62 | } |
63 | aVals.append( sDecode( i ) ); | 63 | aVals.append( sDecode( i ) ); |
64 | } | 64 | } |
65 | else | 65 | else |
66 | { | 66 | { |
67 | // Blanks and stuff? | 67 | // Blanks and stuff? |
68 | sio << "Out of bound: '" << *i << "'" << sio.nl; | 68 | sio << "Out of bound: '" << *i << "'" << sio.nl; |
69 | i++; | 69 | i++; |
70 | } | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
73 | return aVals; | 73 | return aVals; |
74 | } | 74 | } |
75 | 75 | ||
76 | Bu::String Bu::CsvReader::decodeExcel( Bu::String::iterator &i ) | 76 | Bu::String Bu::CsvReader::decodeExcel( Bu::String::iterator &i ) |
77 | { | 77 | { |
78 | Bu::String sRet; | 78 | Bu::String sRet; |
79 | 79 | ||
80 | for(; i && (*i == ' ' || *i == '\t'); i++ ) { } | 80 | for(; i && (*i == ' ' || *i == '\t'); i++ ) { } |
81 | 81 | ||
82 | if( !i ) | 82 | if( !i ) |
83 | return sRet; | 83 | return sRet; |
84 | 84 | ||
85 | if( *i == '\"' ) | 85 | if( *i == '\"' ) |
86 | { | 86 | { |
87 | for( i++ ; i; i++ ) | 87 | for( i++ ; i; i++ ) |
88 | { | 88 | { |
89 | if( *i == '\"' ) | 89 | if( *i == '\"' ) |
90 | { | 90 | { |
91 | i++; | 91 | i++; |
92 | if( !i ) | 92 | if( !i ) |
93 | { | 93 | { |
94 | return sRet; | 94 | return sRet; |
95 | } | 95 | } |
96 | else if( *i == '\"' ) | 96 | else if( *i == '\"' ) |
97 | { | 97 | { |
98 | sRet += *i; | 98 | sRet += *i; |
99 | } | 99 | } |