#pragma once

namespace std {
	class string32 {
	public:
		union {
			char it[16];
			char* pit;
		};

		size_t length;
		size_t textlength;

		string32();
		string32(std::string str);

		char* c_str();
		void set(std::string str) {
			memset(this, 0, sizeof(std::string32));
			length = str.size();
			textlength = length | 0xF;
			if (str.size() < 16) {
				memcpy(it, str.c_str(), str.size());
				if (str.size() < 15)
					it[str.size()] = 0;
			}
			else {
				size_t size = str.size();
				if (size + 1 >= 0x1000)
					size += 8;

				pit = reinterpret_cast<char*>(malloc(size + 1));
				textlength = size;
				if (size + 1 >= 0x1000) {
					*reinterpret_cast<char**>(pit) = pit;
					pit += 8;
				}

				if (pit != 0x0) {
					memcpy(pit, str.c_str(), str.size());
					pit[str.size()] = 0;
				}
			}
		}
	};
}
