From 0cca2d68451849b5ea96a3620566fd0b42dde3c0 Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Sun, 18 Oct 2009 21:56:26 +0200 Subject: More work on syscalls --- Source/Library/Common/String.class.cpp | 20 ++++++++++++++++++++ Source/Library/Common/String.class.h | 5 ++++- 2 files changed, 24 insertions(+), 1 deletion(-) (limited to 'Source/Library/Common') diff --git a/Source/Library/Common/String.class.cpp b/Source/Library/Common/String.class.cpp index d8913d9..c217807 100644 --- a/Source/Library/Common/String.class.cpp +++ b/Source/Library/Common/String.class.cpp @@ -49,6 +49,26 @@ String String::number(s32int number) { return ret; } +String String::unserialize(u32int w) { + u32int* a = (u32int*)w; + String ret; + ret.m_length = a[0]; + ret.m_string = (WChar*)Mem::alloc(a[0] * sizeof(WChar)); + for (u32int i = 0; i < a[0]; i++) { + ret[i] = a[i + 1]; + } + return ret; +} + +u32int String::serialize() { + u32int* x = (u32int*)Mem::mkXchgSpace((m_length + 1) * sizeof(u32int)); + x[0] = m_length; + for (u32int i = 0; i < m_length; i++) { + x[i + 1] = m_string[i]; + } + return (u32int)x; +} + String::String(const char* string, u8int encoding) { m_string = 0; m_length = 0; diff --git a/Source/Library/Common/String.class.h b/Source/Library/Common/String.class.h index 3e50d35..5db9858 100644 --- a/Source/Library/Common/String.class.h +++ b/Source/Library/Common/String.class.h @@ -9,6 +9,9 @@ class String : public BasicString { static String hex(u32int number); static String number(s32int number); + static String unserialize(u32int w); + u32int serialize(); + String(const char* string, u8int encoding = UE_UTF8); String() : BasicString() {} String(const String &other) : BasicString (other) {} @@ -34,7 +37,7 @@ class String : public BasicString { String operator+ (const String &other) const { return concat(other); } String operator+ (const char* other) const { return concat(other); } String operator+ (WChar other) const { return concat(other); } - + s64int toInt() const; //Convert from DEC u64int toInt16() const; //Convert from HEX -- cgit v1.2.3