Selaa lähdekoodia

Added AppendCStringBytes() method.

Brucey 2 vuotta sitten
vanhempi
commit
1aa02b9509

+ 1 - 0
stringbuilder.mod/common.bmx

@@ -48,6 +48,7 @@ Extern
 	Function bmx_stringbuilder_charat:Int(buffer:Byte Ptr, index:Int)
 	Function bmx_stringbuilder_removecharat(buffer:Byte Ptr, index:Int)
 	Function bmx_stringbuilder_append_cstring(buffer:Byte Ptr, chars:Byte Ptr)
+	Function bmx_stringbuilder_append_cstringbytes(buffer:Byte Ptr, chars:Byte Ptr, length:Int)
 	Function bmx_stringbuilder_append_utf8string(buffer:Byte Ptr, chars:Byte Ptr)
 	Function bmx_stringbuilder_append_utf8bytes(buffer:Byte Ptr, chars:Byte Ptr, length:Int)
 	Function bmx_stringbuilder_append_double(buffer:Byte Ptr, value:Double)

+ 4 - 0
stringbuilder.mod/glue.c

@@ -463,6 +463,10 @@ void bmx_stringbuilder_removecharat(struct MaxStringBuilder * buf, int index) {
 
 void bmx_stringbuilder_append_cstring(struct MaxStringBuilder * buf, const char * chars) {
 	int length = strlen(chars);
+	bmx_stringbuilder_append_cstringbytes(buf, chars, length);
+}
+
+void bmx_stringbuilder_append_cstringbytes(struct MaxStringBuilder * buf, const char * chars, int length) {
 	if (length > 0) {
 		int count = length;
 		

+ 1 - 0
stringbuilder.mod/glue.h

@@ -66,6 +66,7 @@ void bmx_stringbuilder_setcharat(struct MaxStringBuilder * buf, int index, int c
 int bmx_stringbuilder_charat(struct MaxStringBuilder * buf, int index);
 void bmx_stringbuilder_removecharat(struct MaxStringBuilder * buf, int index);
 void bmx_stringbuilder_append_cstring(struct MaxStringBuilder * buf, const char * chars);
+void bmx_stringbuilder_append_cstringbytes(struct MaxStringBuilder * buf, const char * chars, int length);
 void bmx_stringbuilder_append_utf8string(struct MaxStringBuilder * buf, const char * chars);
 void bmx_stringbuilder_append_utf8bytes(struct MaxStringBuilder * buf, const char * chars, int length);
 void bmx_stringbuilder_append_double(struct MaxStringBuilder * buf, double value);

+ 12 - 2
stringbuilder.mod/stringbuilder.bmx

@@ -23,10 +23,12 @@ bbdoc: A string builder.
 End Rem	
 Module BRL.StringBuilder
 
-ModuleInfo "Version: 1.16"
+ModuleInfo "Version: 1.17"
 ModuleInfo "License: zlib/libpng"
 ModuleInfo "Copyright: 2018-2022 Bruce A Henderson"
 
+ModuleInfo "History: 1.17"
+ModuleInfo "History: Added AppendCStringBytes() method."
 ModuleInfo "History: 1.16"
 ModuleInfo "History: Added AppendUTF32() and AppendUTF32Bytes() method."
 ModuleInfo "History: 1.15"
@@ -224,7 +226,15 @@ Public
 		bmx_stringbuilder_append_cstring(buffer, chars)
 		Return Self
 	End Method
-	
+
+	Rem
+	bbdoc: Appends a C string of @length bytes onto the string builder.
+	End Rem
+	Method AppendCStringBytes:TStringBuilder(chars:Byte Ptr, length:Int)
+		bmx_stringbuilder_append_cstringbytes(buffer, chars, length)
+		Return Self
+	End Method
+
 	Rem
 	bbdoc: Appends a #Double value to the string builder.
 	End Rem