summaryrefslogtreecommitdiff
path: root/Source/Library/Common
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-10-18 21:56:26 +0200
committerAlexis211 <alexis211@gmail.com>2009-10-18 21:56:26 +0200
commit0cca2d68451849b5ea96a3620566fd0b42dde3c0 (patch)
treefcdcaace870a59d0b8f2ccc6abb8418763960dbe /Source/Library/Common
parent776753bfa0c411f4b1a5680409104904961fcbeb (diff)
downloadMelon-0cca2d68451849b5ea96a3620566fd0b42dde3c0.tar.gz
Melon-0cca2d68451849b5ea96a3620566fd0b42dde3c0.zip
More work on syscalls
Diffstat (limited to 'Source/Library/Common')
-rw-r--r--Source/Library/Common/String.class.cpp20
-rw-r--r--Source/Library/Common/String.class.h5
2 files changed, 24 insertions, 1 deletions
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<WChar> {
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<WChar>() {}
String(const String &other) : BasicString<WChar> (other) {}
@@ -34,7 +37,7 @@ class String : public BasicString<WChar> {
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