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/csvwriter.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/csvwriter.cpp')
-rw-r--r-- | src/stable/csvwriter.cpp | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/src/stable/csvwriter.cpp b/src/stable/csvwriter.cpp index a89b309..8b51115 100644 --- a/src/stable/csvwriter.cpp +++ b/src/stable/csvwriter.cpp | |||
@@ -9,24 +9,24 @@ | |||
9 | #include "bu/stream.h" | 9 | #include "bu/stream.h" |
10 | 10 | ||
11 | Bu::CsvWriter::CsvWriter( Bu::Stream &sOut, Bu::CsvWriter::Style eStyle ) : | 11 | Bu::CsvWriter::CsvWriter( Bu::Stream &sOut, Bu::CsvWriter::Style eStyle ) : |
12 | sOut( sOut ) | 12 | sOut( sOut ) |
13 | { | 13 | { |
14 | switch( eStyle ) | 14 | switch( eStyle ) |
15 | { | 15 | { |
16 | case styleExcel: | 16 | case styleExcel: |
17 | sEncode = Bu::slot( &encodeExcel ); | 17 | sEncode = Bu::slot( &encodeExcel ); |
18 | break; | 18 | break; |
19 | 19 | ||
20 | case styleC: | 20 | case styleC: |
21 | sEncode = Bu::slot( &encodeExcel ); | 21 | sEncode = Bu::slot( &encodeExcel ); |
22 | break; | 22 | break; |
23 | } | 23 | } |
24 | } | 24 | } |
25 | 25 | ||
26 | Bu::CsvWriter::CsvWriter( Bu::Stream &sOut, | 26 | Bu::CsvWriter::CsvWriter( Bu::Stream &sOut, |
27 | Bu::CsvWriter::EncodeSignal sEncode ) : | 27 | Bu::CsvWriter::EncodeSignal sEncode ) : |
28 | sOut( sOut ), | 28 | sOut( sOut ), |
29 | sEncode( sEncode ) | 29 | sEncode( sEncode ) |
30 | { | 30 | { |
31 | } | 31 | } |
32 | 32 | ||
@@ -36,46 +36,46 @@ Bu::CsvWriter::~CsvWriter() | |||
36 | 36 | ||
37 | void Bu::CsvWriter::writeLine( const StrArray &aStrs ) | 37 | void Bu::CsvWriter::writeLine( const StrArray &aStrs ) |
38 | { | 38 | { |
39 | Bu::String sBuf; | 39 | Bu::String sBuf; |
40 | for( StrArray::const_iterator i = aStrs.begin(); i; i++ ) | 40 | for( StrArray::const_iterator i = aStrs.begin(); i; i++ ) |
41 | { | 41 | { |
42 | if( i != aStrs.begin() ) | 42 | if( i != aStrs.begin() ) |
43 | sBuf += ","; | 43 | sBuf += ","; |
44 | sBuf += sEncode( *i ); | 44 | sBuf += sEncode( *i ); |
45 | } | 45 | } |
46 | sBuf += "\n"; | 46 | sBuf += "\n"; |
47 | 47 | ||
48 | sOut.write( sBuf ); | 48 | sOut.write( sBuf ); |
49 | } | 49 | } |
50 | 50 | ||
51 | Bu::String Bu::CsvWriter::encodeExcel( const Bu::String &sIn ) | 51 | Bu::String Bu::CsvWriter::encodeExcel( const Bu::String &sIn ) |
52 | { | 52 | { |
53 | if( sIn.find('\"') || sIn.find(',') ) | 53 | if( sIn.find('\"') || sIn.find(',') ) |
54 | { | 54 | { |
55 | Bu::String sOut = "\""; | 55 | Bu::String sOut = "\""; |
56 | for( Bu::String::const_iterator i = sIn.begin(); i; i++ ) | 56 | for( Bu::String::const_iterator i = sIn.begin(); i; i++ ) |
57 | { | 57 | { |
58 | if( *i == '\"' ) | 58 | if( *i == '\"' ) |
59 | sOut += "\"\""; | 59 | sOut += "\"\""; |
60 | else | 60 | else |
61 | sOut += *i; | 61 | sOut += *i; |
62 | } | 62 | } |
63 | sOut += '\"'; | 63 | sOut += '\"'; |
64 | return sOut; | 64 | return sOut; |
65 | } | 65 | } |
66 | return sIn; | 66 | return sIn; |
67 | } | 67 | } |
68 | 68 | ||
69 | Bu::String Bu::CsvWriter::encodeC( const Bu::String &sIn ) | 69 | Bu::String Bu::CsvWriter::encodeC( const Bu::String &sIn ) |
70 | { | 70 | { |
71 | Bu::String sOut = ""; | 71 | Bu::String sOut = ""; |
72 | for( Bu::String::const_iterator i = sIn.begin(); i; i++ ) | 72 | for( Bu::String::const_iterator i = sIn.begin(); i; i++ ) |
73 | { | 73 | { |
74 | if( *i == ',' ) | 74 | if( *i == ',' ) |
75 | sOut += "\\,"; | 75 | sOut += "\\,"; |
76 | else | 76 | else |
77 | sOut += *i; | 77 | sOut += *i; |
78 | } | 78 | } |
79 | return sOut; | 79 | return sOut; |
80 | } | 80 | } |
81 | 81 | ||