#define IOTSTRING_H
#include "array.h"
-
+#include <string.h>
/**
* IoTString wraps the underlying char string.
* @author Brian Demsky <bdemsky@uci.edu>
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
* 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);
};