27 #include "BuiltInObjectTypeIDs.h"
29 #define CAN_FIT_IN_DATA(len) (len <= sizeof(decltype(data().getOffset())))
40 data().setExactTypeInfoValue(1);
51 int len = strlen(toMe) + 1;
53 if (
data().getExactTypeInfoValue() < 0) {
56 data().setExactTypeInfoValue(len);
58 if (
data().getExactTypeInfoValue() >= 0) {
61 data() = makeObjectWithExtraStorage<char>((len - 1) *
sizeof(
char));
62 data().setExactTypeInfoValue(-len);
65 memmove(
c_str(), toMe, len);
72 if (s.
data().getExactTypeInfoValue() >= 0) {
73 data().setOffset(s.
data().getOffset());
81 data().setExactTypeInfoValue(s.
data().getExactTypeInfoValue());
85 if (
data().getExactTypeInfoValue() < -1) {
93 std::cout <<
"Assigning to myself!!!!\n";
98 if (s.
data().getExactTypeInfoValue() >= 0) {
99 if (
data().getExactTypeInfoValue() < 0) {
102 data().setOffset(s.
data().getOffset());
106 if (
data().getExactTypeInfoValue() >= 0) {
107 data().setOffset(-1);
111 data().setExactTypeInfoValue(s.
data().getExactTypeInfoValue());
116 int len = s.
size() + 1;
118 if (
data().getExactTypeInfoValue() < 0) {
121 data().setExactTypeInfoValue(len);
123 if (
data().getExactTypeInfoValue() >= 0) {
124 data().setOffset(-1);
126 data() = makeObjectWithExtraStorage<char>((len - 1) *
sizeof(
char));
127 data().setExactTypeInfoValue(-len);
130 memmove(
c_str(), s.c_str(), len);
135 int len = strlen(toMe) + 1;
137 data().setExactTypeInfoValue(len);
139 data().setOffset(-1);
140 data() = makeObjectWithExtraStorage<char>((len - 1) *
sizeof(
char));
141 data().setExactTypeInfoValue(-len);
144 memmove(
c_str(), toMe, len);
151 data().setExactTypeInfoValue(len);
153 data().setOffset(-1);
154 data() = makeObjectWithExtraStorage<char>((len - 1) *
sizeof(
char));
155 data().setExactTypeInfoValue(-len);
158 memmove(
c_str(), toMe, len - 1);
159 c_str()[len - 1] = 0;
163 int len = s.size() + 1;
166 data().setExactTypeInfoValue(len);
168 data().setOffset(-1);
169 data() = makeObjectWithExtraStorage<char>((len - 1) *
sizeof(
char));
170 data().setExactTypeInfoValue(-len);
173 memmove(
c_str(), s.c_str(), len);
177 return c_str()[whichOne];
180 inline String::operator std::string()
const {
181 return std::string(c_str());
186 if (
data().getExactTypeInfoValue() >= 0) {
187 return (
char*)&
data();
194 if (
data().getExactTypeInfoValue() >= 0) {
195 return data().getExactTypeInfoValue();
197 return -
data().getExactTypeInfoValue();
202 char* returnVal = printMe.
c_str();
212 return strcmp(
c_str(), toMe.c_str()) == 0;
216 return strcmp(
c_str(), toMe) == 0;
224 return strcmp(
c_str(), toMe.c_str()) != 0;
228 return strcmp(
c_str(), toMe) != 0;
233 std::string str =
c_str();
234 int len1 = str.length();
235 int len2 = suffix.length();
237 return (str.compare(len1 - len2, len2, suffix) == 0);
String & operator=(const char *toMe)
Handle< char > & data() const
bool operator!=(const String &toMe)
bool endsWith(const std::string &suffix)
size_t hashMe(char *me, size_t len)
bool operator==(const String &toMe)
char & operator[](int whichOne)
char storage[sizeof(Handle< char >)]
#define CAN_FIT_IN_DATA(len)
std::ostream & operator<<(std::ostream &stream, const String &printMe)