Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct STRING {
- STRING() {
- this->length = 0;
- this->width = 0;
- this->wtext[this->length] = L'\0';
- this->utext[this->length] = (unsigned char)'\0';
- this->text[this->length] = '\0';
- }
- STRING(const char c) {
- this->length = 0;
- this->width = 0;
- this->wtext[this->length] = L'\0';
- this->utext[this->length] = (unsigned char)'\0';
- this->text[this->length] = '\0';
- this->App(c);
- }
- STRING(const char text[]) {
- this->length = 0;
- this->width = 0;
- this->wtext[this->length] = L'\0';
- this->utext[this->length] = (unsigned char)'\0';
- this->text[this->length] = '\0';
- this->Write(text);
- }
- STRING(char* text) {
- this->length = 0;
- this->width = 0;
- this->wtext[this->length] = L'\0';
- this->utext[this->length] = (unsigned char)'\0';
- this->text[this->length] = '\0';
- this->Write(text);
- }
- STRING(wchar_t* text) {
- this->length = 0;
- this->width = 0;
- this->wtext[this->length] = L'\0';
- this->utext[this->length] = (unsigned char)'\0';
- this->text[this->length] = '\0';
- this->Write<wchar_t>(text);
- }
- STRING(const std::string string) {
- this->length = 0;
- this->width = 0;
- this->wtext[this->length] = L'\0';
- this->utext[this->length] = (unsigned char)'\0';
- this->text[this->length] = '\0';
- this->Write(string.c_str());
- }
- DINT length, width;
- wchar_t wtext[ENGINE_TEXT_MAX_LENGTH];
- char text[ENGINE_TEXT_MAX_LENGTH];
- unsigned char utext[ENGINE_TEXT_MAX_LENGTH];
- char operator[] (int position) {
- return this->text[position];
- }
- template<typename T = const char>
- void Write(T text[]) {
- for (this->length = 0; text[this->length] != '\0'; this->length++) {
- this->text[this->length] = (char)text[this->length];
- this->wtext[this->length] = (wchar_t)text[this->length];
- this->utext[this->length] = (unsigned char)text[this->length];
- }
- this->text[this->length] = '\0';
- this->wtext[this->length] = L'\0';
- this->utext[this->length] = (unsigned char)'\0';
- }
- template<typename T = const char>
- void Append(T text[]) {
- for (int t = 0; text[t] != '\0'; t++) {
- this->text[this->length] = (char)text[t];
- this->wtext[this->length] = (wchar_t)text[t];
- this->utext[this->length] = (unsigned char)text[t];
- this->length++;
- }
- this->text[this->length] = '\0';
- this->wtext[this->length] = L'\0';
- this->utext[this->length] = (unsigned char)'\0';
- }
- template<typename T = const char>
- void Space(T text[]) {
- this->App(' ');
- this->Append(text);
- }
- template<typename T = const char>
- void App(T c) {
- this->text[this->length] = (char)c;
- this->wtext[this->length] = (wchar_t)c;
- this->utext[this->length] = (unsigned char)c;
- this->length++;
- this->text[this->length] = '\0';
- this->wtext[this->length] = L'\0';
- this->utext[this->length] = (unsigned char)'\0';
- }
- bool Has(const char character) {
- for (int i = 0; i < this->length; i++) {
- if (this->text[i] == character) return true;
- }
- return false;
- }
- void _dump() {
- std::cout << "\n>STRING: [" << this->width << ", " << this->length << "] " << this->text;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment