Kaynağa Gözat

Added AppendChar() to string builder.

woollybah 6 yıl önce
ebeveyn
işleme
e113b5b2d0

+ 1 - 0
stringbuilder.mod/common.bmx

@@ -59,6 +59,7 @@ Extern
 	Function bmx_stringbuilder_append_ulong(buffer:Byte Ptr, value:ULong)
 	Function bmx_stringbuilder_append_sizet(buffer:Byte Ptr, value:Size_T)
 	Function bmx_stringbuilder_append_shorts(buffer:Byte Ptr, shorts:Short Ptr, length:Int)
+	Function bmx_stringbuilder_append_char(buffer:Byte Ptr, value:Int)
 	Function bmx_stringbuilder_left:String(buffer:Byte Ptr, length:Int)
 	Function bmx_stringbuilder_right:String(buffer:Byte Ptr, length:Int)
 	

+ 7 - 0
stringbuilder.mod/glue.c

@@ -562,6 +562,13 @@ void bmx_stringbuilder_append_shorts(struct MaxStringBuilder * buf, short * shor
 	}	
 }
 
+void bmx_stringbuilder_append_char(struct MaxStringBuilder * buf, int value) {
+	bmx_stringbuilder_resize(buf, buf->count + 1);
+	BBChar * p = buf->buffer + buf->count;
+	*p = (BBChar)value;
+	buf->count++;
+}
+
 BBString * bmx_stringbuilder_left(struct MaxStringBuilder * buf, int length) {
 	if (length <= 0) {
 		return &bbEmptyString;

+ 8 - 0
stringbuilder.mod/stringbuilder.bmx

@@ -362,6 +362,14 @@ Public
 		Return Self
 	End Method
 	
+	Rem
+	bbdoc: Appends a character of the given @char code point to the string builder.
+	End Rem
+	Method AppendChar:TStringBuilder(char:Int)
+		bmx_stringbuilder_append_char(buffer, char)
+		Return Self
+	End Method
+	
 	Rem
 	bbdoc: Finds first occurance of a sub string.
 	returns: -1 if @subString not found.