summaryrefslogtreecommitdiff
path: root/transpiler/MyString.h
diff options
context:
space:
mode:
authorMatthew Kosarek <mattkae@protonmail.com>2021-07-01 19:46:08 -0400
committerMatthew Kosarek <mattkae@protonmail.com>2021-07-01 19:46:08 -0400
commit4878f0fc6a039d220dd7adecb18d19c688ae50b0 (patch)
tree993893f1d894aedb350e86c759370c0e8c54c443 /transpiler/MyString.h
parent9f968320c83ce79f98006dec71674feff4686e3b (diff)
(mkosarek) Decent SAT description for now
Diffstat (limited to 'transpiler/MyString.h')
-rw-r--r--transpiler/MyString.h76
1 files changed, 0 insertions, 76 deletions
diff --git a/transpiler/MyString.h b/transpiler/MyString.h
deleted file mode 100644
index 805f5de..0000000
--- a/transpiler/MyString.h
+++ /dev/null
@@ -1,76 +0,0 @@
-#pragma once
-#include "List.h"
-
-struct StringView {
- bool error = false;
- char* value = nullptr;
- size_t length = 0;
-};
-
-struct String {
- const static int SSO_SIZE = 31;
-
- char defaultBuffer[String::SSO_SIZE + 1] = { '\0' };
- char* dynamicBuffer = nullptr;
-
- int length = 0;
- int capacity = 0;
- bool isSSO = true;
-
- String();
- String(const char* str);
- char* getValue();
- const char* getValueConst() const;
- void operator =(const char* str);
- void set(const char* str);
- void free();
- int toInteger();
- float toFloat();
- int indexOf(char c);
- inline bool equals(const String& other) { return strcmp(getValueConst(), other.getValueConst()) == 0; };
- inline bool equalsCstr(const char* str) { return strcmp(getValueConst(), str) == 0; };
- StringView substring(int start, int end);
-};
-
-struct StringBuffer {
- const static int BUFFER_SIZE = 31;
-
- int pointer = 0;
- char buffer[StringBuffer::BUFFER_SIZE + 1]; // Leave space for trailing escape character
-
- /*
- * Appends the string to the buffer
- * @param str
- * @returns number of characters copied
- */
- int add(const char* str);
- bool isFull();
- void reset();
-};
-
-struct StringBuilder {
- int bufferPointer = 0;
- int length = 0;
-
- StringBuffer defaultBuffer;
- List<StringBuffer> dynamicBuffer;
-
- StringBuffer* getCurrentBuffer();
- StringBuffer* getBufferAtIdx(int index);
- const StringBuffer* getBufferAtIdxConst(int index) const;
- void addStr(String* str);
- void addStr(const char* str, int length = -1);
- void addChar(char c);
- void format(const char* str, ...);
- void addInt(int value);
- void addFloat(float value);
- void replace(const char* strToReplace, const char* replaceStr);
- void removeAt(int index, int count);
- int indexOf(char c);
- int indexOf(const char* str);
- String toString();
- void clear();
- char getCharAtIdx(int index) const;
- void insert(char c, int index);
- void free();
-};