summaryrefslogtreecommitdiff
path: root/Source/Kernel/Library
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2009-09-13 15:36:39 +0200
committerAlexis211 <alexis211@gmail.com>2009-09-13 15:36:39 +0200
commitace1914398633e05970f634ddec297665dfda7c6 (patch)
treec244c222a7693b5257e1e955b5ed372530035b19 /Source/Kernel/Library
parent0b760a50b5aee05f1f34c1599b547c8b78d1d737 (diff)
downloadMelon-ace1914398633e05970f634ddec297665dfda7c6.tar.gz
Melon-ace1914398633e05970f634ddec297665dfda7c6.zip
RamFS creatable but not loadable yet
Diffstat (limited to 'Source/Kernel/Library')
-rw-r--r--Source/Kernel/Library/String.class.cpp10
-rw-r--r--Source/Kernel/Library/String.class.h10
-rw-r--r--Source/Kernel/Library/Vector.class.cpp10
-rw-r--r--Source/Kernel/Library/Vector.class.h1
4 files changed, 21 insertions, 10 deletions
diff --git a/Source/Kernel/Library/String.class.cpp b/Source/Kernel/Library/String.class.cpp
index 8df5cbf..b8e01d5 100644
--- a/Source/Kernel/Library/String.class.cpp
+++ b/Source/Kernel/Library/String.class.cpp
@@ -136,7 +136,7 @@ bool String::operator== (const char* string) {
return true;
}
-String& String::operator+= (String &other) {
+String& String::operator+= (const String &other) {
WChar* newdata = new WChar[m_length + other.m_length + 1];
for (u32int i = 0; i < m_length; i++) {
newdata[i] = m_string[i];
@@ -181,7 +181,7 @@ String& String::operator+= (WChar other) {
return *this;
}
-String& String::operator+ (String &other) { //Can be optimized
+String& String::operator+ (const String &other) { //Can be optimized
String ret(*this);
return (ret += other);
}
@@ -236,11 +236,11 @@ u32int String::toInt16() {
return number;
}
-WChar& String::operator[] (int index) {
+WChar& String::operator[] (int index) const {
return m_string[index];
}
-u32int String::size() {
+u32int String::size() const {
return m_length;
}
@@ -250,7 +250,7 @@ void String::clear() {
m_string = 0;
}
-bool String::empty() {
+bool String::empty() const {
return (m_length == 0);
}
diff --git a/Source/Kernel/Library/String.class.h b/Source/Kernel/Library/String.class.h
index 85ec268..6b48a30 100644
--- a/Source/Kernel/Library/String.class.h
+++ b/Source/Kernel/Library/String.class.h
@@ -25,19 +25,19 @@ class String {
bool operator== (const String &other);
bool operator== (const char* string);
- String &operator+= (String &other);
+ String &operator+= (const String &other);
String &operator+= (const char* other);
String &operator+= (WChar other);
- String &operator+ (String &other);
+ String &operator+ (const String &other);
String &operator+ (const char* other);
String &operator+ (WChar other);
s32int toInt();
u32int toInt16(); //From HEX
- WChar& operator[] (int index);
+ WChar& operator[] (int index) const;
- u32int size();
+ u32int size() const;
void clear();
- bool empty();
+ bool empty() const;
Vector<String> split(WChar c);
diff --git a/Source/Kernel/Library/Vector.class.cpp b/Source/Kernel/Library/Vector.class.cpp
index aaa777f..d0c71a4 100644
--- a/Source/Kernel/Library/Vector.class.cpp
+++ b/Source/Kernel/Library/Vector.class.cpp
@@ -32,6 +32,16 @@ Vector<T>::Vector(const Vector<T> &other) {
}
template <typename T>
+Vector<T>& Vector<T>::operator= (const Vector<T> &other) {
+ if (m_data != 0) delete[] m_data;
+ m_size = other.m_size;
+ m_data = (T*)Mem::kalloc(m_size * sizeof(T));
+ for (u32int i = 0; i < m_size; i++) {
+ new(&m_data[i]) T(other.m_data[i]);
+ }
+}
+
+template <typename T>
Vector<T>::~Vector() {
if (m_data != 0) delete[] m_data;
}
diff --git a/Source/Kernel/Library/Vector.class.h b/Source/Kernel/Library/Vector.class.h
index 9763d2c..f16303b 100644
--- a/Source/Kernel/Library/Vector.class.h
+++ b/Source/Kernel/Library/Vector.class.h
@@ -14,6 +14,7 @@ class Vector {
Vector(u32int size);
Vector(u32int size, T value);
Vector(const Vector<T> &other);
+ Vector<T>& operator= (const Vector<T> &other);
~Vector();
T& operator[] (u32int index);