aboutsummaryrefslogtreecommitdiff
path: root/src/csvwriter.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2010-04-23 15:14:00 +0000
committerMike Buland <eichlan@xagasoft.com>2010-04-23 15:14:00 +0000
commit801e7de1f85656746d832508baf4583907826420 (patch)
tree6e2639b6904ee8bcef2781420741124948c17f2c /src/csvwriter.cpp
parentd8a8c482b2f6b09ee8995b9563397a9b9bd135e8 (diff)
downloadlibbu++-801e7de1f85656746d832508baf4583907826420.tar.gz
libbu++-801e7de1f85656746d832508baf4583907826420.tar.bz2
libbu++-801e7de1f85656746d832508baf4583907826420.tar.xz
libbu++-801e7de1f85656746d832508baf4583907826420.zip
Minor updates to the List class, unchecked corner cases.
The CsvWriter now writes csv. It understands both excel formatting and c-style, which I made up myself (it's just c-style escape sequences). Sha1 is converted to work with the CryptoHash API and it does indeed work.
Diffstat (limited to 'src/csvwriter.cpp')
-rw-r--r--src/csvwriter.cpp38
1 files changed, 36 insertions, 2 deletions
diff --git a/src/csvwriter.cpp b/src/csvwriter.cpp
index 59a471f..3e2816b 100644
--- a/src/csvwriter.cpp
+++ b/src/csvwriter.cpp
@@ -34,13 +34,47 @@ Bu::CsvWriter::~CsvWriter()
34{ 34{
35} 35}
36 36
37void Bu::CsvWriter::writeLine( const StrArray &aStrs )
38{
39 Bu::FString sBuf;
40 for( StrArray::const_iterator i = aStrs.begin(); i; i++ )
41 {
42 if( i != aStrs.begin() )
43 sBuf += ",";
44 sBuf += sEncode( *i );
45 }
46 sBuf += "\n";
47
48 sOut.write( sBuf );
49}
50
37Bu::FString Bu::CsvWriter::encodeExcel( const Bu::FString &sIn ) 51Bu::FString Bu::CsvWriter::encodeExcel( const Bu::FString &sIn )
38{ 52{
39 return ""; 53 if( sIn.find('\"') )
54 {
55 Bu::FString sOut = "\"";
56 for( Bu::FString::const_iterator i = sIn.begin(); i; i++ )
57 {
58 if( *i == '\"' )
59 sOut += "\"\"";
60 else
61 sOut += *i;
62 }
63 return sOut;
64 }
65 return sIn;
40} 66}
41 67
42Bu::FString Bu::CsvWriter::encodeC( const Bu::FString &sIn ) 68Bu::FString Bu::CsvWriter::encodeC( const Bu::FString &sIn )
43{ 69{
44 return ""; 70 Bu::FString sOut = "";
71 for( Bu::FString::const_iterator i = sIn.begin(); i; i++ )
72 {
73 if( *i == ',' )
74 sOut += "\\,";
75 else
76 sOut += *i;
77 }
78 return sOut;
45} 79}
46 80