edits
[iotcloud.git] / version2 / src / C / IoTString.h
1 #ifndef IOTSTRING_H
2 #define IOTSTRING_H
3
4 #include "array.h"
5
6 /**
7  * IoTString wraps the underlying char string.
8  * @author Brian Demsky <bdemsky@uci.edu>
9  * @version 1.0
10  */
11
12 public class IoTString {
13 private:
14         Array<char> *array;
15         IoTString() {}
16
17         /**
18          * Builds an IoTString object around the char array.  This
19          * constructor makes a copy, so the caller is free to modify the char array.
20          */
21
22 public:
23         IoTString(Array<char> *_array) : array(new Array<char>(_array)) {}
24         ~IoTString() {}
25
26         /**
27          * Internal method to grab a reference to our char array.  Caller
28          * must not modify it.
29          */
30
31         Array<char> *internalBytes() { return array; }
32
33         /**
34          * Returns a copy of the underlying char string.
35          */
36
37         Array<char> *getBytes() { return new Array<Char>(&array); }
38
39         /**
40          * Returns the length in chars of the IoTString.
41          */
42
43         int length() { return array->length(); }
44         friend IoTString *IoTString_shallow(Array<char> *_array);
45 };
46
47 IoTString *IoTString_shallow(Array<char> *_array) {
48         IoTString *str = new IoTString();
49         str->array = _array;
50         return str;
51 }
52 #endif