aboutsummaryrefslogtreecommitdiff
path: root/src/tafwriter.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2008-12-12 08:13:34 +0000
committerMike Buland <eichlan@xagasoft.com>2008-12-12 08:13:34 +0000
commit7c8e31fc057859d08610f17f669fdfcaf2fc2956 (patch)
tree2d645e85abab60a40091f3e676fcae78fe477148 /src/tafwriter.cpp
parenta36df989b1a603474345d792a1f9bc7d375a59ef (diff)
downloadlibbu++-7c8e31fc057859d08610f17f669fdfcaf2fc2956.tar.gz
libbu++-7c8e31fc057859d08610f17f669fdfcaf2fc2956.tar.bz2
libbu++-7c8e31fc057859d08610f17f669fdfcaf2fc2956.tar.xz
libbu++-7c8e31fc057859d08610f17f669fdfcaf2fc2956.zip
All of those changes I thought I'd already committed. The taf writer handles
binary data much better, actually escaping it properly and not stopping on null. Bu::FString has an iterator, it's actually just a raw datatype, but it may have more function later, so careful assuming that it's a char and using it in any non-iterator like way. Also augmented the taf unit test, and added the Bu::CacheCalc base class, the rest of the simple develpment cycle will happen between here and project hhp.
Diffstat (limited to '')
-rw-r--r--src/tafwriter.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/tafwriter.cpp b/src/tafwriter.cpp
index c30bc67..8e5fcdc 100644
--- a/src/tafwriter.cpp
+++ b/src/tafwriter.cpp
@@ -93,12 +93,18 @@ void Bu::TafWriter::writeString( const Bu::FString &str )
93 if( str.getStr() == NULL ) 93 if( str.getStr() == NULL )
94 return; 94 return;
95 sOut.write("\"", 1 ); 95 sOut.write("\"", 1 );
96 for( const char *s = str.getStr(); *s; s++ ) 96 for( Bu::FString::const_iterator s = str.begin(); s != str.end(); s++ )
97 { 97 {
98 if( *s == '\"' ) 98 if( *s == '\"' )
99 sOut.write("\\\"", 2 ); 99 sOut.write("\\\"", 2 );
100 else if( *s == '\\' ) 100 else if( *s == '\\' )
101 sOut.write("\\\\", 2 ); 101 sOut.write("\\\\", 2 );
102 else if( *s < 32 || *s > 126 )
103 {
104 char buf[5];
105 sprintf( buf, "\\x%02X", (unsigned char)*s );
106 sOut.write(buf, 4 );
107 }
102 else 108 else
103 sOut.write( s, 1 ); 109 sOut.write( s, 1 );
104 } 110 }