edits
[iotcloud.git] / version2 / src / C / IoTString.h
index f22324b84e43e9fefdac44adb23822c5320b73ab..a7343db5bf0b564d5c1124642f5fa6aef3bd7092 100644 (file)
@@ -2,7 +2,7 @@
 #define IOTSTRING_H
 
 #include "array.h"
-
+#include <string.h>
 /**
  * IoTString wraps the underlying char string.
  * @author Brian Demsky <bdemsky@uci.edu>
@@ -21,7 +21,15 @@ private:
 
 public:
        IoTString(Array<char> *_array) : array(new Array<char>(_array)) {}
-       ~IoTString() {}
+       IoTString(const char *_array) {
+               int32_t len = strlen(_array);
+               array = new Array<char>(len);
+               strcpy(array->internalArray(), _array);
+       }
+
+       ~IoTString() {
+               delete array;
+       }
 
        /**
         * Internal method to grab a reference to our char array.  Caller
@@ -40,6 +48,16 @@ public:
         * Returns the length in chars of the IoTString.
         */
 
+       bool equals(IoTString *str) {
+               uint strlength = str->array->length();
+               uint thislength = array->length();
+               if (strlength != thislength)
+                       return false;
+
+               int result = memcmp(str->array->internalArray(), array->internalArray(), strlength);
+               return result == 0;
+       }
+
        int length() { return array->length(); }
        friend IoTString *IoTString_shallow(Array<char> *_array);
 };