Browse Source

Added overloads to Variant & XMLElement that take char pointers.

Lasse Öörni 14 years ago
parent
commit
95a8c8bfa7

+ 50 - 36
Engine/Container/String.cpp

@@ -456,42 +456,7 @@ String String::ToUpper() const
 
 
 Vector<String> String::Split(char separator) const
 Vector<String> String::Split(char separator) const
 {
 {
-    Vector<String> ret;
-    unsigned pos = 0;
-    
-    while (pos < length_)
-    {
-        unsigned start = pos;
-        
-        while (start < length_)
-        {
-            if (buffer_[start] == separator)
-                break;
-            
-            ++start;
-        }
-        
-        if (start == length_)
-        {
-            ret.Push(Substring(pos));
-            break;
-        }
-        
-        unsigned end = start;
-        
-        while (end < length_)
-        {
-            if (buffer_[end] != separator)
-                break;
-            
-            ++end;
-        }
-        
-        ret.Push(Substring(pos, start - pos));
-        pos = end;
-    }
-    
-    return ret;
+    return Split(CString(), separator);
 }
 }
 
 
 unsigned String::Find(char c, unsigned startPos) const
 unsigned String::Find(char c, unsigned startPos) const
@@ -628,6 +593,55 @@ int String::Compare(const char* str, bool caseSensitive) const
     }
     }
 }
 }
 
 
+
+Vector<String> String::Split(const char* str, char separator)
+{
+    Vector<String> ret;
+    unsigned pos = 0;
+    unsigned length = CStringLength(str);
+    
+    while (pos < length)
+    {
+        if (str[pos] != separator)
+            break;
+        ++pos;
+    }
+    
+    while (pos < length)
+    {
+        unsigned start = pos;
+        
+        while (start < length)
+        {
+            if (str[start] == separator)
+                break;
+            
+            ++start;
+        }
+        
+        if (start == length)
+        {
+            ret.Push(String(&str[pos]));
+            break;
+        }
+        
+        unsigned end = start;
+        
+        while (end < length)
+        {
+            if (str[end] != separator)
+                break;
+            
+            ++end;
+        }
+        
+        ret.Push(String(&str[pos], start - pos));
+        pos = end;
+    }
+    
+    return ret;
+}
+
 void String::Replace(unsigned pos, unsigned length, const char* srcStart, unsigned srcLength)
 void String::Replace(unsigned pos, unsigned length, const char* srcStart, unsigned srcLength)
 {
 {
     int delta = (int)srcLength - (int)length;
     int delta = (int)srcLength - (int)length;

+ 22 - 18
Engine/Container/StringBase.h

@@ -131,7 +131,7 @@ public:
     /// Assign a C string.
     /// Assign a C string.
     String& operator = (const char* rhs)
     String& operator = (const char* rhs)
     {
     {
-        unsigned rhsLength = GetCStringLength(rhs);
+        unsigned rhsLength = CStringLength(rhs);
         Resize(rhsLength);
         Resize(rhsLength);
         CopyChars(buffer_, rhs, rhsLength);
         CopyChars(buffer_, rhs, rhsLength);
         
         
@@ -151,7 +151,7 @@ public:
     /// Add-assign a C string.
     /// Add-assign a C string.
     String& operator += (const char* rhs)
     String& operator += (const char* rhs)
     {
     {
-        unsigned rhsLength = GetCStringLength(rhs);
+        unsigned rhsLength = CStringLength(rhs);
         unsigned oldLength = length_;
         unsigned oldLength = length_;
         Resize(length_ + rhsLength);
         Resize(length_ + rhsLength);
         CopyChars(buffer_ + oldLength, rhs, rhsLength);
         CopyChars(buffer_ + oldLength, rhs, rhsLength);
@@ -198,7 +198,7 @@ public:
     /// Add a C string.
     /// Add a C string.
     String operator + (const char* rhs) const
     String operator + (const char* rhs) const
     {
     {
-        unsigned rhsLength = GetCStringLength(rhs);
+        unsigned rhsLength = CStringLength(rhs);
         String ret;
         String ret;
         ret.Resize(length_ + rhsLength);
         ret.Resize(length_ + rhsLength);
         CopyChars(ret.buffer_, buffer_, length_);
         CopyChars(ret.buffer_, buffer_, length_);
@@ -336,6 +336,7 @@ public:
     int Compare(const String& str, bool caseSensitive = true) const;
     int Compare(const String& str, bool caseSensitive = true) const;
     /// Return comparision result with a C string.
     /// Return comparision result with a C string.
     int Compare(const char* str, bool caseSensitive = true) const;
     int Compare(const char* str, bool caseSensitive = true) const;
+    
     /// Return hash value for HashSet & HashMap.
     /// Return hash value for HashSet & HashMap.
     unsigned ToHash() const
     unsigned ToHash() const
     {
     {
@@ -350,6 +351,24 @@ public:
         return hash;
         return hash;
     }
     }
     
     
+    /// Return substrings split by a separator char.
+    static Vector<String> Split(const char* str, char separator);
+    
+    /// Return length of a C string.
+    static unsigned CStringLength(const char* str)
+    {
+        if (!str)
+            return 0;
+        #ifdef _MSC_VER
+        return strlen(str);
+        #else
+        const char* ptr = str;
+        while (*ptr)
+            ++ptr;
+        return ptr - str;
+        #endif
+    }
+    
     /// Position for "not found."
     /// Position for "not found."
     static const unsigned NPOS = 0xffffffff;
     static const unsigned NPOS = 0xffffffff;
     /// Initial dynamic allocation size.
     /// Initial dynamic allocation size.
@@ -380,21 +399,6 @@ private:
         #endif
         #endif
     }
     }
     
     
-    /// Return length of a C string.
-    static unsigned GetCStringLength(const char* str)
-    {
-        if (!str)
-            return 0;
-        #ifdef _MSC_VER
-        return strlen(str);
-        #else
-        const char* ptr = str;
-        while (*ptr)
-            ++ptr;
-        return ptr - str;
-        #endif
-    }
-    
     /// Replace a substring with another substring.
     /// Replace a substring with another substring.
     void Replace(unsigned pos, unsigned length, const char* srcStart, unsigned srcLength);
     void Replace(unsigned pos, unsigned length, const char* srcStart, unsigned srcLength);
     
     

+ 117 - 29
Engine/Core/StringUtils.cpp

@@ -29,36 +29,45 @@
 
 
 #include "DebugNew.h"
 #include "DebugNew.h"
 
 
-unsigned CountElements(const String& str, char separator)
+unsigned CountElements(const char* buffer, char separator)
 {
 {
-    const char* buffer = str.CString();
-    unsigned length = str.Length();
-    unsigned pos = 0;
+    if (!buffer)
+        return 0;
+    
+    const char* endPos = buffer + String::CStringLength(buffer);
+    const char* pos = buffer;
     unsigned ret = 0;
     unsigned ret = 0;
     
     
-    while (pos < length)
+    while (pos < endPos)
+    {
+        if (*pos != separator)
+            break;
+        ++pos;
+    }
+    
+    while (pos < endPos)
     {
     {
-        unsigned start = pos;
+        const char* start = pos;
         
         
-        while (start < length)
+        while (start < endPos)
         {
         {
-            if (buffer[start] == separator)
+            if (*start == separator)
                 break;
                 break;
             
             
             ++start;
             ++start;
         }
         }
         
         
-        if (start == length)
+        if (start == endPos)
         {
         {
             ++ret;
             ++ret;
             break;
             break;
         }
         }
         
         
-        unsigned end = start;
+        const char* end = start;
         
         
-        while (end < length)
+        while (end < endPos)
         {
         {
-            if (buffer[end] != separator)
+            if (*end != separator)
                 break;
                 break;
             
             
             ++end;
             ++end;
@@ -73,9 +82,16 @@ unsigned CountElements(const String& str, char separator)
 
 
 bool ToBool(const String& source)
 bool ToBool(const String& source)
 {
 {
-    for (unsigned i = 0; i < source.Length(); ++i)
+    return ToBool(source.CString());
+}
+
+bool ToBool(const char* source)
+{
+    unsigned length = String::CStringLength(source);
+    
+    for (unsigned i = 0; i < length; ++i)
     {
     {
-        char c = tolower(source[0]);
+        char c = tolower(source[i]);
         if (c == 't' || c == 'y' || c == '1')
         if (c == 't' || c == 'y' || c == '1')
             return true;
             return true;
         else if (c != ' ' && c != '\t')
         else if (c != ' ' && c != '\t')
@@ -87,26 +103,49 @@ bool ToBool(const String& source)
 
 
 int ToInt(const String& source)
 int ToInt(const String& source)
 {
 {
-    if (!source.Length())
+    return ToInt(source.CString());
+}
+
+int ToInt(const char* source)
+{
+    if (!source)
         return 0;
         return 0;
-    return strtol(source.CString(), 0, 0);
+    
+    return strtol(source, 0, 0);
 }
 }
 
 
 unsigned ToUInt(const String& source)
 unsigned ToUInt(const String& source)
 {
 {
-    if (!source.Length())
+    return ToUInt(source.CString());
+}
+
+unsigned ToUInt(const char* source)
+{
+    if (!source)
         return 0;
         return 0;
-    return strtoul(source.CString(), 0, 0);
+    
+    return strtoul(source, 0, 0);
 }
 }
 
 
 float ToFloat(const String& source)
 float ToFloat(const String& source)
 {
 {
-    if (!source.Length())
-        return 0.0f;
-    return (float)strtod(source.CString(), 0);
+    return ToFloat(source.CString());
+}
+
+float ToFloat(const char* source)
+{
+    if (!source)
+        return 0;
+    
+    return (float)strtod(source, 0);
 }
 }
 
 
 Color ToColor(const String& source)
 Color ToColor(const String& source)
+{
+    return ToColor(source.CString());
+}
+
+Color ToColor(const char* source)
 {
 {
     Color ret;
     Color ret;
     
     
@@ -114,7 +153,7 @@ Color ToColor(const String& source)
     if (elements < 3)
     if (elements < 3)
         return ret;
         return ret;
     
     
-    char* ptr = (char*)source.CString();
+    char* ptr = (char*)source;
     ret.r_ = (float)strtod(ptr, &ptr);
     ret.r_ = (float)strtod(ptr, &ptr);
     ret.g_ = (float)strtod(ptr, &ptr);
     ret.g_ = (float)strtod(ptr, &ptr);
     ret.b_ = (float)strtod(ptr, &ptr);
     ret.b_ = (float)strtod(ptr, &ptr);
@@ -125,6 +164,11 @@ Color ToColor(const String& source)
 }
 }
 
 
 IntRect ToIntRect(const String& source)
 IntRect ToIntRect(const String& source)
+{
+    return ToIntRect(source.CString());
+}
+
+IntRect ToIntRect(const char* source)
 {
 {
     IntRect ret(IntRect::ZERO);
     IntRect ret(IntRect::ZERO);
     
     
@@ -132,7 +176,7 @@ IntRect ToIntRect(const String& source)
     if (elements < 4)
     if (elements < 4)
         return ret;
         return ret;
     
     
-    char* ptr = (char*)source.CString();
+    char* ptr = (char*)source;
     ret.left_ = strtol(ptr, &ptr, 0);
     ret.left_ = strtol(ptr, &ptr, 0);
     ret.top_ = strtol(ptr, &ptr, 0);
     ret.top_ = strtol(ptr, &ptr, 0);
     ret.right_ = strtol(ptr, &ptr, 0);
     ret.right_ = strtol(ptr, &ptr, 0);
@@ -142,6 +186,11 @@ IntRect ToIntRect(const String& source)
 }
 }
 
 
 IntVector2 ToIntVector2(const String& source)
 IntVector2 ToIntVector2(const String& source)
+{
+    return ToIntVector2(source.CString());
+}
+
+IntVector2 ToIntVector2(const char* source)
 {
 {
     IntVector2 ret(IntVector2::ZERO);
     IntVector2 ret(IntVector2::ZERO);
     
     
@@ -149,7 +198,7 @@ IntVector2 ToIntVector2(const String& source)
     if (elements < 2)
     if (elements < 2)
         return ret;
         return ret;
     
     
-    char* ptr = (char*)source.CString();
+    char* ptr = (char*)source;
     ret.x_ = strtol(ptr, &ptr, 0);
     ret.x_ = strtol(ptr, &ptr, 0);
     ret.y_ = strtol(ptr, &ptr, 0);
     ret.y_ = strtol(ptr, &ptr, 0);
     
     
@@ -157,6 +206,11 @@ IntVector2 ToIntVector2(const String& source)
 }
 }
 
 
 Rect ToRect(const String& source)
 Rect ToRect(const String& source)
+{
+    return ToRect(source.CString());
+}
+
+Rect ToRect(const char* source)
 {
 {
     Rect ret(Rect::ZERO);
     Rect ret(Rect::ZERO);
     
     
@@ -164,7 +218,7 @@ Rect ToRect(const String& source)
     if (elements < 4)
     if (elements < 4)
         return ret;
         return ret;
     
     
-    char* ptr = (char*)source.CString();
+    char* ptr = (char*)source;
     ret.min_.x_ = (float)strtod(ptr, &ptr);
     ret.min_.x_ = (float)strtod(ptr, &ptr);
     ret.min_.y_ = (float)strtod(ptr, &ptr);
     ret.min_.y_ = (float)strtod(ptr, &ptr);
     ret.max_.x_ = (float)strtod(ptr, &ptr);
     ret.max_.x_ = (float)strtod(ptr, &ptr);
@@ -174,9 +228,14 @@ Rect ToRect(const String& source)
 }
 }
 
 
 Quaternion ToQuaternion(const String& source)
 Quaternion ToQuaternion(const String& source)
+{
+    return ToQuaternion(source.CString());
+}
+
+Quaternion ToQuaternion(const char* source)
 {
 {
     unsigned elements = CountElements(source, ' ');
     unsigned elements = CountElements(source, ' ');
-    char* ptr = (char*)source.CString();
+    char* ptr = (char*)source;
     
     
     if (elements < 3)
     if (elements < 3)
         return Quaternion::IDENTITY;
         return Quaternion::IDENTITY;
@@ -204,6 +263,11 @@ Quaternion ToQuaternion(const String& source)
 }
 }
 
 
 Vector2 ToVector2(const String& source)
 Vector2 ToVector2(const String& source)
+{
+    return ToVector2(source.CString());
+}
+
+Vector2 ToVector2(const char* source)
 {
 {
     Vector2 ret(Vector2::ZERO);
     Vector2 ret(Vector2::ZERO);
     
     
@@ -211,7 +275,7 @@ Vector2 ToVector2(const String& source)
     if (elements < 2)
     if (elements < 2)
         return ret;
         return ret;
     
     
-    char* ptr = (char*)source.CString();
+    char* ptr = (char*)source;
     ret.x_ = (float)strtod(ptr, &ptr);
     ret.x_ = (float)strtod(ptr, &ptr);
     ret.y_ = (float)strtod(ptr, &ptr);
     ret.y_ = (float)strtod(ptr, &ptr);
     
     
@@ -219,6 +283,11 @@ Vector2 ToVector2(const String& source)
 }
 }
 
 
 Vector3 ToVector3(const String& source)
 Vector3 ToVector3(const String& source)
+{
+    return ToVector3(source.CString());
+}
+
+Vector3 ToVector3(const char* source)
 {
 {
     Vector3 ret(Vector3::ZERO);
     Vector3 ret(Vector3::ZERO);
     
     
@@ -226,7 +295,7 @@ Vector3 ToVector3(const String& source)
     if (elements < 3)
     if (elements < 3)
         return ret;
         return ret;
     
     
-    char* ptr = (char*)source.CString();
+    char* ptr = (char*)source;
     ret.x_ = (float)strtod(ptr, &ptr);
     ret.x_ = (float)strtod(ptr, &ptr);
     ret.y_ = (float)strtod(ptr, &ptr);
     ret.y_ = (float)strtod(ptr, &ptr);
     ret.z_ = (float)strtod(ptr, &ptr);
     ret.z_ = (float)strtod(ptr, &ptr);
@@ -235,11 +304,16 @@ Vector3 ToVector3(const String& source)
 }
 }
 
 
 Vector4 ToVector4(const String& source, bool allowMissingCoords)
 Vector4 ToVector4(const String& source, bool allowMissingCoords)
+{
+    return ToVector4(source.CString(), allowMissingCoords);
+}
+
+Vector4 ToVector4(const char* source, bool allowMissingCoords)
 {
 {
     Vector4 ret(Vector4::ZERO);
     Vector4 ret(Vector4::ZERO);
     
     
     unsigned elements = CountElements(source, ' ');
     unsigned elements = CountElements(source, ' ');
-    char* ptr = (char*)source.CString();
+    char* ptr = (char*)source;
     
     
     if (!allowMissingCoords)
     if (!allowMissingCoords)
     {
     {
@@ -293,3 +367,17 @@ unsigned GetStringListIndex(const String& value, const String* strings, unsigned
     
     
     return defaultIndex;
     return defaultIndex;
 }
 }
+
+unsigned GetStringListIndex(const char* value, const String* strings, unsigned defaultIndex, bool caseSensitive)
+{
+    unsigned i = 0;
+    
+    while (!strings[i].Empty())
+    {
+        if (!strings[i].Compare(value, caseSensitive))
+            return i;
+        ++i;
+    }
+    
+    return defaultIndex;
+}

+ 26 - 0
Engine/Core/StringUtils.h

@@ -31,31 +31,57 @@
 
 
 /// Parse a bool from a string. Check for the first non-empty character (converted to lowercase) being either 't', 'y' or '1'.
 /// Parse a bool from a string. Check for the first non-empty character (converted to lowercase) being either 't', 'y' or '1'.
 bool ToBool(const String& source);
 bool ToBool(const String& source);
+/// Parse a bool from a C string. Check for the first non-empty character (converted to lowercase) being either 't', 'y' or '1'.
+bool ToBool(const char* source);
 /// Parse a float from a string.
 /// Parse a float from a string.
 float ToFloat(const String& source);
 float ToFloat(const String& source);
+/// Parse a float from a C string.
+float ToFloat(const char* source);
 /// Parse an integer from a string.
 /// Parse an integer from a string.
 int ToInt(const String& source);
 int ToInt(const String& source);
+/// Parse an integer from a C string.
+int ToInt(const char* source);
 /// Parse an unsigned integer from a string.
 /// Parse an unsigned integer from a string.
 unsigned ToUInt(const String& source);
 unsigned ToUInt(const String& source);
+/// Parse an unsigned integer from a C string.
+unsigned ToUInt(const char* source);
 /// Parse a Color from a string.
 /// Parse a Color from a string.
 Color ToColor(const String& source);
 Color ToColor(const String& source);
+/// Parse a Color from a C string.
+Color ToColor(const char* source);
 /// Parse an IntRect from a string.
 /// Parse an IntRect from a string.
 IntRect ToIntRect(const String& source);
 IntRect ToIntRect(const String& source);
+/// Parse an IntRect from a C string.
+IntRect ToIntRect(const char* source);
 /// Parse an IntVector2 from a string.
 /// Parse an IntVector2 from a string.
 IntVector2 ToIntVector2(const String& source);
 IntVector2 ToIntVector2(const String& source);
+/// Parse an IntVector2 from a C string.
+IntVector2 ToIntVector2(const char* source);
 /// Parse a Quaternion from a string. If only 3 components specified, convert Euler angles (degrees) to quaternion.
 /// Parse a Quaternion from a string. If only 3 components specified, convert Euler angles (degrees) to quaternion.
 Quaternion ToQuaternion(const String& source);
 Quaternion ToQuaternion(const String& source);
+/// Parse a Quaternion from a C string. If only 3 components specified, convert Euler angles (degrees) to quaternion.
+Quaternion ToQuaternion(const char* source);
 /// Parse a Rect from a string.
 /// Parse a Rect from a string.
 Rect ToRect(const String& source);
 Rect ToRect(const String& source);
+/// Parse a Rect from a C string.
+Rect ToRect(const char* source);
 /// Parse a Vector2 from a string.
 /// Parse a Vector2 from a string.
 Vector2 ToVector2(const String& source);
 Vector2 ToVector2(const String& source);
+/// Parse a Vector2 from a C string.
+Vector2 ToVector2(const char* source);
 /// Parse a Vector3 from a string.
 /// Parse a Vector3 from a string.
 Vector3 ToVector3(const String& source);
 Vector3 ToVector3(const String& source);
+/// Parse a Vector3 from a C string.
+Vector3 ToVector3(const char* source);
 /// Parse a Vector4 from a string.
 /// Parse a Vector4 from a string.
 Vector4 ToVector4(const String& source, bool allowMissingCoords = false);
 Vector4 ToVector4(const String& source, bool allowMissingCoords = false);
+/// Parse a Vector4 from a C string.
+Vector4 ToVector4(const char* source, bool allowMissingCoords = false);
 /// Convert a pointer to string (returns hexadecimal.)
 /// Convert a pointer to string (returns hexadecimal.)
 String ToString(void* value);
 String ToString(void* value);
 /// Convert an unsigned integer to string as hexadecimal.
 /// Convert an unsigned integer to string as hexadecimal.
 String ToStringHex(unsigned value);
 String ToStringHex(unsigned value);
 /// Return an index to a string list corresponding to the given string, or a default value if not found. The string list must be empty-terminated.
 /// Return an index to a string list corresponding to the given string, or a default value if not found. The string list must be empty-terminated.
 unsigned GetStringListIndex(const String& value, const String* strings, unsigned defaultIndex, bool caseSensitive = false);
 unsigned GetStringListIndex(const String& value, const String* strings, unsigned defaultIndex, bool caseSensitive = false);
+/// Return an index to a string list corresponding to the given C string, or a default value if not found. The string list must be empty-terminated.
+unsigned GetStringListIndex(const char* value, const String* strings, unsigned defaultIndex, bool caseSensitive = false);

+ 18 - 3
Engine/Core/Variant.cpp

@@ -155,11 +155,21 @@ bool Variant::operator == (const Variant& rhs) const
 }
 }
 
 
 void Variant::FromString(const String& type, const String& value)
 void Variant::FromString(const String& type, const String& value)
+{
+    return FromString(GetTypeFromName(type), value.CString());
+}
+
+void Variant::FromString(const char* type, const char* value)
 {
 {
     return FromString(GetTypeFromName(type), value);
     return FromString(GetTypeFromName(type), value);
 }
 }
 
 
 void Variant::FromString(VariantType type, const String& value)
 void Variant::FromString(VariantType type, const String& value)
+{
+    return FromString(type, value.CString());
+}
+
+void Variant::FromString(VariantType type, const char* value)
 {
 {
     switch (type)
     switch (type)
     {
     {
@@ -203,7 +213,7 @@ void Variant::FromString(VariantType type, const String& value)
         {
         {
             SetType(VAR_BUFFER);
             SetType(VAR_BUFFER);
             PODVector<unsigned char>& buffer = *(reinterpret_cast<PODVector<unsigned char>*>(&value_));
             PODVector<unsigned char>& buffer = *(reinterpret_cast<PODVector<unsigned char>*>(&value_));
-            Vector<String> values = value.Split(' ');
+            Vector<String> values = String::Split(value, ' ');
             buffer.Resize(values.Size());
             buffer.Resize(values.Size());
             for (unsigned i = 0; i < values.Size(); ++i)
             for (unsigned i = 0; i < values.Size(); ++i)
                 buffer[i] = ToInt(values[i]);
                 buffer[i] = ToInt(values[i]);
@@ -216,7 +226,7 @@ void Variant::FromString(VariantType type, const String& value)
         
         
     case VAR_RESOURCEREF:
     case VAR_RESOURCEREF:
         {
         {
-            Vector<String> values = value.Split(';');
+            Vector<String> values = String::Split(value, ';');
             if (values.Size() == 2)
             if (values.Size() == 2)
             {
             {
                 SetType(VAR_RESOURCEREF);
                 SetType(VAR_RESOURCEREF);
@@ -229,7 +239,7 @@ void Variant::FromString(VariantType type, const String& value)
         
         
     case VAR_RESOURCEREFLIST:
     case VAR_RESOURCEREFLIST:
         {
         {
-            Vector<String> values = value.Split(';');
+            Vector<String> values = String::Split(value, ';');
             if (values.Size() >= 1)
             if (values.Size() >= 1)
             {
             {
                 SetType(VAR_RESOURCEREFLIST);
                 SetType(VAR_RESOURCEREFLIST);
@@ -524,6 +534,11 @@ const String& Variant::GetTypeName(VariantType type)
 }
 }
 
 
 VariantType Variant::GetTypeFromName(const String& typeName)
 VariantType Variant::GetTypeFromName(const String& typeName)
+{
+    return GetTypeFromName(typeName.CString());
+}
+
+VariantType Variant::GetTypeFromName(const char* typeName)
 {
 {
     unsigned index = 0;
     unsigned index = 0;
     while (!typeNames[index].Empty())
     while (!typeNames[index].Empty())

+ 20 - 0
Engine/Core/Variant.h

@@ -300,6 +300,20 @@ public:
         FromString(type, value);
         FromString(type, value);
     }
     }
     
     
+    /// Construct from type and value.
+    Variant(const char* type, const char* value) :
+        type_(VAR_NONE)
+    {
+        FromString(type, value);
+    }
+    
+    /// Construct from type and value.
+    Variant(VariantType type, const char* value) :
+        type_(VAR_NONE)
+    {
+        FromString(type, value);
+    }
+    
     /// Copy-construct from another variant.
     /// Copy-construct from another variant.
     Variant(const Variant& value) :
     Variant(const Variant& value) :
         type_(VAR_NONE)
         type_(VAR_NONE)
@@ -678,8 +692,12 @@ public:
     
     
     /// %Set from typename and value strings. Pointers will be set to null, and VariantBuffer or VariantMap types are not supported.
     /// %Set from typename and value strings. Pointers will be set to null, and VariantBuffer or VariantMap types are not supported.
     void FromString(const String& type, const String& value);
     void FromString(const String& type, const String& value);
+    /// %Set from typename and value strings. Pointers will be set to null, and VariantBuffer or VariantMap types are not supported.
+    void FromString(const char* type, const char* value);
     /// %Set from type and value string. Pointers will be set to null, and VariantBuffer or VariantMap types are not supported.
     /// %Set from type and value string. Pointers will be set to null, and VariantBuffer or VariantMap types are not supported.
     void FromString(VariantType type, const String& value);
     void FromString(VariantType type, const String& value);
+    /// %Set from type and value string. Pointers will be set to null, and VariantBuffer or VariantMap types are not supported.
+    void FromString(VariantType type, const char* value);
     /// %Set buffer type from a memory area.
     /// %Set buffer type from a memory area.
     void SetBuffer(const void* data, unsigned size);
     void SetBuffer(const void* data, unsigned size);
     
     
@@ -840,6 +858,8 @@ public:
     static const String& GetTypeName(VariantType type);
     static const String& GetTypeName(VariantType type);
     /// Return variant type from type name.
     /// Return variant type from type name.
     static VariantType GetTypeFromName(const String& typeName);
     static VariantType GetTypeFromName(const String& typeName);
+    /// Return variant type from type name.
+    static VariantType GetTypeFromName(const char* typeName);
     
     
     /// Empty variant.
     /// Empty variant.
     static const Variant EMPTY;
     static const Variant EMPTY;

+ 11 - 11
Engine/Engine/CoreAPI.cpp

@@ -523,17 +523,17 @@ static CScriptArray* StringSplit(char separator, const String* str)
 static void RegisterStringUtils(asIScriptEngine* engine)
 static void RegisterStringUtils(asIScriptEngine* engine)
 {
 {
     engine->RegisterObjectMethod("String", "Array<String>@ Split(uint8) const", asFUNCTION(StringSplit), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("String", "Array<String>@ Split(uint8) const", asFUNCTION(StringSplit), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("String", "bool ToBool() const", asFUNCTION(ToBool), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("String", "float ToFloat() const", asFUNCTION(ToFloat), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("String", "int ToInt() const", asFUNCTION(ToInt), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("String", "uint ToUInt() const", asFUNCTION(ToUInt), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("String", "Color ToColor() const", asFUNCTION(ToColor), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("String", "IntRect ToIntRect() const", asFUNCTION(ToIntRect), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("String", "IntVector2 ToIntVector2() const", asFUNCTION(ToIntVector2), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("String", "Quaternion ToQuaternion() const", asFUNCTION(ToQuaternion), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("String", "Vector2 ToVector2() const", asFUNCTION(ToVector2), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("String", "Vector3 ToVector3() const", asFUNCTION(ToVector3), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("String", "Vector4 ToVector4(bool allowMissingCoords = false) const", asFUNCTION(ToVector4), asCALL_CDECL_OBJFIRST);
+    engine->RegisterObjectMethod("String", "bool ToBool() const", asFUNCTIONPR(ToBool, (const String&), bool), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("String", "float ToFloat() const", asFUNCTIONPR(ToFloat, (const String&), float), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("String", "int ToInt() const", asFUNCTIONPR(ToInt, (const String&), int), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("String", "uint ToUInt() const", asFUNCTIONPR(ToUInt, (const String&), unsigned), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("String", "Color ToColor() const", asFUNCTIONPR(ToColor, (const String&), Color), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("String", "IntRect ToIntRect() const", asFUNCTIONPR(ToIntRect, (const String&), IntRect), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("String", "IntVector2 ToIntVector2() const", asFUNCTIONPR(ToIntVector2, (const String&), IntVector2), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("String", "Quaternion ToQuaternion() const", asFUNCTIONPR(ToQuaternion, (const String&), Quaternion), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("String", "Vector2 ToVector2() const", asFUNCTIONPR(ToVector2, (const String&), Vector2), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("String", "Vector3 ToVector3() const", asFUNCTIONPR(ToVector3, (const String&), Vector3), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("String", "Vector4 ToVector4(bool allowMissingCoords = false) const", asFUNCTIONPR(ToVector4, (const String&, bool), Vector4), asCALL_CDECL_OBJFIRST);
     engine->RegisterGlobalFunction("String ToStringHex(int)", asFUNCTION(ToStringHex), asCALL_CDECL);
     engine->RegisterGlobalFunction("String ToStringHex(int)", asFUNCTION(ToStringHex), asCALL_CDECL);
 }
 }
 
 

+ 8 - 8
Engine/Engine/ResourceAPI.cpp

@@ -174,11 +174,11 @@ static void RegisterXMLElement(asIScriptEngine* engine)
     engine->RegisterObjectBehaviour("XMLElement", asBEHAVE_CONSTRUCT, "void f(const XMLElement&in)", asFUNCTION(ConstructXMLElementCopy), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectBehaviour("XMLElement", asBEHAVE_CONSTRUCT, "void f(const XMLElement&in)", asFUNCTION(ConstructXMLElementCopy), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectBehaviour("XMLElement", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(DestructXMLElement), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectBehaviour("XMLElement", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(DestructXMLElement), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("XMLElement", "XMLElement& opAssign(const XMLElement&in)", asMETHOD(XMLElement, operator =), asCALL_THISCALL);
     engine->RegisterObjectMethod("XMLElement", "XMLElement& opAssign(const XMLElement&in)", asMETHOD(XMLElement, operator =), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "XMLElement CreateChild(const String&in)", asMETHOD(XMLElement, CreateChild), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "XMLElement CreateChild(const String&in)", asMETHODPR(XMLElement, CreateChild, (const String&), XMLElement), asCALL_THISCALL);
     engine->RegisterObjectMethod("XMLElement", "bool RemoveChild(const XMLElement&in)", asMETHODPR(XMLElement, RemoveChild, (const XMLElement&), bool), asCALL_THISCALL);
     engine->RegisterObjectMethod("XMLElement", "bool RemoveChild(const XMLElement&in)", asMETHODPR(XMLElement, RemoveChild, (const XMLElement&), bool), asCALL_THISCALL);
     engine->RegisterObjectMethod("XMLElement", "bool RemoveChild(const String&in)", asMETHODPR(XMLElement, RemoveChild, (const String&), bool), asCALL_THISCALL);
     engine->RegisterObjectMethod("XMLElement", "bool RemoveChild(const String&in)", asMETHODPR(XMLElement, RemoveChild, (const String&), bool), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "bool RemoveChildren(const String&in name = String())", asMETHOD(XMLElement,RemoveChildren), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "bool SetAttribute(const String&in, const String&in)", asMETHOD(XMLElement, SetAttribute), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "bool RemoveChildren(const String&in name = String())", asMETHODPR(XMLElement, RemoveChildren, (const String&), bool), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "bool SetAttribute(const String&in, const String&in)", asMETHODPR(XMLElement, SetAttribute, (const String&, const String&), bool), asCALL_THISCALL);
     engine->RegisterObjectMethod("XMLElement", "bool SetBool(const String&in, bool)", asMETHOD(XMLElement, SetBool), asCALL_THISCALL);
     engine->RegisterObjectMethod("XMLElement", "bool SetBool(const String&in, bool)", asMETHOD(XMLElement, SetBool), asCALL_THISCALL);
     engine->RegisterObjectMethod("XMLElement", "bool SetBoundingBox(const BoundingBox&in)", asMETHOD(XMLElement, SetBoundingBox), asCALL_THISCALL);
     engine->RegisterObjectMethod("XMLElement", "bool SetBoundingBox(const BoundingBox&in)", asMETHOD(XMLElement, SetBoundingBox), asCALL_THISCALL);
     engine->RegisterObjectMethod("XMLElement", "bool SetColor(const String&in, const Color&in)", asMETHOD(XMLElement, SetColor), asCALL_THISCALL);
     engine->RegisterObjectMethod("XMLElement", "bool SetColor(const String&in, const Color&in)", asMETHOD(XMLElement, SetColor), asCALL_THISCALL);
@@ -195,12 +195,12 @@ static void RegisterXMLElement(asIScriptEngine* engine)
     engine->RegisterObjectMethod("XMLElement", "bool SetVector3(const String&in, const Vector3&in)", asMETHOD(XMLElement, SetVector3), asCALL_THISCALL);
     engine->RegisterObjectMethod("XMLElement", "bool SetVector3(const String&in, const Vector3&in)", asMETHOD(XMLElement, SetVector3), asCALL_THISCALL);
     engine->RegisterObjectMethod("XMLElement", "bool SetVector4(const String&in, const Vector3&in)", asMETHOD(XMLElement, SetVector4), asCALL_THISCALL);
     engine->RegisterObjectMethod("XMLElement", "bool SetVector4(const String&in, const Vector3&in)", asMETHOD(XMLElement, SetVector4), asCALL_THISCALL);
     engine->RegisterObjectMethod("XMLElement", "uint GetNumAttributes() const", asMETHOD(XMLElement, GetNumAttributes), asCALL_THISCALL);
     engine->RegisterObjectMethod("XMLElement", "uint GetNumAttributes() const", asMETHOD(XMLElement, GetNumAttributes), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "bool HasAttribute(const String&in) const", asMETHOD(XMLElement, HasAttribute), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "String GetAttribute(const String&in) const", asMETHOD(XMLElement, GetAttribute), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "bool HasAttribute(const String&in) const", asMETHODPR(XMLElement, HasAttribute, (const String&) const, bool), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "String GetAttribute(const String&in) const", asMETHODPR(XMLElement, GetAttribute, (const String&) const, String), asCALL_THISCALL);
     engine->RegisterObjectMethod("XMLElement", "Array<String>@ GetAttributeNames() const", asFUNCTION(XMLElementGetAttributeNames), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("XMLElement", "Array<String>@ GetAttributeNames() const", asFUNCTION(XMLElementGetAttributeNames), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("XMLElement", "bool HasChild(const String&in) const", asMETHOD(XMLElement, HasChild), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "XMLElement GetChild(const String&in name = String()) const", asMETHOD(XMLElement, GetChild), asCALL_THISCALL);
-    engine->RegisterObjectMethod("XMLElement", "XMLElement GetNext(const String&in name = String()) const", asMETHOD(XMLElement, GetNext), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "bool HasChild(const String&in) const", asMETHODPR(XMLElement, HasChild, (const String&) const, bool), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "XMLElement GetChild(const String&in name = String()) const", asMETHODPR(XMLElement, GetChild, (const String&) const, XMLElement), asCALL_THISCALL);
+    engine->RegisterObjectMethod("XMLElement", "XMLElement GetNext(const String&in name = String()) const", asMETHODPR(XMLElement, GetNext, (const String&) const, XMLElement), asCALL_THISCALL);
     engine->RegisterObjectMethod("XMLElement", "bool GetBool(const String&in) const", asMETHOD(XMLElement, GetBool), asCALL_THISCALL);
     engine->RegisterObjectMethod("XMLElement", "bool GetBool(const String&in) const", asMETHOD(XMLElement, GetBool), asCALL_THISCALL);
     engine->RegisterObjectMethod("XMLElement", "BoundingBox GetBoundingBox() const", asMETHOD(XMLElement, GetBoundingBox), asCALL_THISCALL);
     engine->RegisterObjectMethod("XMLElement", "BoundingBox GetBoundingBox() const", asMETHOD(XMLElement, GetBoundingBox), asCALL_THISCALL);
     engine->RegisterObjectMethod("XMLElement", "Color GetColor(const String&in) const", asMETHOD(XMLElement, GetColor), asCALL_THISCALL);
     engine->RegisterObjectMethod("XMLElement", "Color GetColor(const String&in) const", asMETHOD(XMLElement, GetColor), asCALL_THISCALL);

+ 1 - 1
Engine/Graphics/Direct3D9/D3D9TextureCube.cpp

@@ -293,7 +293,7 @@ bool TextureCube::Load(Deserializer& source)
     unsigned faces = 0;
     unsigned faces = 0;
     while (faceElem && faces < MAX_CUBEMAP_FACES)
     while (faceElem && faces < MAX_CUBEMAP_FACES)
     {
     {
-        String name = faceElem.GetString("name");
+        String name = faceElem.GetAttribute("name");
         
         
         String faceTexPath, faceTexName, faceTexExt;
         String faceTexPath, faceTexName, faceTexExt;
         SplitPath(name, faceTexPath, faceTexName, faceTexExt);
         SplitPath(name, faceTexPath, faceTexName, faceTexExt);

+ 5 - 5
Engine/Graphics/Material.cpp

@@ -141,7 +141,7 @@ bool Material::Load(Deserializer& source)
     techniques_.Clear();
     techniques_.Clear();
     while (techniqueElem)
     while (techniqueElem)
     {
     {
-        Technique* technique = cache->GetResource<Technique>(techniqueElem.GetString("name"));
+        Technique* technique = cache->GetResource<Technique>(techniqueElem.GetAttribute("name"));
         if (technique)
         if (technique)
         {
         {
             TechniqueEntry newTechnique;
             TechniqueEntry newTechnique;
@@ -168,7 +168,7 @@ bool Material::Load(Deserializer& source)
         }
         }
         if (unit != MAX_MATERIAL_TEXTURE_UNITS)
         if (unit != MAX_MATERIAL_TEXTURE_UNITS)
         {
         {
-            String name = textureElem.GetString("name");
+            String name = textureElem.GetAttribute("name");
             // Detect cube maps by file extension: they are defined by an XML file
             // Detect cube maps by file extension: they are defined by an XML file
             if (GetExtension(name) == ".xml")
             if (GetExtension(name) == ".xml")
                 SetTexture(unit, cache->GetResource<TextureCube>(name));
                 SetTexture(unit, cache->GetResource<TextureCube>(name));
@@ -181,7 +181,7 @@ bool Material::Load(Deserializer& source)
     XMLElement parameterElem = rootElem.GetChild("parameter");
     XMLElement parameterElem = rootElem.GetChild("parameter");
     while (parameterElem)
     while (parameterElem)
     {
     {
-        String name = parameterElem.GetString("name");
+        String name = parameterElem.GetAttribute("name");
         Vector4 value = parameterElem.GetVector("value");
         Vector4 value = parameterElem.GetVector("value");
         SetShaderParameter(name, value);
         SetShaderParameter(name, value);
         
         
@@ -190,11 +190,11 @@ bool Material::Load(Deserializer& source)
     
     
     XMLElement cullElem = rootElem.GetChild("cull");
     XMLElement cullElem = rootElem.GetChild("cull");
     if (cullElem)
     if (cullElem)
-        SetCullMode((CullMode)GetStringListIndex(cullElem.GetString("value"), cullModeNames, CULL_CCW));
+        SetCullMode((CullMode)GetStringListIndex(cullElem.GetAttribute("value"), cullModeNames, CULL_CCW));
     
     
     XMLElement shadowCullElem = rootElem.GetChild("shadowcull");
     XMLElement shadowCullElem = rootElem.GetChild("shadowcull");
     if (shadowCullElem)
     if (shadowCullElem)
-        SetShadowCullMode((CullMode)GetStringListIndex(shadowCullElem.GetString("value"), cullModeNames, CULL_CCW));
+        SetShadowCullMode((CullMode)GetStringListIndex(shadowCullElem.GetAttribute("value"), cullModeNames, CULL_CCW));
     
     
     // Calculate memory use
     // Calculate memory use
     unsigned memoryUse = sizeof(Material);
     unsigned memoryUse = sizeof(Material);

+ 3 - 3
Engine/Graphics/OpenGL/OGLShader.cpp

@@ -76,12 +76,12 @@ bool Shader::Load(Deserializer& source)
         return false;
         return false;
     
     
     XMLElement shaderElem = file->GetRoot();
     XMLElement shaderElem = file->GetRoot();
-    shaderType_ = shaderElem.GetString("type") == "vs" ? VS : PS;
+    shaderType_ = String(shaderElem.GetAttribute("type")) == "vs" ? VS : PS;
     
     
     XMLElement variationElem = shaderElem.GetChild("variation");
     XMLElement variationElem = shaderElem.GetChild("variation");
     while (variationElem)
     while (variationElem)
     {
     {
-        String variationName = variationElem.GetString("name");
+        String variationName = variationElem.GetAttribute("name");
         StringHash nameHash(variationName);
         StringHash nameHash(variationName);
         SharedPtr<ShaderVariation> newVariation(new ShaderVariation(this, shaderType_));
         SharedPtr<ShaderVariation> newVariation(new ShaderVariation(this, shaderType_));
         if (!variationName.Empty())
         if (!variationName.Empty())
@@ -89,7 +89,7 @@ bool Shader::Load(Deserializer& source)
         else
         else
             newVariation->SetName(fileName);
             newVariation->SetName(fileName);
         newVariation->SetSourceCode(sourceCode_, sourceCodeLength_);
         newVariation->SetSourceCode(sourceCode_, sourceCodeLength_);
-        newVariation->SetDefines(variationElem.GetString("defines").Split(' '));
+        newVariation->SetDefines(String(variationElem.GetAttribute("defines")).Split(' '));
         
         
         if (variations_.Contains(nameHash))
         if (variations_.Contains(nameHash))
             LOGERROR("Shader variation name hash collision: " + variationName);
             LOGERROR("Shader variation name hash collision: " + variationName);

+ 1 - 1
Engine/Graphics/OpenGL/OGLTextureCube.cpp

@@ -265,7 +265,7 @@ bool TextureCube::Load(Deserializer& source)
     unsigned faces = 0;
     unsigned faces = 0;
     while (faceElem && faces < MAX_CUBEMAP_FACES)
     while (faceElem && faces < MAX_CUBEMAP_FACES)
     {
     {
-        String name = faceElem.GetString("name");
+        String name = faceElem.GetAttribute("name");
         
         
         String faceTexPath, faceTexName, faceTexExt;
         String faceTexPath, faceTexName, faceTexExt;
         SplitPath(name, faceTexPath, faceTexName, faceTexExt);
         SplitPath(name, faceTexPath, faceTexName, faceTexExt);

+ 1 - 1
Engine/Graphics/ParticleEmitter.cpp

@@ -231,7 +231,7 @@ bool ParticleEmitter::LoadParameters(XMLFile* file)
     parameterSource_ = file;
     parameterSource_ = file;
     
     
     if (rootElem.HasChild("material"))
     if (rootElem.HasChild("material"))
-        SetMaterial(cache->GetResource<Material>(rootElem.GetChild("material").GetString("name")));
+        SetMaterial(cache->GetResource<Material>(rootElem.GetChild("material").GetAttribute("name")));
     
     
     if (rootElem.HasChild("numparticles"))
     if (rootElem.HasChild("numparticles"))
         SetNumParticles(rootElem.GetChild("numparticles").GetInt("value"));
         SetNumParticles(rootElem.GetChild("numparticles").GetInt("value"));

+ 7 - 7
Engine/Graphics/PostProcess.cpp

@@ -110,10 +110,10 @@ bool PostProcess::LoadParameters(XMLFile* file)
     XMLElement rtElem = rootElem.GetChild("rendertarget");
     XMLElement rtElem = rootElem.GetChild("rendertarget");
     while (rtElem)
     while (rtElem)
     {
     {
-        String name = rtElem.GetString("name");
+        String name = rtElem.GetAttribute("name");
         
         
         unsigned format = Graphics::GetRGBFormat();
         unsigned format = Graphics::GetRGBFormat();
-        String formatName = rtElem.GetString("format").ToLower();
+        String formatName = rtElem.GetStringLower("format");
         if (formatName == "rgba")
         if (formatName == "rgba")
             format = Graphics::GetRGBAFormat();
             format = Graphics::GetRGBAFormat();
         else if (formatName == "float")
         else if (formatName == "float")
@@ -152,9 +152,9 @@ bool PostProcess::LoadParameters(XMLFile* file)
     while (passElem)
     while (passElem)
     {
     {
         SharedPtr<PostProcessPass> pass(new PostProcessPass());
         SharedPtr<PostProcessPass> pass(new PostProcessPass());
-        pass->SetVertexShader(passElem.GetString("vs"));
-        pass->SetPixelShader(passElem.GetString("ps"));
-        pass->SetOutput(passElem.GetString("output"));
+        pass->SetVertexShader(passElem.GetAttribute("vs"));
+        pass->SetPixelShader(passElem.GetAttribute("ps"));
+        pass->SetOutput(passElem.GetAttribute("output"));
         
         
         XMLElement textureElem = passElem.GetChild("texture");
         XMLElement textureElem = passElem.GetChild("texture");
         while (textureElem)
         while (textureElem)
@@ -169,7 +169,7 @@ bool PostProcess::LoadParameters(XMLFile* file)
             }
             }
             if (unit != MAX_MATERIAL_TEXTURE_UNITS)
             if (unit != MAX_MATERIAL_TEXTURE_UNITS)
             {
             {
-                String name = textureElem.GetString("name");
+                String name = textureElem.GetAttribute("name");
                 pass->SetTexture(unit, name);
                 pass->SetTexture(unit, name);
             }
             }
             textureElem = textureElem.GetNext("texture");
             textureElem = textureElem.GetNext("texture");
@@ -178,7 +178,7 @@ bool PostProcess::LoadParameters(XMLFile* file)
         XMLElement parameterElem = passElem.GetChild("parameter");
         XMLElement parameterElem = passElem.GetChild("parameter");
         while (parameterElem)
         while (parameterElem)
         {
         {
-            String name = parameterElem.GetString("name");
+            String name = parameterElem.GetAttribute("name");
             Vector4 value = parameterElem.GetVector("value");
             Vector4 value = parameterElem.GetVector("value");
             pass->SetShaderParameter(name, value);
             pass->SetShaderParameter(name, value);
             
             

+ 2 - 2
Engine/Graphics/Technique.cpp

@@ -168,10 +168,10 @@ bool Technique::Load(Deserializer& source)
             Pass* newPass = CreatePass(type);
             Pass* newPass = CreatePass(type);
             
             
             if (passElem.HasAttribute("vs"))
             if (passElem.HasAttribute("vs"))
-                newPass->SetVertexShader(passElem.GetString("vs"));
+                newPass->SetVertexShader(passElem.GetAttribute("vs"));
             
             
             if (passElem.HasAttribute("ps"))
             if (passElem.HasAttribute("ps"))
-                newPass->SetPixelShader(passElem.GetString("ps"));
+                newPass->SetPixelShader(passElem.GetAttribute("ps"));
             
             
             if (passElem.HasAttribute("alphatest"))
             if (passElem.HasAttribute("alphatest"))
                 newPass->SetAlphaTest(passElem.GetBool("alphatest"));
                 newPass->SetAlphaTest(passElem.GetBool("alphatest"));

+ 66 - 17
Engine/Resource/XMLElement.cpp

@@ -51,12 +51,17 @@ XMLElement::~XMLElement()
 }
 }
 
 
 XMLElement XMLElement::CreateChild(const String& name)
 XMLElement XMLElement::CreateChild(const String& name)
+{
+    return CreateChild(name.CString());
+}
+
+XMLElement XMLElement::CreateChild(const char* name)
 {
 {
     if (!file_ || !node_)
     if (!file_ || !node_)
         return XMLElement();
         return XMLElement();
     
     
     pugi::xml_node node(node_);
     pugi::xml_node node(node_);
-    pugi::xml_node child = node.append_child(name.CString());
+    pugi::xml_node child = node.append_child(name);
     return XMLElement(file_, child.internal_object());
     return XMLElement(file_, child.internal_object());
 }
 }
 
 
@@ -71,21 +76,31 @@ bool XMLElement::RemoveChild(const XMLElement& element)
 }
 }
 
 
 bool XMLElement::RemoveChild(const String& name)
 bool XMLElement::RemoveChild(const String& name)
+{
+    return RemoveChild(name.CString());
+}
+
+bool XMLElement::RemoveChild(const char* name)
 {
 {
     if (!file_ || !node_)
     if (!file_ || !node_)
         return false;
         return false;
     
     
     pugi::xml_node node(node_);
     pugi::xml_node node(node_);
-    return node.remove_child(name.CString());
+    return node.remove_child(name);
 }
 }
 
 
 bool XMLElement::RemoveChildren(const String& name)
 bool XMLElement::RemoveChildren(const String& name)
+{
+    return RemoveChildren(name.CString());
+}
+
+bool XMLElement::RemoveChildren(const char* name)
 {
 {
     if (!file_ || !node_)
     if (!file_ || !node_)
         return false;
         return false;
     
     
     pugi::xml_node node(node_);
     pugi::xml_node node(node_);
-    if (name.Empty())
+    if (!String::CStringLength(name))
     {
     {
         for (;;)
         for (;;)
         {
         {
@@ -99,7 +114,7 @@ bool XMLElement::RemoveChildren(const String& name)
     {
     {
         for (;;)
         for (;;)
         {
         {
-            pugi::xml_node child = node.child(name.CString());
+            pugi::xml_node child = node.child(name);
             if (child.empty())
             if (child.empty())
                 break;
                 break;
             node.remove_child(child);
             node.remove_child(child);
@@ -110,15 +125,20 @@ bool XMLElement::RemoveChildren(const String& name)
 }
 }
 
 
 bool XMLElement::SetAttribute(const String& name, const String& value)
 bool XMLElement::SetAttribute(const String& name, const String& value)
+{
+    return SetAttribute(name.CString(), value.CString());
+}
+
+bool XMLElement::SetAttribute(const char* name, const char* value)
 {
 {
     if (!file_ || !node_)
     if (!file_ || !node_)
         return false;
         return false;
     
     
     pugi::xml_node node(node_);
     pugi::xml_node node(node_);
-    pugi::xml_attribute attr = node.attribute(name.CString());
+    pugi::xml_attribute attr = node.attribute(name);
     if (attr.empty())
     if (attr.empty())
-        attr = node.append_attribute(name.CString());
-    attr.set_value(value.CString());
+        attr = node.append_attribute(name);
+    attr.set_value(value);
     return true;
     return true;
 }
 }
 
 
@@ -218,7 +238,7 @@ bool XMLElement::SetVariantValue(const Variant& value)
         return SetVariantMap(value.GetVariantMap());
         return SetVariantMap(value.GetVariantMap());
         
         
     default:
     default:
-        return SetAttribute("value", value.ToString());
+        return SetAttribute("value", value.ToString().CString());
     }
     }
 }
 }
 
 
@@ -251,7 +271,7 @@ bool XMLElement::SetResourceRefList(const ResourceRefList& value)
         str += cache->GetResourceName(value.ids_[i]);
         str += cache->GetResourceName(value.ids_[i]);
     }
     }
     
     
-    SetAttribute("value", str);
+    SetAttribute("value", str.CString());
     return true;
     return true;
 }
 }
 
 
@@ -314,36 +334,51 @@ String XMLElement::GetName() const
 }
 }
 
 
 bool XMLElement::HasChild(const String& name) const
 bool XMLElement::HasChild(const String& name) const
+{
+    return HasChild(name.CString());
+}
+
+bool XMLElement::HasChild(const char* name) const
 {
 {
     if (!file_ || !node_)
     if (!file_ || !node_)
         return false;
         return false;
     
     
     pugi::xml_node node(node_);
     pugi::xml_node node(node_);
-    return !node.child(name.CString()).empty();
+    return !node.child(name).empty();
 }
 }
 
 
 XMLElement XMLElement::GetChild(const String& name) const
 XMLElement XMLElement::GetChild(const String& name) const
+{
+    return GetChild(name.CString());
+}
+
+XMLElement XMLElement::GetChild(const char* name) const
 {
 {
     if (!file_ || !node_)
     if (!file_ || !node_)
         return XMLElement();
         return XMLElement();
     
     
     pugi::xml_node node(node_);
     pugi::xml_node node(node_);
-    if (name.Empty())
+    if (!String::CStringLength(name))
         return XMLElement(file_, node.first_child().internal_object());
         return XMLElement(file_, node.first_child().internal_object());
     else
     else
-        return XMLElement(file_, node.child(name.CString()).internal_object());
+        return XMLElement(file_, node.child(name).internal_object());
 }
 }
 
 
 XMLElement XMLElement::GetNext(const String& name) const
 XMLElement XMLElement::GetNext(const String& name) const
+{
+    return GetNext(name.CString());
+}
+
+XMLElement XMLElement::GetNext(const char* name) const
 {
 {
     if (!file_ || !node_)
     if (!file_ || !node_)
         return XMLElement();
         return XMLElement();
     
     
     pugi::xml_node node(node_);
     pugi::xml_node node(node_);
-    if (name.Empty())
+    if (!String::CStringLength(name))
         return XMLElement(file_, node.next_sibling().internal_object());
         return XMLElement(file_, node.next_sibling().internal_object());
     else
     else
-        return XMLElement(file_, node.next_sibling(name.CString()).internal_object());
+        return XMLElement(file_, node.next_sibling(name).internal_object());
 }
 }
 
 
 XMLElement XMLElement::GetParent() const
 XMLElement XMLElement::GetParent() const
@@ -374,12 +409,17 @@ unsigned XMLElement::GetNumAttributes() const
 }
 }
 
 
 bool XMLElement::HasAttribute(const String& name) const
 bool XMLElement::HasAttribute(const String& name) const
+{
+    return HasAttribute(name.CString());
+}
+
+bool XMLElement::HasAttribute(const char* name) const
 {
 {
     if (!file_ || !node_)
     if (!file_ || !node_)
         return false;
         return false;
     
     
     pugi::xml_node node(node_);
     pugi::xml_node node(node_);
-    return !node.attribute(name.CString()).empty();
+    return !node.attribute(name).empty();
 }
 }
 
 
 String XMLElement::GetAttribute(const String& name) const
 String XMLElement::GetAttribute(const String& name) const
@@ -391,6 +431,15 @@ String XMLElement::GetAttribute(const String& name) const
     return String(node.attribute(name.CString()).value());
     return String(node.attribute(name.CString()).value());
 }
 }
 
 
+const char* XMLElement::GetAttribute(const char* name) const
+{
+    if (!file_ || !node_)
+        return 0;
+    
+    pugi::xml_node node(node_);
+    return node.attribute(name).value();
+}
+
 Vector<String> XMLElement::GetAttributeNames() const
 Vector<String> XMLElement::GetAttributeNames() const
 {
 {
     if (!file_ || !node_)
     if (!file_ || !node_)
@@ -526,7 +575,7 @@ ResourceRef XMLElement::GetResourceRef() const
 {
 {
     ResourceRef ret;
     ResourceRef ret;
     
     
-    Vector<String> values = GetAttribute("value").Split(';');
+    Vector<String> values = String::Split(GetAttribute("value"), ';');
     if (values.Size() == 2)
     if (values.Size() == 2)
     {
     {
         ret.type_ = ShortStringHash(values[0]);
         ret.type_ = ShortStringHash(values[0]);
@@ -545,7 +594,7 @@ ResourceRefList XMLElement::GetResourceRefList() const
 {
 {
     ResourceRefList ret;
     ResourceRefList ret;
     
     
-    Vector<String> values = GetAttribute("value").Split(';');
+    Vector<String> values = String::Split(GetAttribute("value"), ';');
     if (values.Size() >= 1)
     if (values.Size() >= 1)
     {
     {
         // Whenever we encounter resource names read from a ResourceRefList XML element, store the reverse mapping to
         // Whenever we encounter resource names read from a ResourceRefList XML element, store the reverse mapping to

+ 19 - 1
Engine/Resource/XMLElement.h

@@ -50,14 +50,22 @@ public:
     
     
     /// Create a child element.
     /// Create a child element.
     XMLElement CreateChild(const String& name);
     XMLElement CreateChild(const String& name);
+    /// Create a child element.
+    XMLElement CreateChild(const char* name);
     /// Remove a child element. Return true if successful.
     /// Remove a child element. Return true if successful.
     bool RemoveChild(const XMLElement& element);
     bool RemoveChild(const XMLElement& element);
     /// Remove a child element by name. Return true if successful.
     /// Remove a child element by name. Return true if successful.
     bool RemoveChild(const String& name);
     bool RemoveChild(const String& name);
+    /// Remove a child element by name. Return true if successful.
+    bool RemoveChild(const char* name);
     /// Remove child elements of certain name, or all child elements if name is empty. Return true if successful.
     /// Remove child elements of certain name, or all child elements if name is empty. Return true if successful.
     bool RemoveChildren(const String& name = String());
     bool RemoveChildren(const String& name = String());
+    /// Remove child elements of certain name, or all child elements if name is empty. Return true if successful.
+    bool RemoveChildren(const char* name);
     /// %Set an attribute.
     /// %Set an attribute.
     bool SetAttribute(const String& name, const String& value);
     bool SetAttribute(const String& name, const String& value);
+    /// %Set an attribute.
+    bool SetAttribute(const char* name, const char* value);
     /// %Set a bool attribute.
     /// %Set a bool attribute.
     bool SetBool(const String& name, bool value);
     bool SetBool(const String& name, bool value);
     /// %Set a BoundingBox attribute.
     /// %Set a BoundingBox attribute.
@@ -111,18 +119,28 @@ public:
     String GetName() const;
     String GetName() const;
     /// Return whether has a child element.
     /// Return whether has a child element.
     bool HasChild(const String& name) const;
     bool HasChild(const String& name) const;
+    /// Return whether has a child element.
+    bool HasChild(const char* name) const;
     /// Return child element, or null if missing.
     /// Return child element, or null if missing.
     XMLElement GetChild(const String& name = String()) const;
     XMLElement GetChild(const String& name = String()) const;
+    /// Return child element, or null if missing.
+    XMLElement GetChild(const char* name) const;
     /// Return next sibling element.
     /// Return next sibling element.
     XMLElement GetNext(const String& name = String()) const;
     XMLElement GetNext(const String& name = String()) const;
+    /// Return next sibling element.
+    XMLElement GetNext(const char* name) const;
     /// Return parent element.
     /// Return parent element.
     XMLElement GetParent() const;
     XMLElement GetParent() const;
     /// Return number of attributes.
     /// Return number of attributes.
     unsigned GetNumAttributes() const;
     unsigned GetNumAttributes() const;
     /// Return whether has an attribute.
     /// Return whether has an attribute.
     bool HasAttribute(const String& name) const;
     bool HasAttribute(const String& name) const;
+    /// Return whether has an attribute.
+    bool HasAttribute(const char* name) const;
     /// Return attribute, or empty if missing.
     /// Return attribute, or empty if missing.
     String GetAttribute(const String& name) const;
     String GetAttribute(const String& name) const;
+    /// Return attribute, or empty if missing.
+    const char* GetAttribute(const char* name) const;
     /// Return names of all attributes.
     /// Return names of all attributes.
     Vector<String> GetAttributeNames() const;
     Vector<String> GetAttributeNames() const;
     /// Return bool attribute, or false if missing.
     /// Return bool attribute, or false if missing.
@@ -175,7 +193,7 @@ public:
     Vector4 GetVector(const String& name) const;
     Vector4 GetVector(const String& name) const;
     /// Return XML file.
     /// Return XML file.
     XMLFile* GetFile() const;
     XMLFile* GetFile() const;
-    /// Return pugixml node.
+    /// Return pugixml node.s
     pugi::xml_node_struct* GetNode() const { return node_; }
     pugi::xml_node_struct* GetNode() const { return node_; }
     
     
 private:
 private:

+ 1 - 1
Engine/Scene/Node.cpp

@@ -1090,7 +1090,7 @@ bool Node::LoadXML(const XMLElement& source, SceneResolver& resolver, bool readC
     XMLElement compElem = source.GetChild("component");
     XMLElement compElem = source.GetChild("component");
     while (compElem)
     while (compElem)
     {
     {
-        String typeName = compElem.GetString("type");
+        String typeName = compElem.GetAttribute("type");
         unsigned compID = compElem.GetInt("id");
         unsigned compID = compElem.GetInt("id");
         Component* newComponent = CreateComponent(ShortStringHash(typeName), rewriteIDs ? 0 : compID, (mode == REPLICATED &&
         Component* newComponent = CreateComponent(ShortStringHash(typeName), rewriteIDs ? 0 : compID, (mode == REPLICATED &&
             compID < FIRST_LOCAL_ID) ? REPLICATED : LOCAL);
             compID < FIRST_LOCAL_ID) ? REPLICATED : LOCAL);

+ 4 - 4
Engine/Scene/Serializable.cpp

@@ -267,7 +267,7 @@ bool Serializable::LoadXML(const XMLElement& source)
     
     
     while (attrElem)
     while (attrElem)
     {
     {
-        String name = attrElem.GetString("name");
+        String name = attrElem.GetAttribute("name");
         
         
         unsigned i = startIndex;
         unsigned i = startIndex;
         unsigned attempts = attributes->Size();
         unsigned attempts = attributes->Size();
@@ -280,7 +280,7 @@ bool Serializable::LoadXML(const XMLElement& source)
                 // If enums specified, do enum lookup and int assignment. Otherwise assign the variant directly
                 // If enums specified, do enum lookup and int assignment. Otherwise assign the variant directly
                 if (attr.enumNames_)
                 if (attr.enumNames_)
                 {
                 {
-                    String value = attrElem.GetString("value");
+                    String value = attrElem.GetAttribute("value");
                     const String* enumPtr = attr.enumNames_;
                     const String* enumPtr = attr.enumNames_;
                     int enumValue = 0;
                     int enumValue = 0;
                     bool enumFound = false;
                     bool enumFound = false;
@@ -343,13 +343,13 @@ bool Serializable::SaveXML(XMLElement& dest)
             continue;
             continue;
         
         
         XMLElement attrElem = dest.CreateChild("attribute");
         XMLElement attrElem = dest.CreateChild("attribute");
-        attrElem.SetString("name", String(attr.name_));
+        attrElem.SetAttribute("name", String(attr.name_).CString());
         OnGetAttribute(attr, value);
         OnGetAttribute(attr, value);
         // If enums specified, set as an enum string. Otherwise set directly as a Variant
         // If enums specified, set as an enum string. Otherwise set directly as a Variant
         if (attr.enumNames_)
         if (attr.enumNames_)
         {
         {
             int enumValue = value.GetInt();
             int enumValue = value.GetInt();
-            attrElem.SetString("value", String(attr.enumNames_[enumValue]));
+            attrElem.SetAttribute("value", String(attr.enumNames_[enumValue]).CString());
         }
         }
         else
         else
             attrElem.SetVariantValue(value);
             attrElem.SetVariantValue(value);

+ 1 - 1
Engine/UI/BorderImage.cpp

@@ -53,7 +53,7 @@ void BorderImage::SetStyle(const XMLElement& element)
     UIElement::SetStyle(element);
     UIElement::SetStyle(element);
     
     
     if (element.HasChild("texture"))
     if (element.HasChild("texture"))
-        SetTexture(GetSubsystem<ResourceCache>()->GetResource<Texture2D>(element.GetChild("texture").GetString("name")));
+        SetTexture(GetSubsystem<ResourceCache>()->GetResource<Texture2D>(element.GetChild("texture").GetAttribute("name")));
     if (element.HasChild("imagerect"))
     if (element.HasChild("imagerect"))
     {
     {
         XMLElement imageElem = element.GetChild("imagerect");
         XMLElement imageElem = element.GetChild("imagerect");

+ 1 - 1
Engine/UI/Cursor.cpp

@@ -76,7 +76,7 @@ void Cursor::SetStyle(const XMLElement& element)
     while (shapeElem)
     while (shapeElem)
     {
     {
         CursorShape shape = (CursorShape)GetStringListIndex(shapeElem.GetStringLower("name"), shapeNames, CS_NORMAL);
         CursorShape shape = (CursorShape)GetStringListIndex(shapeElem.GetStringLower("name"), shapeNames, CS_NORMAL);
-        DefineShape(shape, GetSubsystem<ResourceCache>()->GetResource<Texture2D>(shapeElem.GetString("texture")),
+        DefineShape(shape, GetSubsystem<ResourceCache>()->GetResource<Texture2D>(shapeElem.GetAttribute("texture")),
             shapeElem.GetIntRect("imagerect"), shapeElem.GetIntVector2("hotspot"));
             shapeElem.GetIntRect("imagerect"), shapeElem.GetIntVector2("hotspot"));
         shapeElem = shapeElem.GetNext("shape");
         shapeElem = shapeElem.GetNext("shape");
     }
     }

+ 1 - 1
Engine/UI/DropDownList.cpp

@@ -82,7 +82,7 @@ void DropDownList::SetStyle(const XMLElement& element)
         while (itemElem)
         while (itemElem)
         {
         {
             if (itemElem.HasAttribute("name"))
             if (itemElem.HasAttribute("name"))
-                AddItem(root->GetChild(itemElem.GetString("name"), true));
+                AddItem(root->GetChild(itemElem.GetAttribute("name"), true));
             itemElem = itemElem.GetNext("popupitem");
             itemElem = itemElem.GetNext("popupitem");
         }
         }
     }
     }

+ 2 - 2
Engine/UI/LineEdit.cpp

@@ -87,7 +87,7 @@ void LineEdit::SetStyle(const XMLElement& element)
     if (textElem)
     if (textElem)
     {
     {
         if (textElem.HasAttribute("value"))
         if (textElem.HasAttribute("value"))
-            SetText(textElem.GetString("value"));
+            SetText(textElem.GetAttribute("value"));
         text_->SetStyle(textElem);
         text_->SetStyle(textElem);
     }
     }
     
     
@@ -101,7 +101,7 @@ void LineEdit::SetStyle(const XMLElement& element)
         SetCursorBlinkRate(element.GetChild("cursorblinkrate").GetFloat("value"));
         SetCursorBlinkRate(element.GetChild("cursorblinkrate").GetFloat("value"));
     if (element.HasChild("echocharacter"))
     if (element.HasChild("echocharacter"))
     {
     {
-        String text = element.GetChild("echocharacter").GetString("value");
+        String text = element.GetChild("echocharacter").GetAttribute("value");
         if (text.Length())
         if (text.Length())
             SetEchoCharacter(text[0]);
             SetEchoCharacter(text[0]);
     }
     }

+ 1 - 1
Engine/UI/ListView.cpp

@@ -94,7 +94,7 @@ void ListView::SetStyle(const XMLElement& element)
         {
         {
             if (itemElem.HasAttribute("name"))
             if (itemElem.HasAttribute("name"))
             {
             {
-                UIElement* item = root->GetChild(itemElem.GetString("name"), true);
+                UIElement* item = root->GetChild(itemElem.GetAttribute("name"), true);
                 AddItem(item);
                 AddItem(item);
                 if (itemElem.HasAttribute("indent"))
                 if (itemElem.HasAttribute("indent"))
                     item->vars_[indentHash] = itemElem.GetInt("indent");
                     item->vars_[indentHash] = itemElem.GetInt("indent");

+ 1 - 1
Engine/UI/Menu.cpp

@@ -67,7 +67,7 @@ void Menu::SetStyle(const XMLElement& element)
     {
     {
         UIElement* root = GetRoot();
         UIElement* root = GetRoot();
         if (root)
         if (root)
-            SetPopup(root->GetChild(popupElem.GetString("name"), true));
+            SetPopup(root->GetChild(popupElem.GetAttribute("name"), true));
     }
     }
     
     
     if (element.HasChild("popupoffset"))
     if (element.HasChild("popupoffset"))

+ 1 - 1
Engine/UI/ScrollView.cpp

@@ -97,7 +97,7 @@ void ScrollView::SetStyle(const XMLElement& element)
     
     
     UIElement* root = GetRoot();
     UIElement* root = GetRoot();
     if (root && element.HasChild("contentelement"))
     if (root && element.HasChild("contentelement"))
-        SetContentElement(root->GetChild(element.GetChild("contentelement").GetString("name"), true));
+        SetContentElement(root->GetChild(element.GetChild("contentelement").GetAttribute("name"), true));
     
     
     // Set the scrollbar orientations again and perform size update now that the style is known
     // Set the scrollbar orientations again and perform size update now that the style is known
     horizontalScrollBar_->SetOrientation(O_HORIZONTAL);
     horizontalScrollBar_->SetOrientation(O_HORIZONTAL);

+ 3 - 3
Engine/UI/Text.cpp

@@ -78,7 +78,7 @@ void Text::SetStyle(const XMLElement& element)
     if (element.HasChild("font"))
     if (element.HasChild("font"))
     {
     {
         XMLElement fontElem = element.GetChild("font");
         XMLElement fontElem = element.GetChild("font");
-        String fontName = fontElem.GetString("name");
+        String fontName = fontElem.GetAttribute("name");
         
         
         ResourceCache* cache = GetSubsystem<ResourceCache>();
         ResourceCache* cache = GetSubsystem<ResourceCache>();
         if (cache->Exists(fontName))
         if (cache->Exists(fontName))
@@ -94,7 +94,7 @@ void Text::SetStyle(const XMLElement& element)
         else if (element.HasChild("fallbackfont"))
         else if (element.HasChild("fallbackfont"))
         {
         {
             fontElem = element.GetChild("fallbackfont");
             fontElem = element.GetChild("fallbackfont");
-            String fontName = fontElem.GetString("name");
+            String fontName = fontElem.GetAttribute("name");
             Font* font = cache->GetResource<Font>(fontName);
             Font* font = cache->GetResource<Font>(fontName);
             if (font)
             if (font)
             {
             {
@@ -106,7 +106,7 @@ void Text::SetStyle(const XMLElement& element)
     }
     }
     if (element.HasChild("text"))
     if (element.HasChild("text"))
     {
     {
-        text_ = element.GetChild("text").GetString("value").Replaced("\\n", "\n");
+        text_ = String(element.GetChild("text").GetAttribute("value")).Replaced("\\n", "\n");
         changed = true;
         changed = true;
     }
     }
     if (element.HasChild("textalignment"))
     if (element.HasChild("textalignment"))

+ 6 - 6
Engine/UI/UI.cpp

@@ -343,7 +343,7 @@ SharedPtr<UIElement> UI::LoadLayout(XMLFile* file, XMLFile* styleFile)
         return root;
         return root;
     }
     }
     
     
-    String type = rootElem.GetString("type");
+    String type = rootElem.GetAttribute("type");
     if (type.Empty())
     if (type.Empty())
         type = "UIElement";
         type = "UIElement";
     
     
@@ -353,9 +353,9 @@ SharedPtr<UIElement> UI::LoadLayout(XMLFile* file, XMLFile* styleFile)
         LOGERROR("Could not create UI element " + type);
         LOGERROR("Could not create UI element " + type);
         return root;
         return root;
     }
     }
-    root->SetName(rootElem.GetString("name"));
+    root->SetName(rootElem.GetAttribute("name"));
     
     
-    String styleName = rootElem.HasAttribute("style") ? rootElem.GetString("style") : rootElem.GetString("type");
+    String styleName = rootElem.HasAttribute("style") ? rootElem.GetAttribute("style") : rootElem.GetAttribute("type");
     // First set the base style from the style file if exists, then apply UI layout overrides
     // First set the base style from the style file if exists, then apply UI layout overrides
     if (styleFile)
     if (styleFile)
         root->SetStyle(styleFile, styleName);
         root->SetStyle(styleFile, styleName);
@@ -633,7 +633,7 @@ void UI::LoadLayout(UIElement* current, const XMLElement& elem, XMLFile* styleFi
     while (childElem)
     while (childElem)
     {
     {
         // Create element
         // Create element
-        String type = childElem.GetString("type");
+        String type = childElem.GetAttribute("type");
         if (type.Empty())
         if (type.Empty())
             type = "UIElement";
             type = "UIElement";
         
         
@@ -644,13 +644,13 @@ void UI::LoadLayout(UIElement* current, const XMLElement& elem, XMLFile* styleFi
             childElem = childElem.GetNext("element");
             childElem = childElem.GetNext("element");
             continue;
             continue;
         }
         }
-        child->SetName(childElem.GetString("name"));
+        child->SetName(childElem.GetAttribute("name"));
         
         
         // Add to the hierarchy
         // Add to the hierarchy
         current->AddChild(child);
         current->AddChild(child);
         
         
         // First set the base style from the style file if exists, then apply UI layout overrides
         // First set the base style from the style file if exists, then apply UI layout overrides
-        String styleName = childElem.HasAttribute("style") ? childElem.GetString("style") : childElem.GetString("type");
+        String styleName = childElem.HasAttribute("style") ? childElem.GetAttribute("style") : childElem.GetAttribute("type");
         if (styleFile)
         if (styleFile)
             child->SetStyle(styleFile, styleName);
             child->SetStyle(styleFile, styleName);
         child->SetStyle(childElem);
         child->SetStyle(childElem);

+ 2 - 2
Engine/UI/UIElement.cpp

@@ -133,7 +133,7 @@ void UIElement::RegisterObject(Context* context)
 void UIElement::SetStyle(const XMLElement& element)
 void UIElement::SetStyle(const XMLElement& element)
 {
 {
     if (element.HasAttribute("name"))
     if (element.HasAttribute("name"))
-        name_ = element.GetString("name");
+        name_ = element.GetAttribute("name");
     if (element.HasChild("position"))
     if (element.HasChild("position"))
         SetPosition(element.GetChild("position").GetIntVector2("value"));
         SetPosition(element.GetChild("position").GetIntVector2("value"));
     if (element.HasChild("size"))
     if (element.HasChild("size"))
@@ -591,7 +591,7 @@ void UIElement::SetStyle(XMLFile* file, const String& typeName)
     XMLElement childElem = rootElem.GetChild("element");
     XMLElement childElem = rootElem.GetChild("element");
     while (childElem)
     while (childElem)
     {
     {
-        if (childElem.GetString("type") == typeName)
+        if (typeName == childElem.GetAttribute("type"))
         {
         {
             SetStyle(childElem);
             SetStyle(childElem);
             return;
             return;

+ 7 - 7
Tools/OgreImporter/OgreImporter.cpp

@@ -144,7 +144,7 @@ void LoadSkeleton(const String& skeletonFileName)
         while (bone)
         while (bone)
         {
         {
             unsigned index = bone.GetInt("id");
             unsigned index = bone.GetInt("id");
-            String name = bone.GetString("name");
+            String name = bone.GetAttribute("name");
             if (index >= bones_.Size())
             if (index >= bones_.Size())
                 bones_.Resize(index + 1);
                 bones_.Resize(index + 1);
             
             
@@ -180,8 +180,8 @@ void LoadSkeleton(const String& skeletonFileName)
         XMLElement boneParent = boneHierarchy.GetChild("boneparent");
         XMLElement boneParent = boneHierarchy.GetChild("boneparent");
         while (boneParent)
         while (boneParent)
         {
         {
-            String bone = boneParent.GetString("bone");
-            String parent = boneParent.GetString("parent");
+            String bone = boneParent.GetAttribute("bone");
+            String parent = boneParent.GetAttribute("parent");
             unsigned i = 0, j = 0;
             unsigned i = 0, j = 0;
             for (i = 0; i < bones_.Size() && bones_[i].name_ != bone; ++i)
             for (i = 0; i < bones_.Size() && bones_[i].name_ != bone; ++i)
             for (j = 0; j < bones_.Size() && bones_[j].name_ != parent; ++j)
             for (j = 0; j < bones_.Size() && bones_[j].name_ != parent; ++j)
@@ -237,7 +237,7 @@ void LoadMesh(const String& inputFileName, bool generateTangents, bool splitSubM
     XMLElement subMeshes = root.GetChild("submeshes");
     XMLElement subMeshes = root.GetChild("submeshes");
     XMLElement skeletonLink = root.GetChild("skeletonlink");
     XMLElement skeletonLink = root.GetChild("skeletonlink");
     
     
-    String skeletonName = skeletonLink.GetString("name");
+    String skeletonName = skeletonLink.GetAttribute("name");
     if (!skeletonName.Empty())
     if (!skeletonName.Empty())
         LoadSkeleton(GetPath(inputFileName) + GetFileName(skeletonName) + ".skeleton.xml");
         LoadSkeleton(GetPath(inputFileName) + GetFileName(skeletonName) + ".skeleton.xml");
     
     
@@ -661,7 +661,7 @@ void LoadMesh(const String& inputFileName, bool generateTangents, bool splitSubM
                 XMLElement anim = animsRoot.GetChild("animation");
                 XMLElement anim = animsRoot.GetChild("animation");
                 while (anim)
                 while (anim)
                 {
                 {
-                    String name = anim.GetString("name");
+                    String name = anim.GetAttribute("name");
                     float length = anim.GetFloat("length");
                     float length = anim.GetFloat("length");
                     HashSet<unsigned> usedPoses;
                     HashSet<unsigned> usedPoses;
                     XMLElement tracks = anim.GetChild("tracks");
                     XMLElement tracks = anim.GetChild("tracks");
@@ -965,14 +965,14 @@ void WriteOutput(const String& outputFileName, bool exportAnimations, bool rotat
             while (animation)
             while (animation)
             {
             {
                 ModelAnimation newAnimation;
                 ModelAnimation newAnimation;
-                newAnimation.name_ = animation.GetString("name");
+                newAnimation.name_ = animation.GetAttribute("name");
                 newAnimation.length_ = animation.GetFloat("length");
                 newAnimation.length_ = animation.GetFloat("length");
                 
                 
                 XMLElement tracksRoot = animation.GetChild("tracks");
                 XMLElement tracksRoot = animation.GetChild("tracks");
                 XMLElement track = tracksRoot.GetChild("track");
                 XMLElement track = tracksRoot.GetChild("track");
                 while (track)
                 while (track)
                 {
                 {
-                    String trackName = track.GetString("bone");
+                    String trackName = track.GetAttribute("bone");
                     ModelBone* bone = 0;
                     ModelBone* bone = 0;
                     for (unsigned i = 0; i < bones_.Size(); ++i)
                     for (unsigned i = 0; i < bones_.Size(); ++i)
                     {
                     {

+ 11 - 11
Tools/ShaderCompiler/ShaderCompiler.cpp

@@ -291,9 +291,9 @@ void Run(const Vector<String>& arguments)
     XMLElement shader = shaders.GetChild("shader");
     XMLElement shader = shaders.GetChild("shader");
     while (shader)
     while (shader)
     {
     {
-        String source = shader.GetString("name");
+        String source = shader.GetAttribute("name");
         ShaderType compileType = Both;
         ShaderType compileType = Both;
-        String type = shader.GetString("type");
+        String type = shader.GetAttribute("type");
         if (type == "VS" || type == "vs")
         if (type == "VS" || type == "vs")
             compileType = VS;
             compileType = VS;
         if (type == "PS" || type == "ps")
         if (type == "PS" || type == "ps")
@@ -307,11 +307,11 @@ void Run(const Vector<String>& arguments)
             String value = variation.GetName();
             String value = variation.GetName();
             if (value == "variation" || value == "option")
             if (value == "variation" || value == "option")
             {
             {
-                String name = variation.GetString("name");
+                String name = variation.GetAttribute("name");
                 
                 
                 Variation newVar(name, value == "option");
                 Variation newVar(name, value == "option");
                 
                 
-                String simpleDefine = variation.GetString("define");
+                String simpleDefine = variation.GetAttribute("define");
                 if (!simpleDefine.Empty())
                 if (!simpleDefine.Empty())
                 {
                 {
                     Vector<String> nameAndValue = simpleDefine.Split('=');
                     Vector<String> nameAndValue = simpleDefine.Split('=');
@@ -327,22 +327,22 @@ void Run(const Vector<String>& arguments)
                     }
                     }
                 }
                 }
                 
                 
-                String simpleExclude = variation.GetString("exclude");
+                String simpleExclude = variation.GetAttribute("exclude");
                 if (!simpleExclude.Empty())
                 if (!simpleExclude.Empty())
                     newVar.excludes_.Push(simpleExclude);
                     newVar.excludes_.Push(simpleExclude);
                 
                 
-                String simpleInclude = variation.GetString("include");
+                String simpleInclude = variation.GetAttribute("include");
                 if (!simpleInclude.Empty())
                 if (!simpleInclude.Empty())
                     newVar.includes_.Push(simpleInclude);
                     newVar.includes_.Push(simpleInclude);
                 
                 
-                String simpleRequire = variation.GetString("require");
+                String simpleRequire = variation.GetAttribute("require");
                 if (!simpleRequire.Empty())
                 if (!simpleRequire.Empty())
                     newVar.requires_.Push(simpleRequire);
                     newVar.requires_.Push(simpleRequire);
                 
                 
                 XMLElement define = variation.GetChild("define");
                 XMLElement define = variation.GetChild("define");
                 while (define)
                 while (define)
                 {
                 {
-                    String defineName = define.GetString("name");
+                    String defineName = define.GetAttribute("name");
                     Vector<String> nameAndValue = defineName.Split('=');
                     Vector<String> nameAndValue = defineName.Split('=');
                     if (nameAndValue.Size() == 2)
                     if (nameAndValue.Size() == 2)
                     {
                     {
@@ -360,21 +360,21 @@ void Run(const Vector<String>& arguments)
                 XMLElement exclude = variation.GetChild("exclude");
                 XMLElement exclude = variation.GetChild("exclude");
                 while (exclude)
                 while (exclude)
                 {
                 {
-                    newVar.excludes_.Push(exclude.GetString("name"));
+                    newVar.excludes_.Push(exclude.GetAttribute("name"));
                     exclude = exclude.GetNext("exclude");
                     exclude = exclude.GetNext("exclude");
                 }
                 }
                 
                 
                 XMLElement include = variation.GetChild("include");
                 XMLElement include = variation.GetChild("include");
                 while (include)
                 while (include)
                 {
                 {
-                    newVar.includes_.Push(include.GetString("name"));
+                    newVar.includes_.Push(include.GetAttribute("name"));
                     include = include.GetNext("include");
                     include = include.GetNext("include");
                 }
                 }
                 
                 
                 XMLElement require = variation.GetChild("require");
                 XMLElement require = variation.GetChild("require");
                 while (require)
                 while (require)
                 {
                 {
-                    newVar.requires_.Push(require.GetString("name"));
+                    newVar.requires_.Push(require.GetAttribute("name"));
                     require = require.GetNext("require");
                     require = require.GetNext("require");
                 }
                 }