sdk: const correctness
[sdk] / extras / types / DynamicString.ec
index afedfe4..67056e0 100644 (file)
@@ -1,8 +1,12 @@
+#ifdef ECERE_STATIC
+public import static "ecere"
+#endif
+
 #include <stdarg.h>
 
 extern int isblank(int c);
 
-class DynamicString : Array<char>
+public class DynamicString : Array<char>
 {
    minAllocSize = 1024;
 
@@ -27,7 +31,18 @@ class DynamicString : Array<char>
       get { return array; }
    }
 
-   void concat(String s)
+   const char * OnGetString(char * tempString, void * fieldData, bool * needClass)
+   {
+      return array;
+   }
+
+   bool OnGetDataFromString(const char * string)
+   {
+      this = (DynamicString)(char *)string;
+      return true;
+   }
+
+   void concat(const String s)
    {
       int len = strlen(s);
       if(len)
@@ -39,13 +54,14 @@ class DynamicString : Array<char>
       }
    }
 
-   void concatf(char * format, ...)
+   void concatf(const char * format, ...)
    {
       // TODO: improve this to vsprinf directly in the Array<char> instead of calling concat
       char string[MAX_F_STRING];
       va_list args;
       va_start(args, format);
-      vsprintf(string, format, args);
+      vsnprintf(string, sizeof(string), format, args);
+      string[sizeof(string)-1] = 0;
       va_end(args);
       concat(string);
    }
@@ -55,9 +71,9 @@ class DynamicString : Array<char>
       // TODO: improve this to work directly on the Array<char> instead of calling PrintStdArgsToBuffer
       char string[MAX_F_STRING];
       va_list args;
-      int len;
+      //int len;
       va_start(args, object);
-      len = PrintStdArgsToBuffer(string, sizeof(string), object, args);
+      /*len = */PrintStdArgsToBuffer(string, sizeof(string), object, args);
       concat(string);
       va_end(args);
    }