diff options
author | Alexis211 <alexis211@gmail.com> | 2009-09-11 16:22:30 +0200 |
---|---|---|
committer | Alexis211 <alexis211@gmail.com> | 2009-09-11 16:22:30 +0200 |
commit | 7b0d6ac9f903296c7537cec9ac606d49cb364049 (patch) | |
tree | c9bc6aaf4e7237cf5577f3a78291f1f591fe1563 /Source/Kernel/Library | |
parent | d95452c5452b4ca7418505fa5597f000596fcb78 (diff) | |
download | Melon-7b0d6ac9f903296c7537cec9ac606d49cb364049.tar.gz Melon-7b0d6ac9f903296c7537cec9ac606d49cb364049.zip |
Nothing, really
Diffstat (limited to 'Source/Kernel/Library')
-rw-r--r-- | Source/Kernel/Library/String.class.cpp | 38 | ||||
-rw-r--r-- | Source/Kernel/Library/String.class.h | 12 | ||||
-rw-r--r-- | Source/Kernel/Library/WChar.class.cpp (renamed from Source/Kernel/Library/wchar.class.cpp) | 18 | ||||
-rw-r--r-- | Source/Kernel/Library/WChar.class.h (renamed from Source/Kernel/Library/wchar.class.h) | 22 |
4 files changed, 45 insertions, 45 deletions
diff --git a/Source/Kernel/Library/String.class.cpp b/Source/Kernel/Library/String.class.cpp index 518d8c9..e70d19f 100644 --- a/Source/Kernel/Library/String.class.cpp +++ b/Source/Kernel/Library/String.class.cpp @@ -6,7 +6,7 @@ using namespace CMem; //strlen and memcpy String String::hex(u32int number) { String ret; ret.m_length = 10; - ret.m_string = new wchar[11]; + ret.m_string = new WChar[11]; ret.m_string[0] = '0'; ret.m_string[1] = 'x'; ret.m_string[10] = 0; @@ -35,7 +35,7 @@ String String::number(s32int number) { String ret; ret.m_length = order; - ret.m_string = new wchar[order + 1]; + ret.m_string = new WChar[order + 1]; for (u32int i = order; i > 0; i--) { ret.m_string[i - 1] = numbers[number % 10]; @@ -55,12 +55,12 @@ String::String() { } String::String(char* string) { - m_length = wchar::utf8len(string); + m_length = WChar::utf8len(string); if (m_length == 0) { m_string = 0; return; } - m_string = new wchar[m_length + 1]; + m_string = new WChar[m_length + 1]; int i = 0, l = strlen(string), c = 0; while (i < l) { i += m_string[c].affectUtf8(string + i); @@ -75,7 +75,7 @@ String::String(const String &other) { m_string = 0; return; } - m_string = new wchar[m_length + 1]; + m_string = new WChar[m_length + 1]; for (u32int i = 0; i < m_length; i++) { m_string[i] = other.m_string[i]; } @@ -93,7 +93,7 @@ void String::operator= (const String &other) { m_string = 0; return; } - m_string = new wchar[m_length + 1]; + m_string = new WChar[m_length + 1]; for (u32int i = 0; i < m_length; i++) { m_string[i] = other.m_string[i]; } @@ -101,13 +101,13 @@ void String::operator= (const String &other) { } void String::operator= (char* string) { - m_length = wchar::utf8len(string); + m_length = WChar::utf8len(string); if (m_string != 0) delete [] m_string; if (m_length == 0) { m_string = 0; return; } - m_string = new wchar[m_length + 1]; + m_string = new WChar[m_length + 1]; int i = 0, l = strlen(string), c = 0; while (i < l) { i += m_string[c].affectUtf8(string + i); @@ -125,9 +125,9 @@ bool String::operator== (String &other) { } bool String::operator== (char* string) { - if (m_length != wchar::utf8len(string)) return false; + if (m_length != WChar::utf8len(string)) return false; int i = 0, l = strlen(string), c = 0; - wchar tmp; + WChar tmp; while (i < l) { i += tmp.affectUtf8(string + i); if (m_string[c] != tmp) return false; @@ -137,7 +137,7 @@ bool String::operator== (char* string) { } String& String::operator+= (String &other) { - wchar* newdata = new wchar[m_length + other.m_length + 1]; + WChar* newdata = new WChar[m_length + other.m_length + 1]; for (u32int i = 0; i < m_length; i++) { newdata[i] = m_string[i]; } @@ -152,7 +152,7 @@ String& String::operator+= (String &other) { } String& String::operator+= (char* other) { - wchar* newdata = new wchar[m_length + wchar::utf8len(other) + 1]; + WChar* newdata = new WChar[m_length + WChar::utf8len(other) + 1]; for (u32int i = 0; i < m_length; i++) { newdata[i] = m_string[i]; } @@ -168,8 +168,8 @@ String& String::operator+= (char* other) { return *this; } -String& String::operator+= (wchar other) { - wchar* newdata = new wchar[m_length + 2]; +String& String::operator+= (WChar other) { + WChar* newdata = new WChar[m_length + 2]; for (u32int i = 0; i < m_length; i++) { newdata[i] = m_string[i]; } @@ -191,7 +191,7 @@ String& String::operator+ (char* other) { //Can be optimized return (ret += other); } -String& String::operator+ (wchar other) { +String& String::operator+ (WChar other) { String ret(*this); return (ret += other); } @@ -236,7 +236,7 @@ u32int String::toInt16() { return number; } -wchar& String::operator[] (int index) { +WChar& String::operator[] (int index) { return m_string[index]; } @@ -254,7 +254,7 @@ bool String::empty() { return (m_length == 0); } -Vector<String> String::split(wchar c) { +Vector<String> String::split(WChar c) { Vector<String> ret; ret.push(String("")); for (u32int i = 0; i < m_length; i++) { @@ -274,9 +274,9 @@ String String::substr(s32int start, s32int size) { size = 0 - size; } String ret; - ret.m_string = new wchar[size + 1]; + ret.m_string = new WChar[size + 1]; ret.m_length = size; - memcpy((u8int*)ret.m_string, (const u8int*)(m_string + start), size * sizeof(wchar)); + memcpy((u8int*)ret.m_string, (const u8int*)(m_string + start), size * sizeof(WChar)); ret.m_string[size] = 0; return ret; } diff --git a/Source/Kernel/Library/String.class.h b/Source/Kernel/Library/String.class.h index d086b31..ecbc2a0 100644 --- a/Source/Kernel/Library/String.class.h +++ b/Source/Kernel/Library/String.class.h @@ -2,13 +2,13 @@ #define DEF_STRING_CLASS #include <Core/common.wtf.h> -#include <Library/wchar.class.h> +#include <Library/WChar.class.h> template <typename T> class Vector; class String { private: - wchar *m_string; + WChar *m_string; u32int m_length; public: @@ -27,19 +27,19 @@ class String { bool operator== (char* string); String &operator+= (String &other); String &operator+= (char* other); - String &operator+= (wchar other); + String &operator+= (WChar other); String &operator+ (String &other); String &operator+ (char* other); - String &operator+ (wchar other); + String &operator+ (WChar other); s32int toInt(); u32int toInt16(); //From HEX - wchar& operator[] (int index); + WChar& operator[] (int index); u32int size(); void clear(); bool empty(); - Vector<String> split(wchar c); + Vector<String> split(WChar c); String substr(s32int start, s32int size); }; diff --git a/Source/Kernel/Library/wchar.class.cpp b/Source/Kernel/Library/WChar.class.cpp index 3a2ef92..c1a1977 100644 --- a/Source/Kernel/Library/wchar.class.cpp +++ b/Source/Kernel/Library/WChar.class.cpp @@ -1,6 +1,6 @@ -#include "wchar.class.h" +#include "WChar.class.h" -wchar wchar::CP437[] = { //These are the UTF8 equivalents for the 128 extra characters of code page 850 +WChar WChar::CP437[] = { //These are the UTF8 equivalents for the 128 extra characters of code page 850 "Ç", "ü", "é", "â", "ä", "à", "å", "ç", "ê", "ë", "è", "ï", "î", "ì", "Ä", "Å", "É", "æ", "Æ", "ô", "ö", "ò", "û", "ù", "ÿ", "Ö", "Ü", "¢", "£", "¥", "₧", "ƒ", "á", "í", "ó", "ú", "ñ", "Ñ", "ª", "º", "¿", "⌐", "¬", "½", "¼", "¡", "«", "»", @@ -11,19 +11,19 @@ wchar wchar::CP437[] = { //These are the UTF8 equivalents for the 128 extra char "≡", "±", "≥", "≤", "⌠", "⌡", "÷", "≈", "°", "∙", "·", "√", "ⁿ", "²", "■", "⍽" }; -wchar::wchar() { +WChar::WChar() { value = 0; } -wchar::wchar(char c) { +WChar::WChar(char c) { affectAscii(c); } -wchar::wchar(char* c) { +WChar::WChar(char* c) { affectUtf8(c); } -u32int wchar::utf8len(char* c) { +u32int WChar::utf8len(char* c) { int i = 0, l = CMem::strlen(c), co = 0; while (i < l) { if ((c[i] & 0x80) == 0) i += 1; @@ -36,12 +36,12 @@ u32int wchar::utf8len(char* c) { return co; } -void wchar::affectAscii(char c) { +void WChar::affectAscii(char c) { if (c >= 0) value = c; else value = CP437[c + 128]; } -u32int wchar::affectUtf8(char* c) { //Returns the number of bytes for the character +u32int WChar::affectUtf8(char* c) { //Returns the number of bytes for the character /*if ((c[0] & 0xB0) == 0x80) { //11000000b == 10000000b, means we are IN a sequence value = 0; return 1; @@ -71,7 +71,7 @@ u32int wchar::affectUtf8(char* c) { //Returns the number of bytes for the charac return 1; } -u8int wchar::toAscii() { +u8int WChar::toAscii() { if (value < 128) return (char)value; for (int i = 0; i < 128; i++) { if (CP437[i] == value) return (i + 128); diff --git a/Source/Kernel/Library/wchar.class.h b/Source/Kernel/Library/WChar.class.h index cadabd0..c582017 100644 --- a/Source/Kernel/Library/wchar.class.h +++ b/Source/Kernel/Library/WChar.class.h @@ -3,13 +3,13 @@ #include <Core/common.wtf.h> -struct wchar { +struct WChar { u32int value; - static wchar CP437[]; + static WChar CP437[]; - wchar(); //Creates a null character - wchar(char c); //From ascii character - wchar(char* c); //From utf8 string + WChar(); //Creates a null character + WChar(char c); //From ascii character + WChar(char* c); //From utf8 string static u32int utf8len(char* c); //Returns count of utf8 characters in string @@ -19,21 +19,21 @@ struct wchar { void affectUtf32(char* c); u8int toAscii(); - inline wchar operator+ (u32int other) { - wchar r; + inline WChar operator+ (u32int other) { + WChar r; r.value = value + other; return r; } - inline wchar operator- (u32int other) { - wchar r; + inline WChar operator- (u32int other) { + WChar r; r.value = value - other; return r; } - inline wchar& operator+= (u32int other) { + inline WChar& operator+= (u32int other) { value += other; return *this; } - inline wchar& operator-= (u32int other) { + inline WChar& operator-= (u32int other) { value -= other; return *this; } |