summaryrefslogtreecommitdiff
path: root/include/sized_string.h
diff options
context:
space:
mode:
authorrobojumper <robojumper@gmail.com>2024-11-24 12:18:00 +0100
committerrobojumper <robojumper@gmail.com>2024-11-24 13:04:46 +0100
commit2f9a33d106f46c96b1da2f8ff5cedf6e000cb9a5 (patch)
tree20b564833242f6cde78a100ee545d26b745c1fae /include/sized_string.h
parent547fcc4d21fe363677282015c4f09f0b21bb48bd (diff)
More map
Diffstat (limited to 'include/sized_string.h')
-rw-r--r--include/sized_string.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/include/sized_string.h b/include/sized_string.h
index 9d06409b..c1aac98b 100644
--- a/include/sized_string.h
+++ b/include/sized_string.h
@@ -78,4 +78,35 @@ struct SizedString {
}
};
+// TODO this might be a shared template with SizedString but I'm
+// not sure how to write the inline functions
+template <size_t Size>
+struct SizedWString {
+ SizedWString() {
+ mChars[0] = '\0';
+ }
+
+ wchar_t mChars[Size];
+
+ operator wchar_t *() {
+ return mChars;
+ }
+
+ operator const wchar_t *() const {
+ return mChars;
+ }
+
+ int sprintf(const wchar_t *fmt, ...) {
+ va_list args;
+ va_start(args, fmt);
+
+ int printed = vswprintf(this->mChars, Size, fmt, args);
+ if (printed != wcslen(this->mChars)) {
+ this->mChars[0] = '\0';
+ }
+ va_end(list);
+ return printed;
+ }
+};
+
#endif