فهرست منبع

Moved some of StringUtils functions to the String class.
Moved minidump generation to a separate file that is only linked when used.
Replaced std::string with String.
Removed use of iostream.

Lasse Öörni 14 سال پیش
والد
کامیت
565de1ad02
100فایلهای تغییر یافته به همراه1038 افزوده شده و 1014 حذف شده
  1. 2 1
      Engine/Audio/Precompiled.h
  2. 3 3
      Engine/Audio/Sound.cpp
  3. 1 1
      Engine/Audio/SoundSource.cpp
  4. 35 11
      Engine/Container/String.cpp
  5. 51 45
      Engine/Container/StringBase.h
  6. 3 3
      Engine/Core/Attribute.h
  7. 3 3
      Engine/Core/Context.cpp
  8. 2 2
      Engine/Core/Context.h
  9. 90 0
      Engine/Core/MiniDump.cpp
  10. 29 0
      Engine/Core/MiniDump.h
  11. 7 7
      Engine/Core/Object.h
  12. 2 1
      Engine/Core/Precompiled.h
  13. 31 66
      Engine/Core/ProcessUtils.cpp
  14. 11 9
      Engine/Core/ProcessUtils.h
  15. 6 6
      Engine/Core/Profiler.cpp
  16. 2 2
      Engine/Core/Profiler.h
  17. 4 7
      Engine/Core/StringHash.cpp
  18. 3 3
      Engine/Core/StringHash.h
  19. 76 152
      Engine/Core/StringUtils.cpp
  20. 30 46
      Engine/Core/StringUtils.h
  21. 20 20
      Engine/Core/Variant.cpp
  22. 15 15
      Engine/Core/Variant.h
  23. 32 32
      Engine/Engine/APITemplates.h
  24. 6 6
      Engine/Engine/Console.cpp
  25. 3 3
      Engine/Engine/Console.h
  26. 31 35
      Engine/Engine/CoreAPI.cpp
  27. 3 3
      Engine/Engine/DebugHud.cpp
  28. 14 14
      Engine/Engine/Engine.cpp
  29. 2 2
      Engine/Engine/Engine.h
  30. 6 6
      Engine/Engine/GraphicsAPI.cpp
  31. 16 16
      Engine/Engine/IOAPI.cpp
  32. 6 6
      Engine/Engine/MathAPI.cpp
  33. 2 1
      Engine/Engine/Precompiled.h
  34. 11 11
      Engine/Engine/ResourceAPI.cpp
  35. 13 13
      Engine/Engine/ScriptAPI.cpp
  36. 3 3
      Engine/Engine/UIAPI.cpp
  37. 4 4
      Engine/Graphics/AnimatedModel.cpp
  38. 4 4
      Engine/Graphics/AnimatedModel.h
  39. 2 2
      Engine/Graphics/Animation.cpp
  40. 5 5
      Engine/Graphics/Animation.h
  41. 29 29
      Engine/Graphics/AnimationController.cpp
  42. 28 28
      Engine/Graphics/AnimationController.h
  43. 16 16
      Engine/Graphics/Graphics.cpp
  44. 12 12
      Engine/Graphics/Graphics.h
  45. 1 1
      Engine/Graphics/Light.cpp
  46. 7 7
      Engine/Graphics/Material.cpp
  47. 2 2
      Engine/Graphics/Material.h
  48. 1 1
      Engine/Graphics/Model.cpp
  49. 2 2
      Engine/Graphics/Model.h
  50. 1 1
      Engine/Graphics/ParticleEmitter.cpp
  51. 11 11
      Engine/Graphics/PixelShader.cpp
  52. 2 1
      Engine/Graphics/Precompiled.h
  53. 13 13
      Engine/Graphics/Renderer.cpp
  54. 6 6
      Engine/Graphics/Renderer.h
  55. 1 1
      Engine/Graphics/Skeleton.cpp
  56. 2 2
      Engine/Graphics/Skeleton.h
  57. 1 1
      Engine/Graphics/StaticModel.h
  58. 9 9
      Engine/Graphics/Technique.cpp
  59. 7 7
      Engine/Graphics/Technique.h
  60. 9 9
      Engine/Graphics/Texture.cpp
  61. 4 4
      Engine/Graphics/TextureCube.cpp
  62. 1 1
      Engine/Graphics/VertexBuffer.cpp
  63. 1 1
      Engine/Graphics/VertexBuffer.h
  64. 10 10
      Engine/Graphics/VertexShader.cpp
  65. 2 2
      Engine/Graphics/View.cpp
  66. 9 9
      Engine/IO/Deserializer.cpp
  67. 4 4
      Engine/IO/Deserializer.h
  68. 7 7
      Engine/IO/File.cpp
  69. 7 7
      Engine/IO/File.h
  70. 88 86
      Engine/IO/FileSystem.cpp
  71. 29 29
      Engine/IO/FileSystem.h
  72. 12 12
      Engine/IO/Log.cpp
  73. 7 7
      Engine/IO/Log.h
  74. 8 8
      Engine/IO/PackageFile.cpp
  75. 8 8
      Engine/IO/PackageFile.h
  76. 2 1
      Engine/IO/Precompiled.h
  77. 8 8
      Engine/IO/Serializer.cpp
  78. 3 3
      Engine/IO/Serializer.h
  79. 0 2
      Engine/Math/Quaternion.cpp
  80. 25 25
      Engine/Network/Client.cpp
  81. 12 12
      Engine/Network/Client.h
  82. 1 1
      Engine/Network/Connection.cpp
  83. 1 1
      Engine/Network/Connection.h
  84. 2 2
      Engine/Network/Network.cpp
  85. 1 1
      Engine/Network/Network.h
  86. 2 2
      Engine/Network/Peer.cpp
  87. 2 2
      Engine/Network/Peer.h
  88. 2 1
      Engine/Network/Precompiled.h
  89. 1 1
      Engine/Network/Server.cpp
  90. 1 1
      Engine/Network/Server.h
  91. 7 7
      Engine/Physics/CollisionShape.cpp
  92. 1 1
      Engine/Physics/CollisionShape.h
  93. 1 1
      Engine/Physics/Joint.cpp
  94. 4 4
      Engine/Physics/PhysicsWorld.cpp
  95. 4 4
      Engine/Physics/PhysicsWorld.h
  96. 2 2
      Engine/Physics/Precompiled.h
  97. 1 1
      Engine/Physics/RigidBody.cpp
  98. 5 5
      Engine/Resource/Image.cpp
  99. 2 2
      Engine/Resource/Image.h
  100. 2 1
      Engine/Resource/Precompiled.h

+ 2 - 1
Engine/Audio/Precompiled.h

@@ -23,7 +23,8 @@
 
 #pragma once
 
+#include "StringBase.h"
+
 #include <map>
 #include <set>
-#include <string>
 #include <vector>

+ 3 - 3
Engine/Audio/Sound.cpp

@@ -374,9 +374,9 @@ void Sound::LoadParameters()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     
-    std::string soundPath, soundName, soundExt;
+    String soundPath, soundName, soundExt;
     SplitPath(GetName(), soundPath, soundName, soundExt);
-    std::string xmlName = soundPath + soundName + ".xml";
+    String xmlName = soundPath + soundName + ".xml";
     
     if (!cache->Exists(xmlName))
         return;
@@ -390,7 +390,7 @@ void Sound::LoadParameters()
     
     while (paramElem)
     {
-        std::string name = paramElem.GetName();
+        String name = paramElem.GetName();
         
         if ((name == "format") && (!compressed_))
         {

+ 1 - 1
Engine/Audio/SoundSource.cpp

@@ -88,7 +88,7 @@
 
 #define GET_IP_SAMPLE_RIGHT() (((((int)pos[3] - (int)pos[1]) * fractPos) / 65536) + (int)pos[1])
 
-static const std::string typeNames[] = 
+static const String typeNames[] = 
 {
     "master",
     "effect",

+ 35 - 11
Engine/Container/String.cpp

@@ -26,7 +26,7 @@
 
 char String::endZero = 0;
 
-void String::Replace(char replaceThis, char replaceWith)
+void String::ReplaceInPlace(char replaceThis, char replaceWith)
 {
     for (unsigned i = 0; i < length_; ++i)
     {
@@ -35,7 +35,7 @@ void String::Replace(char replaceThis, char replaceWith)
     }
 }
 
-void String::Replace(const String& replaceThis, const String& replaceWith)
+void String::ReplaceInPlace(const String& replaceThis, const String& replaceWith)
 {
     unsigned nextPos = 0;
     
@@ -44,27 +44,27 @@ void String::Replace(const String& replaceThis, const String& replaceWith)
         unsigned pos = Find(replaceThis, nextPos);
         if (pos == NPOS)
             break;
-        Replace(pos, replaceThis.length_, replaceWith);
+        ReplaceInPlace(pos, replaceThis.length_, replaceWith);
         nextPos = pos + replaceWith.length_;
     }
 }
 
-void String::Replace(unsigned pos, unsigned length, const String& str)
+void String::ReplaceInPlace(unsigned pos, unsigned length, const String& str)
 {
     // If substring is illegal, do nothing
     if (pos + length > length_)
         return;
     
-    Replace(pos, length, str.buffer_, str.length_);
+    ReplaceInPlace(pos, length, str.buffer_, str.length_);
 }
 
-String::Iterator String::Replace(const String::Iterator& start, const String::Iterator& end, const String& replaceWith)
+String::Iterator String::ReplaceInPlace(const String::Iterator& start, const String::Iterator& end, const String& replaceWith)
 {
     unsigned pos = start - Begin();
     if (pos >= length_)
         return End();
     unsigned length = end - start;
-    Replace(pos, length, replaceWith);
+    ReplaceInPlace(pos, length, replaceWith);
     
     return Begin() + pos;
 }
@@ -77,7 +77,7 @@ void String::Insert(unsigned pos, const String& str)
     if (pos == length_)
         (*this) += str;
     else
-        Replace(pos, 0, str);
+        ReplaceInPlace(pos, 0, str);
 }
 
 void String::Insert(unsigned pos, char c)
@@ -112,7 +112,7 @@ String::Iterator String::Insert(const String::Iterator& dest, const String::Iter
     if (pos > length_)
         pos = length_;
     unsigned length = end - start;
-    Replace(pos, 0, start, length);
+    ReplaceInPlace(pos, 0, start, length);
     
     return Begin() + pos;
 }
@@ -129,7 +129,7 @@ String::Iterator String::Insert(const String::Iterator& dest, char c)
 
 void String::Erase(unsigned pos, unsigned length)
 {
-    Replace(pos, length, String());
+    ReplaceInPlace(pos, length, String());
 }
 
 String::Iterator String::Erase(const String::Iterator& it)
@@ -231,6 +231,30 @@ void String::Swap(String& str)
     ::Swap(buffer_, str.buffer_);
 }
 
+String String::Replace(char replaceThis, char replaceWith) const
+{
+    String ret(*this);
+    ret.ReplaceInPlace(replaceThis, replaceWith);
+    
+    return ret;
+}
+
+String String::Replace(const String& replaceThis, const String& replaceWith) const
+{
+    String ret(*this);
+    ret.ReplaceInPlace(replaceThis, replaceWith);
+    
+    return ret;
+}
+
+String String::Replace(unsigned pos, unsigned length, const String& str) const
+{
+    String ret(*this);
+    ret.ReplaceInPlace(pos, length, str);
+    
+    return ret;
+}
+
 String String::Substring(unsigned pos) const
 {
     if (pos >= length_)
@@ -387,7 +411,7 @@ unsigned String::FindLast(const String& str) const
     return NPOS;
 }
 
-void String::Replace(unsigned pos, unsigned length, const char* srcStart, unsigned srcLength)
+void String::ReplaceInPlace(unsigned pos, unsigned length, const char* srcStart, unsigned srcLength)
 {
     int delta = (int)srcLength - (int)length;
     

+ 51 - 45
Engine/Container/StringBase.h

@@ -23,7 +23,7 @@
 
 #pragma once
 
-// Note: file is named StringBase.h to prevent conflicts with C headers
+// Note: this file is named StringBase.h to prevent conflicts with C headers
 
 #include "Iterator.h"
 
@@ -63,6 +63,16 @@ public:
         *this = str;
     }
     
+    /// Construct from a char array and length
+    String(const char* str, unsigned length) :
+        length_(0),
+        capacity_(0),
+        buffer_(&endZero)
+    {
+        Resize(length);
+        CopyChars(buffer_, str, length);
+    }
+    
     /// Destruct
     ~String()
     {
@@ -164,62 +174,52 @@ public:
         return ret;
     }
     
-    /// Test for equality
+    /// Test for equality with another string
     bool operator == (const String& rhs) const
     {
-        if (rhs.length_ != length_)
-            return false;
-        
-        for (unsigned i = 0; i < length_; ++i)
-        {
-            if (buffer_[i] != rhs.buffer_[i])
-                return false;
-        }
-        
-        return true;
+        return strcmp(CString(), rhs.CString()) == 0;
     }
     
     /// Test for inequality with another string
     bool operator != (const String& rhs) const
     {
-        if (rhs.length_ != length_)
-            return true;
-        
-        for (unsigned i = 0; i < length_; ++i)
-        {
-            if (buffer_[i] != rhs.buffer_[i])
-                return true;
-        }
-        
-        return false;
+        return strcmp(CString(), rhs.CString()) != 0;
     }
     
     /// Test if string is less than another string
     bool operator < (const String& rhs) const
     {
-        for (unsigned i = 0; (i < length_) && (i < rhs.length_); ++i)
-        {
-            if (buffer_[i] < rhs.buffer_[i])
-                return true;
-            if (buffer_[i] > rhs.buffer_[i])
-                return false;
-        }
-        
-        return length_ < rhs.length_;
+        return strcmp(CString(), rhs.CString()) < 0;
     }
     
     /// Test if string is greater than another string
     bool operator > (const String& rhs) const
     {
-        for (unsigned i = 0; (i < length_) && (i < rhs.length_); ++i)
-        {
-            if (buffer_[i] > rhs.buffer_[i])
-                return true;
-            if (buffer_[i] < rhs.buffer_[i])
-                return false;
-        }
-        
-        return length_ > rhs.length_;
+        return strcmp(CString(), rhs.CString()) > 0;
+    }
+    
+    /// Test for equality with a C string
+    bool operator == (const char* rhs) const
+    {
+        return strcmp(CString(), rhs) == 0;
+    }
+    
+    /// Test for inequality with a C string
+    bool operator != (const char* rhs) const
+    {
+        return strcmp(CString(), rhs) != 0;
+    }
+    
+    /// Test if string is less than a C string
+    bool operator < (const char* rhs) const
+    {
+        return strcmp(CString(), rhs) < 0;
+    }
+    
+    /// Test if string is greater than a C string
+    bool operator > (const char* rhs) const
+    {
+        return strcmp(CString(), rhs) > 0;
     }
     
     /// Return char at index
@@ -228,13 +228,13 @@ public:
     const char& operator [] (unsigned pos) const { return buffer_[pos]; }
     
     /// Replace all occurrences of a character
-    void Replace(char replaceThis, char replaceWith);
+    void ReplaceInPlace(char replaceThis, char replaceWith);
     /// Replace all occurrences of a string
-    void Replace(const String& replaceThis, const String& replaceWith);
+    void ReplaceInPlace(const String& replaceThis, const String& replaceWith);
     /// Replace a substring
-    void Replace(unsigned pos, unsigned length, const String& replaceWith);
+    void ReplaceInPlace(unsigned pos, unsigned length, const String& replaceWith);
     /// Replace a substring using iterators
-    Iterator Replace(const Iterator& start, const Iterator& end, const String& replaceWith);
+    Iterator ReplaceInPlace(const Iterator& start, const Iterator& end, const String& replaceWith);
     /// Insert a string
     void Insert(unsigned pos, const String& str);
     /// Insert a character
@@ -270,6 +270,12 @@ public:
     Iterator End() { return Iterator(buffer_ + length_); }
     /// Return const iterator to the end
     ConstIterator End() const { return ConstIterator(buffer_ + length_); }
+    /// Return string with all occurrences of a character replaced
+    String Replace(char replaceThis, char replaceWith) const;
+    /// Return string with all occurrences of a string replaced
+    String Replace(const String& replaceThis, const String& replaceWith) const;
+    /// Return string with a substring replaced
+    String Replace(unsigned pos, unsigned length, const String& replaceWith) const;
     /// Return a substring from position to end
     String Substring(unsigned pos) const;
     /// Return a substring with length from position
@@ -343,7 +349,7 @@ private:
     }
     
     /// Replace a substring with another substring
-    void Replace(unsigned pos, unsigned length, const char* srcStart, unsigned srcLength);
+    void ReplaceInPlace(unsigned pos, unsigned length, const char* srcStart, unsigned srcLength);
     
     /// String length
     unsigned length_;

+ 3 - 3
Engine/Core/Attribute.h

@@ -69,7 +69,7 @@ struct AttributeInfo
     }
     
    /// Construct offset enum attribute
-    AttributeInfo(VariantType type, const char* name, unsigned offset, const std::string* enumNames, const Variant& defaultValue, unsigned mode) :
+    AttributeInfo(VariantType type, const char* name, unsigned offset, const String* enumNames, const Variant& defaultValue, unsigned mode) :
         type_(type),
         name_(name),
         offset_(offset),
@@ -94,11 +94,11 @@ struct AttributeInfo
     /// Attribute type
     VariantType type_;
     /// Name
-    std::string name_;
+    String name_;
     /// Byte offset from start of object
     unsigned offset_;
     /// Enum string names
-    const std::string* enumNames_;
+    const String* enumNames_;
     /// Helper object for accessor mode
     SharedPtr<AttributeAccessor> accessor_;
     /// Default value for network replication

+ 3 - 3
Engine/Core/Context.cpp

@@ -27,7 +27,7 @@
 
 #include "DebugNew.h"
 
-static std::string noType;
+static String noType;
 
 Context::Context() :
     handler_(0)
@@ -77,7 +77,7 @@ void Context::RegisterAttribute(ShortStringHash objectType, const AttributeInfo&
     attributes_[objectType].push_back(attr);
 }
 
-void Context::RemoveAttribute(ShortStringHash objectType, const std::string& name)
+void Context::RemoveAttribute(ShortStringHash objectType, const String& name)
 {
     std::vector<AttributeInfo>& attributes = attributes_[objectType];
     for (std::vector<AttributeInfo>::iterator i = attributes.begin(); i != attributes.end(); ++i)
@@ -201,7 +201,7 @@ Object* Context::GetSender() const
         return 0;
 }
 
-const std::string& Context::GetTypeName(ShortStringHash type) const
+const String& Context::GetTypeName(ShortStringHash type) const
 {
     // Search factories to find the hash-to-name mapping
     std::map<ShortStringHash, SharedPtr<ObjectFactory> >::const_iterator i = factories_.find(type);

+ 2 - 2
Engine/Core/Context.h

@@ -48,7 +48,7 @@ public:
     /// Register object attribute
     void RegisterAttribute(ShortStringHash objectType, const AttributeInfo& attr);
     /// Remove object attribute
-    void RemoveAttribute(ShortStringHash objectType, const std::string& name);
+    void RemoveAttribute(ShortStringHash objectType, const String& name);
     /// Copy base class attributes to derived class
     void CopyBaseAttributes(ShortStringHash baseType, ShortStringHash derivedType);
     /// Add event receiver
@@ -139,7 +139,7 @@ public:
     /// Return active event handler. Set by Object. Null outside event handling
     EventHandler* GetHandler() const { return handler_; }
     /// Return object type name from hash, or empty if unknown
-    const std::string& GetTypeName(ShortStringHash type) const;
+    const String& GetTypeName(ShortStringHash type) const;
     /// Template version of returning a subsystem
     template <class T> T* GetSubsystem() const;
     

+ 90 - 0
Engine/Core/MiniDump.cpp

@@ -0,0 +1,90 @@
+//
+// Urho3D Engine
+// Copyright (c) 2008-2011 Lasse Öörni
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#include "Precompiled.h"
+
+#ifdef ENABLE_MINIDUMPS
+
+#include "ProcessUtils.h"
+#include "StringUtils.h"
+
+#include <cstdio>
+#include <list>
+#include <io.h>
+#include <fcntl.h>
+#include <time.h>
+#include <Windows.h>
+#include <DbgHelp.h>
+
+// Enable SHGetSpecialFolderPath on MinGW
+#ifndef _MSC_VER
+#define _WIN32_IE 0x0400
+#endif
+#include <ShlObj.h>
+
+static bool miniDumpWritten = false;
+
+int WriteMiniDump(const char* applicationName, void* exceptionPointers)
+{
+    // In case of recursive or repeating exceptions, only write the dump once
+    if (miniDumpWritten)
+        return EXCEPTION_EXECUTE_HANDLER;
+    
+    miniDumpWritten = true;
+    
+    MINIDUMP_EXCEPTION_INFORMATION info;
+    info.ThreadId = GetCurrentThreadId();
+    info.ExceptionPointers = (EXCEPTION_POINTERS*)exceptionPointers;
+    info.ClientPointers = TRUE;
+    
+    static time_t sysTime;
+    time(&sysTime);
+    const char* dateTime = ctime(&sysTime);
+    String dateTimeStr = String(dateTime);
+    dateTimeStr.ReplaceInPlace("\n", "");
+    dateTimeStr.ReplaceInPlace(":", "");
+    dateTimeStr.ReplaceInPlace("/", "");
+    dateTimeStr.ReplaceInPlace(' ', '_');
+    
+    char pathName[MAX_PATH];
+    pathName[0] = 0;
+    SHGetSpecialFolderPath(0, pathName, CSIDL_PERSONAL, 0);
+    String applicationNameStr(applicationName);
+    String miniDumpDir = String(pathName) + "\\" + applicationNameStr;
+    String miniDumpName = miniDumpDir + "\\" + applicationNameStr + "_" + dateTimeStr + ".dmp";
+    
+    CreateDirectory(miniDumpDir.CString(), 0);
+    HANDLE file = CreateFile(miniDumpName.CString(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ,
+        0, CREATE_ALWAYS, 0, 0);
+    
+    BOOL success = MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), file, MiniDumpWithDataSegs, &info, 0, 0);
+    CloseHandle(file);
+    
+    if (success)
+        ErrorDialog(applicationName, String("An unexpected error occurred. A minidump was generated to " + miniDumpName).CString());
+    else
+        ErrorDialog(applicationName, "An unexpected error occurred. Could not write minidump.");
+    
+    return EXCEPTION_EXECUTE_HANDLER;
+}
+#endif

+ 29 - 0
Engine/Core/MiniDump.h

@@ -0,0 +1,29 @@
+//
+// Urho3D Engine
+// Copyright (c) 2008-2011 Lasse Öörni
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+#pragma once
+
+#ifdef ENABLE_MINIDUMPS
+/// Write a minidump. Needs to be called from within a structured exception handler
+int WriteMiniDump(const char* applicationName, void* exceptionPointers);
+#endif

+ 7 - 7
Engine/Core/Object.h

@@ -41,7 +41,7 @@ public:
     /// Return type
     virtual ShortStringHash GetType() const = 0;
     /// Return type name
-    virtual const std::string& GetTypeName() const = 0;
+    virtual const String& GetTypeName() const = 0;
     /// Handle event
     virtual void OnEvent(Object* sender, bool broadcast, StringHash eventType, VariantMap& eventData);
     
@@ -123,7 +123,7 @@ public:
     /// Return type
     ShortStringHash GetType() const { return type_; }
     /// Return typename
-    const std::string& GetTypeName() const { return typeName_; }
+    const String& GetTypeName() const { return typeName_; }
     
 protected:
     /// Execution context
@@ -131,7 +131,7 @@ protected:
     /// Object type
     ShortStringHash type_;
     /// Object typename
-    std::string typeName_;
+    String typeName_;
 };
 
 /// Template implementation of the object factory
@@ -224,22 +224,22 @@ private:
 #define OBJECT(typeName) \
     private: \
         static const ShortStringHash typeStatic; \
-        static const std::string typeNameStatic; \
+        static const String typeNameStatic; \
     public: \
         virtual ShortStringHash GetType() const { return GetTypeStatic(); } \
-        virtual const std::string& GetTypeName() const { return GetTypeNameStatic(); } \
+        virtual const String& GetTypeName() const { return GetTypeNameStatic(); } \
         static ShortStringHash GetTypeStatic() \
         { \
             return typeStatic; \
         } \
-        static const std::string& GetTypeNameStatic() \
+        static const String& GetTypeNameStatic() \
         { \
             return typeNameStatic; \
         } \
 
 #define OBJECTTYPESTATIC(typeName) \
     const ShortStringHash typeName::typeStatic(#typeName); \
-    const std::string typeName::typeNameStatic(#typeName); \
+    const String typeName::typeNameStatic(#typeName); \
 
 #define EVENT(eventID, eventName) static const StringHash eventID(#eventName); namespace eventName
 #define PARAM(paraid_, paraname_) static const ShortStringHash paraid_(#paraname_)

+ 2 - 1
Engine/Core/Precompiled.h

@@ -23,7 +23,8 @@
 
 #pragma once
 
+#include "StringBase.h"
+
 #include <map>
 #include <set>
-#include <string>
 #include <vector>

+ 31 - 66
Engine/Core/ProcessUtils.cpp

@@ -37,18 +37,13 @@
 #ifndef _MSC_VER
 #define _WIN32_IE 0x0400
 #endif
-#include <shlobj.h>
-
-#ifdef ENABLE_MINIDUMPS
-#include <dbghelp.h>
-#endif
+#include <ShlObj.h>
 
 #include "DebugNew.h"
 
-static bool miniDumpWritten = false;
 static bool consoleOpened = false;
-static std::string currentLine;
-static std::vector<std::string> arguments;
+static String currentLine;
+static std::vector<String> arguments;
 static Mutex staticMutex;
 
 void ErrorDialog(const char* title, const char* message)
@@ -56,6 +51,12 @@ void ErrorDialog(const char* title, const char* message)
     MessageBox(0, message, title, 0);
 }
 
+void ErrorExit(const String& message, int exitCode)
+{
+    PrintLine(message);
+    exit(exitCode);
+}
+
 void OpenConsoleWindow()
 {
     if (consoleOpened)
@@ -78,24 +79,34 @@ void OpenConsoleWindow()
     consoleOpened = true;
 }
 
+void PrintLine(const String& str)
+{
+    PrintLine(str.CString());
+}
+
+void PrintLine(const char* str)
+{
+    printf("%s\n", str);
+}
+
 Mutex& GetStaticMutex()
 {
     return staticMutex;
 }
 
-const std::vector<std::string>& ParseArguments(const char* cmdLine)
+const std::vector<String>& ParseArguments(const char* cmdLine)
 {
     arguments.clear();
     
     if (!cmdLine)
         return arguments;
     
-    std::string cmdStr(cmdLine);
+    String cmdStr(cmdLine);
     unsigned cmdStart, cmdEnd;
     bool inCmd = false;
     bool inQuote = false;
     
-    for (unsigned i = 0; i < cmdStr.length(); ++i)
+    for (unsigned i = 0; i < cmdStr.Length(); ++i)
     {
         if (cmdStr[i] == '\"')
             inQuote = !inQuote;
@@ -105,7 +116,7 @@ const std::vector<std::string>& ParseArguments(const char* cmdLine)
             {
                 inCmd = false;
                 cmdEnd = i;
-                arguments.push_back(cmdStr.substr(cmdStart, cmdEnd - cmdStart));
+                arguments.push_back(cmdStr.Substring(cmdStart, cmdEnd - cmdStart));
             }
         }
         else
@@ -119,21 +130,21 @@ const std::vector<std::string>& ParseArguments(const char* cmdLine)
     }
     if (inCmd)
     {
-        cmdEnd = cmdStr.length();
-        arguments.push_back(cmdStr.substr(cmdStart, cmdEnd - cmdStart));
+        cmdEnd = cmdStr.Length();
+        arguments.push_back(cmdStr.Substring(cmdStart, cmdEnd - cmdStart));
     }
     
     return arguments;
 }
 
-const std::vector<std::string>& GetArguments()
+const std::vector<String>& GetArguments()
 {
     return arguments;
 }
 
-std::string GetConsoleInput()
+String GetConsoleInput()
 {
-    std::string ret;
+    String ret;
     
     HANDLE input = GetStdHandle(STD_INPUT_HANDLE);
     if (input == INVALID_HANDLE_VALUE)
@@ -160,15 +171,15 @@ std::string GetConsoleInput()
                 if (c == '\b')
                 {
                     printf("\b \b");
-                    int length = currentLine.length();
+                    int length = currentLine.Length();
                     if (length)
-                        currentLine.resize(length - 1);
+                        currentLine.Resize(length - 1);
                 }
                 else if (c == '\r')
                 {
                     printf("\n");
                     ret = currentLine;
-                    currentLine.clear();
+                    currentLine.Clear();
                     return ret;
                 }
                 else
@@ -190,49 +201,3 @@ unsigned GetNumCPUCores()
     GetSystemInfo(&info);
     return info.dwNumberOfProcessors;
 }
-
-#ifdef ENABLE_MINIDUMPS
-int WriteMiniDump(const char* applicationName, void* exceptionPointers)
-{
-    // In case of recursive or repeating exceptions, only write the dump once
-    if (miniDumpWritten)
-        return EXCEPTION_EXECUTE_HANDLER;
-    
-    miniDumpWritten = true;
-    
-    MINIDUMP_EXCEPTION_INFORMATION info;
-    info.ThreadId = GetCurrentThreadId();
-    info.ExceptionPointers = (EXCEPTION_POINTERS*)exceptionPointers;
-    info.ClientPointers = TRUE;
-    
-    static time_t sysTime;
-    time(&sysTime);
-    const char* dateTime = ctime(&sysTime);
-    std::string dateTimeStr = std::string(dateTime);
-    ReplaceInPlace(dateTimeStr, "\n", "");
-    ReplaceInPlace(dateTimeStr, ":", "");
-    ReplaceInPlace(dateTimeStr, "/", "");
-    ReplaceInPlace(dateTimeStr, ' ', '_');
-    
-    char pathName[MAX_PATH];
-    pathName[0] = 0;
-    SHGetSpecialFolderPath(0, pathName, CSIDL_PERSONAL, 0);
-    std::string applicationNameStr(applicationName);
-    std::string miniDumpDir = std::string(pathName) + "\\" + applicationNameStr;
-    std::string miniDumpName = miniDumpDir + "\\" + applicationNameStr + "_" + dateTimeStr + ".dmp";
-    
-    CreateDirectory(miniDumpDir.c_str(), 0);
-    HANDLE file = CreateFile(miniDumpName.c_str(), GENERIC_READ | GENERIC_WRITE, FILE_SHARE_WRITE | FILE_SHARE_READ,
-        0, CREATE_ALWAYS, 0, 0);
-    
-    BOOL success = MiniDumpWriteDump(GetCurrentProcess(), GetCurrentProcessId(), file, MiniDumpWithDataSegs, &info, 0, 0);
-    CloseHandle(file);
-    
-    if (success)
-        ErrorDialog(applicationName, std::string("An unexpected error occurred. A minidump was generated to " + miniDumpName).c_str());
-    else
-        ErrorDialog(applicationName, "An unexpected error occurred. Could not write minidump.");
-    
-    return EXCEPTION_EXECUTE_HANDLER;
-}
-#endif

+ 11 - 9
Engine/Core/ProcessUtils.h

@@ -23,27 +23,29 @@
 
 #pragma once
 
-#include <string>
+#include "StringBase.h"
+
 #include <vector>
 
 class Mutex;
 
 /// Display an error dialog with the specified title and message
 void ErrorDialog(const char* title, const char* message);
+/// Exit the application with an error message to the console
+void ErrorExit(const String& message, int exitCode = 1);
 /// Open a console window
 void OpenConsoleWindow();
+/// Print to the console. A newline will be added automatically
+void PrintLine(const String& str);
+/// Print to the console. A newline will be added automatically
+void PrintLine(const char* str);
 /// Return the static library init/shutdown mutex
 Mutex& GetStaticMutex();
 /// Parse arguments from the command line
-const std::vector<std::string>& ParseArguments(const char* cmdLine);
+const std::vector<String>& ParseArguments(const char* cmdLine);
 /// Return previously parsed arguments
-const std::vector<std::string>& GetArguments();
+const std::vector<String>& GetArguments();
 /// Read input from the console window. Return empty if no input
-std::string GetConsoleInput();
+String GetConsoleInput();
 /// Return the number of (logical) CPU cores
 unsigned GetNumCPUCores();
-
-#ifdef ENABLE_MINIDUMPS
-/// Write a minidump. Needs to be called from within a structured exception handler
-int WriteMiniDump(const char* applicationName, void* exceptionPointers);
-#endif

+ 6 - 6
Engine/Core/Profiler.cpp

@@ -83,21 +83,21 @@ void Profiler::ClearAccumulated()
     accumulatedFrames_ = 0;
 }
 
-std::string Profiler::GetData(bool showUnused, bool showAccumulated, bool showTotal) const
+String Profiler::GetData(bool showUnused, bool showAccumulated, bool showTotal) const
 {
-    std::string output;
+    String output;
     
     if (!showTotal)
-        output += std::string("Block                          Count   Average   Total\n \n");
+        output += String("Block                          Count   Average   Total\n \n");
     else
-        output += std::string("Block                             Frame average (msec)      Accumulated total (sec)\n \n");
+        output += String("Block                             Frame average (msec)      Accumulated total (sec)\n \n");
     
     GetData(root_, output, 0, showUnused, showAccumulated, showTotal);
     
     return output;
 }
 
-void Profiler::GetData(ProfilerBlock* block, std::string& output, unsigned indent, bool showUnused, bool showAccumulated, bool showTotal) const
+void Profiler::GetData(ProfilerBlock* block, String& output, unsigned indent, bool showUnused, bool showAccumulated, bool showTotal) const
 {
     char line[LINE_MAX_LENGTH];
     char indentedName[LINE_MAX_LENGTH];
@@ -159,7 +159,7 @@ void Profiler::GetData(ProfilerBlock* block, std::string& output, unsigned inden
                     indentedName, avgFrameCount, avgFrameTime, avgFrameTotalTime,
                     totalCount, avgTotalTime / 1000.0f, totalTime / 1000.0);
             }
-            output += std::string(line);
+            output += String(line);
             
             indent++;
         }

+ 2 - 2
Engine/Core/Profiler.h

@@ -208,13 +208,13 @@ public:
     void ClearAccumulated();
     
     /// Return profiling data as text output
-    std::string GetData(bool showUnused = false, bool showAccumulated = false, bool showTotal = false) const;
+    String GetData(bool showUnused = false, bool showAccumulated = false, bool showTotal = false) const;
     /// Return the current profiling block
     const ProfilerBlock* GetCurrentBlock() { return current_; }
     
 private:
     /// Return profiling data as text output for a specified profiling block
-    void GetData(ProfilerBlock* block, std::string& output, unsigned indent, bool showUnused, bool showAccumulated, bool showTotal) const;
+    void GetData(ProfilerBlock* block, String& output, unsigned indent, bool showUnused, bool showAccumulated, bool showTotal) const;
     /// Handle begin frame event
     void HandleBeginFrame(StringHash eventType, VariantMap& eventData);
     

+ 4 - 7
Engine/Core/StringHash.cpp

@@ -24,9 +24,6 @@
 #include "Precompiled.h"
 #include "StringUtils.h"
 
-#include <cstring>
-#include <map>
-
 #include "DebugNew.h"
 
 const StringHash StringHash::ZERO;
@@ -37,8 +34,8 @@ StringHash::StringHash(const char* str) :
 {
 }
 
-StringHash::StringHash(const std::string& str) :
-    value_(Calculate(str.c_str()))
+StringHash::StringHash(const String& str) :
+    value_(Calculate(str.CString()))
 {
 }
 
@@ -65,8 +62,8 @@ ShortStringHash::ShortStringHash(const char* str) :
 {
 }
 
-ShortStringHash::ShortStringHash(const std::string& str) :
-    value_(Calculate(str.c_str()))
+ShortStringHash::ShortStringHash(const String& str) :
+    value_(Calculate(str.CString()))
 {
 }
 

+ 3 - 3
Engine/Core/StringHash.h

@@ -23,7 +23,7 @@
 
 #pragma once
 
-#include <string>
+#include "StringBase.h"
 
 /// 32-bit hash value for a string
 class StringHash
@@ -50,7 +50,7 @@ public:
     /// Construct from a C string case-insensitively
     explicit StringHash(const char* str);
     /// Construct from a string case-insensitively
-    explicit StringHash(const std::string& str);
+    explicit StringHash(const String& str);
     
     /// Assign from another hash
     StringHash& operator = (const StringHash& rhs)
@@ -131,7 +131,7 @@ public:
     /// Construct from a C string case-insensitively
     explicit ShortStringHash(const char* str);
     /// Construct from a string case-insensitively
-    explicit ShortStringHash(const std::string& str);
+    explicit ShortStringHash(const String& str);
     
     /// Assign from another hash
     ShortStringHash& operator = (const ShortStringHash& rhs)

+ 76 - 152
Engine/Core/StringUtils.cpp

@@ -31,16 +31,16 @@
 
 static const int TEMP_BUFFER_LENGTH = 128;
 
-std::vector<std::string> Split(const std::string& source, char separator)
+std::vector<String> Split(const String& source, char separator)
 {
-    std::vector<std::string> ret;
+    std::vector<String> ret;
     unsigned pos = 0;
     
-    while (pos < source.length())
+    while (pos < source.Length())
     {
         unsigned start = pos;
         
-        while (start < source.length())
+        while (start < source.Length())
         {
             if (source[start] == separator)
                 break;
@@ -48,15 +48,15 @@ std::vector<std::string> Split(const std::string& source, char separator)
             start++;
         }
         
-        if (start == source.length())
+        if (start == source.Length())
         {
-            ret.push_back(source.substr(pos));
+            ret.push_back(source.Substring(pos));
             break;
         }
         
         unsigned end = start;
         
-        while (end < source.length())
+        while (end < source.Length())
         {
             if (source[end] != separator)
                 break;
@@ -64,127 +64,46 @@ std::vector<std::string> Split(const std::string& source, char separator)
             end++;
         }
         
-        ret.push_back(source.substr(pos, start - pos));
+        ret.push_back(source.Substring(pos, start - pos));
         pos = end;
     }
     
     return ret;
 }
 
-std::string Replace(const std::string& source, char replaceThis, char replaceWith)
+bool ToBool(const String& source)
 {
-    std::string ret;
-    ret.resize(source.length());
-    
-    for (unsigned i = 0; i < ret.length(); ++i)
-    {
-        if (source[i] == replaceThis)
-            ret[i] = replaceWith;
-        else
-            ret[i] = source[i];
-    }
-    
-    return ret;
-}
-
-std::string Replace(const std::string& source, const std::string& replaceThis, const std::string& replaceWith)
-{
-    std::string ret = source;
-    ReplaceInPlace(ret, replaceThis, replaceWith);
-    return ret;
-}
-
-std::string ToLower(const std::string& source)
-{
-    std::string ret;
-    ret.resize(source.length());
-    
-    for (unsigned i = 0; i < ret.length(); ++i)
-        ret[i] = tolower(source[i]);
-    
-    return ret;
-}
-
-std::string ToUpper(const std::string& source)
-{
-    std::string ret;
-    ret.resize(source.length());
-    
-    for (unsigned i = 0; i < ret.length(); ++i)
-        ret[i] = toupper(source[i]);
-    
-    return ret;
-}
-
-void ReplaceInPlace(std::string& str, char replaceThis, char replaceWith)
-{
-    for (unsigned i = 0; i < str.length(); ++i)
-    {
-        if (str[i] == replaceThis)
-            str[i] = replaceWith;
-    }
-}
-
-void ReplaceInPlace(std::string& str, const std::string& replaceThis, const std::string& replaceWith)
-{
-    size_t nextIndex = 0;
-    
-    while (nextIndex < str.length())
-    {
-        size_t index = str.find(replaceThis, nextIndex);
-        if (index == std::string::npos)
-            break;
-        
-        str.replace(index, replaceThis.length(), replaceWith);
-        nextIndex = index + replaceWith.length();
-    }
-}
-
-void ToLowerInPlace(std::string& str)
-{
-    for (unsigned i = 0; i < str.length(); ++i)
-        str[i] = tolower(str[i]);
-}
-
-void ToUpperInPlace(std::string& str)
-{
-    for (unsigned i = 0; i < str.length(); ++i)
-        str[i] = toupper(str[i]);
-}
-
-bool ToBool(const std::string& source)
-{
-    std::string temp = ToLower(source);
-    if (temp.find("true") != std::string::npos)
+    String temp = source.ToLower();
+    if (temp.Find("true") != String::NPOS)
         return true;
     else
         return false;
 }
 
-int ToInt(const std::string& source)
+int ToInt(const String& source)
 {
-    if (!source.length())
+    if (!source.Length())
         return 0;
-    return atoi(source.c_str());
+    return atoi(source.CString());
 }
 
-unsigned ToUInt(const std::string& source)
+unsigned ToUInt(const String& source)
 {
-    if (!source.length())
+    if (!source.Length())
         return 0;
-    return (unsigned)atoi(source.c_str());
+    return (unsigned)atoi(source.CString());
 }
 
-float ToFloat(const std::string& source)
+float ToFloat(const String& source)
 {
-    if (!source.length())
+    if (!source.Length())
         return 0.0f;
-    return (float)atof(source.c_str());
+    return (float)atof(source.CString());
 }
 
-Color ToColor(const std::string& source)
+Color ToColor(const String& source)
 {
-    std::vector<std::string> colors = Split(source, ' ');
+    std::vector<String> colors = Split(source, ' ');
     if (colors.size() < 3)
         return Color();
     
@@ -195,36 +114,36 @@ Color ToColor(const std::string& source)
     return ret;
 }
 
-IntRect ToIntRect(const std::string& source)
+IntRect ToIntRect(const String& source)
 {
-    std::vector<std::string> coords = Split(source, ' ');
+    std::vector<String> coords = Split(source, ' ');
     if (coords.size() < 4)
         return IntRect::ZERO;
     else
         return IntRect(ToInt(coords[0]), ToInt(coords[1]), ToInt(coords[2]), ToInt(coords[3]));
 }
 
-IntVector2 ToIntVector2(const std::string& source)
+IntVector2 ToIntVector2(const String& source)
 {
-    std::vector<std::string> coords = Split(source, ' ');
+    std::vector<String> coords = Split(source, ' ');
     if (coords.size() < 2)
         return IntVector2::ZERO;
     else
         return IntVector2(ToInt(coords[0]), ToInt(coords[1]));
 }
 
-Rect ToRect(const std::string& source)
+Rect ToRect(const String& source)
 {
-    std::vector<std::string> coords = Split(source, ' ');
+    std::vector<String> coords = Split(source, ' ');
     if (coords.size() < 4)
         return Rect::ZERO;
     else
         return Rect(ToFloat(coords[0]), ToFloat(coords[1]), ToFloat(coords[2]), ToFloat(coords[3]));
 }
 
-Quaternion ToQuaternion(const std::string& source)
+Quaternion ToQuaternion(const String& source)
 {
-    std::vector<std::string> coords = Split(source, ' ');
+    std::vector<String> coords = Split(source, ' ');
     if (coords.size() < 3)
         return Quaternion::IDENTITY;
     else if (coords.size() < 4)
@@ -235,27 +154,27 @@ Quaternion ToQuaternion(const std::string& source)
         return Quaternion(ToFloat(coords[0]), ToFloat(coords[1]), ToFloat(coords[2]), ToFloat(coords[3])).GetNormalized();
 }
 
-Vector2 ToVector2(const std::string& source)
+Vector2 ToVector2(const String& source)
 {
-    std::vector<std::string> coords = Split(source, ' ');
+    std::vector<String> coords = Split(source, ' ');
     if (coords.size() < 2)
         return Vector2::ZERO;
     else
         return Vector2(ToFloat(coords[0]), ToFloat(coords[1]));
 }
 
-Vector3 ToVector3(const std::string& source)
+Vector3 ToVector3(const String& source)
 {
-    std::vector<std::string> coords = Split(source, ' ');
+    std::vector<String> coords = Split(source, ' ');
     if (coords.size() < 3)
         return Vector3::ZERO;
     else
         return Vector3(ToFloat(coords[0]), ToFloat(coords[1]), ToFloat(coords[2]));
 }
 
-Vector4 ToVector4(const std::string& source, bool allowMissingCoords)
+Vector4 ToVector4(const String& source, bool allowMissingCoords)
 {
-    std::vector<std::string> coords = Split(source, ' ');
+    std::vector<String> coords = Split(source, ' ');
     if (!allowMissingCoords)
     {
         if (coords.size() < 4)
@@ -279,7 +198,7 @@ Vector4 ToVector4(const std::string& source, bool allowMissingCoords)
     }
 }
 
-std::string ToString(bool value)
+String ToString(bool value)
 {
     if (value)
         return "true";
@@ -287,122 +206,127 @@ std::string ToString(bool value)
         return "false";
 }
 
-std::string ToString(float value)
+String ToString(float value)
 {
     char tempBuffer[TEMP_BUFFER_LENGTH];
     sprintf(tempBuffer, "%g", value);
-    return std::string(tempBuffer);
+    return String(tempBuffer);
 }
 
-std::string ToString(int value)
+String ToString(int value)
 {
     char tempBuffer[TEMP_BUFFER_LENGTH];
     sprintf(tempBuffer, "%d", value);
-    return std::string(tempBuffer);
+    return String(tempBuffer);
 }
 
-std::string ToString(unsigned value)
+String ToString(unsigned value)
 {
     char tempBuffer[TEMP_BUFFER_LENGTH];
     sprintf(tempBuffer, "%u", value);
-    return std::string(tempBuffer);
+    return String(tempBuffer);
 }
 
-std::string ToString(const Color& value)
+String ToString(const Color& value)
 {
     char tempBuffer[TEMP_BUFFER_LENGTH];
     sprintf(tempBuffer, "%g %g %g %g", value.r_, value.g_, value.b_, value.a_);
-    return std::string(tempBuffer);
+    return String(tempBuffer);
 }
 
-std::string ToString(const IntRect& value)
+String ToString(const IntRect& value)
 {
     char tempBuffer[TEMP_BUFFER_LENGTH];
     sprintf(tempBuffer, "%d %d %d &d", value.left_, value.top_, value.right_, value.bottom_);
-    return std::string(tempBuffer);
+    return String(tempBuffer);
 }
 
-std::string ToString(const IntVector2& value)
+String ToString(const IntVector2& value)
 {
     char tempBuffer[TEMP_BUFFER_LENGTH];
     sprintf(tempBuffer, "%d %d", value.x_, value.y_);
-    return std::string(tempBuffer);
+    return String(tempBuffer);
 }
 
-std::string ToString(const Rect& value)
+String ToString(const Rect& value)
 {
     char tempBuffer[TEMP_BUFFER_LENGTH];
     sprintf(tempBuffer, "%g %g %g %g", value.min_.x_, value.min_.y_, value.max_.x_, value.max_.y_);
-    return std::string(tempBuffer);
+    return String(tempBuffer);
 }
 
-std::string ToString(const Quaternion& value)
+String ToString(const Quaternion& value)
 {
     char tempBuffer[TEMP_BUFFER_LENGTH];
     sprintf(tempBuffer, "%g %g %g %g", value.w_, value.x_, value.y_, value.z_);
-    return std::string(tempBuffer);
+    return String(tempBuffer);
 }
 
-std::string ToString(const StringHash& value)
+String ToString(const StringHash& value)
 {
     char tempBuffer[TEMP_BUFFER_LENGTH];
     sprintf(tempBuffer, "%08X", value.GetValue());
-    return std::string(tempBuffer);
+    return String(tempBuffer);
 }
 
-std::string ToString(const ShortStringHash& value)
+String ToString(const ShortStringHash& value)
 {
     char tempBuffer[TEMP_BUFFER_LENGTH];
     sprintf(tempBuffer, "%04X", value.GetValue());
-    return std::string(tempBuffer);
+    return String(tempBuffer);
 }
 
-std::string ToString(const Vector2& value)
+String ToString(const Vector2& value)
 {
     char tempBuffer[TEMP_BUFFER_LENGTH];
     sprintf(tempBuffer, "%g %g", value.x_, value.y_);
-    return std::string(tempBuffer);
+    return String(tempBuffer);
 }
 
-std::string ToString(const Vector3& value)
+String ToString(const Vector3& value)
 {
     char tempBuffer[TEMP_BUFFER_LENGTH];
     sprintf(tempBuffer, "%g %g %g", value.x_, value.y_, value.z_);
-    return std::string(tempBuffer);
+    return String(tempBuffer);
 }
 
-std::string ToString(const Vector4& value)
+String ToString(const Vector4& value)
 {
     char tempBuffer[TEMP_BUFFER_LENGTH];
     sprintf(tempBuffer, "%g %g %g %g", value.x_, value.y_, value.z_, value.w_);
-    return std::string(tempBuffer);
+    return String(tempBuffer);
 }
 
-std::string ToString(void* value)
+String ToString(void* value)
 {
     return ToStringHex((int)value);
 }
 
-std::string ToStringHex(unsigned value)
+String ToStringHex(unsigned value)
 {
     char tempBuffer[TEMP_BUFFER_LENGTH];
     sprintf(tempBuffer, "%08x", value);
-    return std::string(tempBuffer);
+    return String(tempBuffer);
 }
 
-unsigned GetStringListIndex(const std::string& value, const std::string* strings, unsigned count, unsigned defaultIndex,
+unsigned GetStringListIndex(const String& value, const String* strings, unsigned count, unsigned defaultIndex,
     bool caseSensitive)
 {
-    for (unsigned i = 0; i < count; ++i)
+    if (caseSensitive)
     {
-        if (caseSensitive)
+        for (unsigned i = 0; i < count; ++i)
         {
             if (value == strings[i])
                 return i;
         }
-        else
+    }
+    else
+    {
+        String valueLower = value.ToLower();
+        for (unsigned i = 0; i < count; ++i)
         {
-            if (ToLower(value) == ToLower(strings[i]))
+            /// \todo Write an insensitive compare function instead of creating new strings
+            if (valueLower == strings[i].ToLower())
                 return i;
         }
     }

+ 30 - 46
Engine/Core/StringUtils.h

@@ -32,80 +32,64 @@
 #include <vector>
 
 /// Split string with a separator char
-std::vector<std::string> Split(const std::string& source, char separator);
-/// Replace characters in a string
-std::string Replace(const std::string& source, char replaceThis, char replaceWith);
-/// Replace substrings in a string
-std::string Replace(const std::string& source, const std::string& replaceThis, const std::string& replaceWith);
-/// Convert a string to uppercase
-std::string ToUpper(const std::string& source);
-/// Convert a string to lowercase
-std::string ToLower(const std::string& source);
-/// Replace characters in a string by modifying the original string
-void ReplaceInPlace(std::string& str, char replaceThis, char replaceWith);
-/// Replace substrings in a string by modifying the original string
-void ReplaceInPlace(std::string& str, const std::string& replaceThis, const std::string& replaceWith);
-/// Convert a string to uppercase by modifying the original string
-void ToUpperInPlace(std::string& str);
-/// Convert a string to lowercase by modifying the original string
-void ToLowerInPlace(std::string& str);
+std::vector<String> Split(const String& source, char separator);
 /// Parse a bool from a string. Check for the substring "true" case-insensitively
-bool ToBool(const std::string& source);
+bool ToBool(const String& source);
 /// Parse a float from a string
-float ToFloat(const std::string& source);
+float ToFloat(const String& source);
 /// Parse an integer from a string
-int ToInt(const std::string& source);
+int ToInt(const String& source);
 /// Parse an unsigned integer from a string
-unsigned ToUInt(const std::string& source);
+unsigned ToUInt(const String& source);
 /// Parse a Color from a string
-Color ToColor(const std::string& source);
+Color ToColor(const String& source);
 /// Parse an IntRect from a string
-IntRect ToIntRect(const std::string& source);
+IntRect ToIntRect(const String& source);
 /// Parse an IntVector2 from a string
-IntVector2 ToIntVector2(const std::string& source);
+IntVector2 ToIntVector2(const String& source);
 /// Parse a Quaternion from a string. If only 3 components specified, convert Euler angles (degrees) to quaternion
-Quaternion ToQuaternion(const std::string& source);
+Quaternion ToQuaternion(const String& source);
 /// Parse a Rect from a string
-Rect ToRect(const std::string& source);
+Rect ToRect(const String& source);
 /// Parse a Vector2 from a string
-Vector2 ToVector2(const std::string& source);
+Vector2 ToVector2(const String& source);
 /// Parse a Vector3 from a string
-Vector3 ToVector3(const std::string& source);
+Vector3 ToVector3(const String& source);
 /// Parse a Vector4 from a string
-Vector4 ToVector4(const std::string& source, bool allowMissingCoords = false);
+Vector4 ToVector4(const String& source, bool allowMissingCoords = false);
 /// Convert a bool to string
-std::string ToString(bool value);
+String ToString(bool value);
 /// Convert a float to string
-std::string ToString(float value);
+String ToString(float value);
 /// Convert an integer to string
-std::string ToString(int value);
+String ToString(int value);
 /// Convert an unsigned integer to string
-std::string ToString(unsigned value);
+String ToString(unsigned value);
 /// Convert a Color to string
-std::string ToString(const Color& value);
+String ToString(const Color& value);
 /// Convert an IntRect to string
-std::string ToString(const IntRect& value);
+String ToString(const IntRect& value);
 /// Convert an IntVector2 to string
-std::string ToString(const IntVector2& value);
+String ToString(const IntVector2& value);
 /// Convert a Quaternion to string
-std::string ToString(const Quaternion& value);
+String ToString(const Quaternion& value);
 /// Convert a Rect to string
-std::string ToString(const Rect& value);
+String ToString(const Rect& value);
 /// Convert a StringHash to string. Return the reverse mapping if found
-std::string ToString(const StringHash& value);
+String ToString(const StringHash& value);
 /// Convert a ShortStringHash to string. Return the reverse mapping if found
-std::string ToString(const ShortStringHash& value);
+String ToString(const ShortStringHash& value);
 /// Convert a Vector2 to string
-std::string ToString(const Vector2& value);
+String ToString(const Vector2& value);
 /// Convert a Vector3 to string
-std::string ToString(const Vector3& value);
+String ToString(const Vector3& value);
 /// Convert a Vector4 to string
-std::string ToString(const Vector4& value);
+String ToString(const Vector4& value);
 /// Convert a pointer to string (returns hexadecimal)
-std::string ToString(void* value);
+String ToString(void* value);
 /// Convert an unsigned integer to string as hexadecimal
-std::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
-unsigned GetStringListIndex(const std::string& value, const std::string* strings, unsigned count, unsigned defaultIndex,
+unsigned GetStringListIndex(const String& value, const String* strings, unsigned count, unsigned defaultIndex,
     bool caseSensitive = false);

+ 20 - 20
Engine/Core/Variant.cpp

@@ -30,14 +30,14 @@
 #include "DebugNew.h"
 
 const Variant Variant::EMPTY;
-const std::string Variant::emptyString;
+const String Variant::emptyString;
 const std::vector<unsigned char> Variant::emptyBuffer;
 const ResourceRef Variant::emptyResourceRef;
 const ResourceRefList Variant::emptyResourceRefList;
 const VariantMap Variant::emptyVariantMap;
 const VariantVector Variant::emptyVariantVector;
 
-static const std::string typeNames[] =
+static const String typeNames[] =
 {
     "None",
     "Int",
@@ -64,7 +64,7 @@ Variant& Variant::operator = (const Variant& rhs)
     switch (type_)
     {
     case VAR_STRING:
-        *(reinterpret_cast<std::string*>(value_.ptr_)) = *(reinterpret_cast<const std::string*>(rhs.value_.ptr_));
+        *(reinterpret_cast<String*>(value_.ptr_)) = *(reinterpret_cast<const String*>(rhs.value_.ptr_));
         break;
         
     case VAR_BUFFER:
@@ -127,7 +127,7 @@ bool Variant::operator == (const Variant& rhs) const
         return *(reinterpret_cast<const Color*>(&value_)) == *(reinterpret_cast<const Color*>(&rhs.value_));
         
     case VAR_STRING:
-        return *(reinterpret_cast<const std::string*>(value_.ptr_)) == *(reinterpret_cast<const std::string*>(rhs.value_.ptr_));
+        return *(reinterpret_cast<const String*>(value_.ptr_)) == *(reinterpret_cast<const String*>(rhs.value_.ptr_));
         
     case VAR_BUFFER:
         return *(reinterpret_cast<const std::vector<unsigned char>*>(value_.ptr_)) == *(reinterpret_cast<const std::vector<unsigned char>*>(rhs.value_.ptr_));
@@ -151,9 +151,9 @@ bool Variant::operator == (const Variant& rhs) const
     return true;
 }
 
-void Variant::FromString(const std::string& type, const std::string& value)
+void Variant::FromString(const String& type, const String& value)
 {
-    std::string typeLower = ToLower(type);
+    String typeLower = type.ToLower();
     
     if (typeLower == "none")
         SetType(VAR_NONE);
@@ -179,7 +179,7 @@ void Variant::FromString(const std::string& type, const std::string& value)
     {
         SetType(VAR_BUFFER);
         std::vector<unsigned char>& buffer = *(reinterpret_cast<std::vector<unsigned char>*>(value_.ptr_));
-        std::vector<std::string> values = Split(value, ' ');
+        std::vector<String> values = Split(value, ' ');
         buffer.resize(values.size());
         for (unsigned i = 0; i < values.size(); ++i)
             buffer[i] = ToInt(values[i]);
@@ -190,7 +190,7 @@ void Variant::FromString(const std::string& type, const std::string& value)
     }
     else if (typeLower == "objectref")
     {
-        std::vector<std::string> values = Split(value, ';');
+        std::vector<String> values = Split(value, ';');
         if (values.size() == 2)
         {
             SetType(VAR_RESOURCEREF);
@@ -201,7 +201,7 @@ void Variant::FromString(const std::string& type, const std::string& value)
     }
     else if (typeLower == "objectreflist")
     {
-        std::vector<std::string> values = Split(value, ';');
+        std::vector<String> values = Split(value, ';');
         if (values.size() >= 1)
         {
             SetType(VAR_RESOURCEREFLIST);
@@ -228,12 +228,12 @@ void Variant::SetBuffer(const void* data, unsigned size)
         memcpy(&buffer[0], data, size);
 }
 
-const std::string& Variant::GetTypeName() const
+const String& Variant::GetTypeName() const
 {
     return typeNames[type_];
 }
 
-std::string Variant::ToString() const
+String Variant::ToString() const
 {
     switch (type_)
     {
@@ -262,12 +262,12 @@ std::string Variant::ToString() const
         return ::ToString(*(reinterpret_cast<const Color*>(&value_)));
         
     case VAR_STRING:
-        return *(reinterpret_cast<const std::string*>(value_.ptr_));
+        return *(reinterpret_cast<const String*>(value_.ptr_));
         
     case VAR_BUFFER:
         {
             const std::vector<unsigned char>& buffer = *(reinterpret_cast<const std::vector<unsigned char>*>(value_.ptr_));
-            std::string ret;
+            String ret;
             for (std::vector<unsigned char>::const_iterator i = buffer.begin(); i != buffer.end(); ++i)
             {
                 if (i != buffer.begin())
@@ -287,10 +287,10 @@ std::string Variant::ToString() const
     case VAR_VARIANTMAP:
         // Reference string serialization requires hash-to-name mapping from the context & subsystems. Can not support here
         // Also variant map or vector string serialization is not supported. XML or binary save should be used instead
-        return std::string();
+        return String();
     }
     
-    return std::string();
+    return String();
 }
 
 void Variant::SetType(VariantType newType)
@@ -301,7 +301,7 @@ void Variant::SetType(VariantType newType)
     switch (type_)
     {
     case VAR_STRING:
-        delete reinterpret_cast<std::string*>(value_.ptr_);
+        delete reinterpret_cast<String*>(value_.ptr_);
         break;
         
     case VAR_BUFFER:
@@ -330,7 +330,7 @@ void Variant::SetType(VariantType newType)
     switch (type_)
     {
     case VAR_STRING:
-        *reinterpret_cast<std::string**>(&value_.ptr_) = new std::string();
+        *reinterpret_cast<String**>(&value_.ptr_) = new String();
         break;
         
     case VAR_BUFFER:
@@ -410,7 +410,7 @@ template<> const Color& Variant::Get<const Color&>() const
     return GetColor();
 }
 
-template<> const std::string& Variant::Get<const std::string&>() const
+template<> const String& Variant::Get<const String&>() const
 {
     return GetString();
 }
@@ -470,7 +470,7 @@ template<> Color Variant::Get<Color>() const
     return GetColor();
 }
 
-template<> std::string Variant::Get<std::string>() const
+template<> String Variant::Get<String>() const
 {
     return GetString();
 }
@@ -480,7 +480,7 @@ template<> std::vector<unsigned char> Variant::Get<std::vector<unsigned char> >(
     return GetBuffer();
 }
 
-const std::string& Variant::GetTypeName(VariantType type)
+const String& Variant::GetTypeName(VariantType type)
 {
     return typeNames[type];
 }

+ 15 - 15
Engine/Core/Variant.h

@@ -247,7 +247,7 @@ public:
     }
     
     /// Construct from a string
-    Variant(const std::string& value) :
+    Variant(const String& value) :
         type_(VAR_NONE)
     {
         *this = value;
@@ -303,7 +303,7 @@ public:
     }
     
     /// Construct from type and value
-    Variant(const std::string& type, const std::string& value) :
+    Variant(const String& type, const String& value) :
         type_(VAR_NONE)
     {
         FromString(type, value);
@@ -420,10 +420,10 @@ public:
     }
     
     /// Assign from a string
-    Variant& operator = (const std::string& rhs)
+    Variant& operator = (const String& rhs)
     {
         SetType(VAR_STRING);
-        *(reinterpret_cast<std::string*>(value_.ptr_)) = rhs;
+        *(reinterpret_cast<String*>(value_.ptr_)) = rhs;
         return *this;
     }
     
@@ -431,7 +431,7 @@ public:
     Variant& operator = (const char* rhs)
     {
         SetType(VAR_STRING);
-        *(reinterpret_cast<std::string*>(value_.ptr_)) = std::string(rhs);
+        *(reinterpret_cast<String*>(value_.ptr_)) = String(rhs);
         return *this;
     }
 
@@ -574,10 +574,10 @@ public:
     }
     
     /// Test for equality with a string. To return true, both the type and value must match
-    bool operator == (const std::string& rhs) const
+    bool operator == (const String& rhs) const
     {
         if (type_ == VAR_STRING)
-            return *(reinterpret_cast<const std::string*>(value_.ptr_)) == rhs;
+            return *(reinterpret_cast<const String*>(value_.ptr_)) == rhs;
         else
             return false;
     }
@@ -671,7 +671,7 @@ public:
     /// Test for inequality with a Quaternion
     bool operator != (const Quaternion& rhs) const { return !(*this == rhs); }
     /// Test for inequality with a string
-    bool operator != (const std::string& rhs) const { return !(*this == rhs); }
+    bool operator != (const String& rhs) const { return !(*this == rhs); }
     /// Test for inequality with a buffer
     bool operator != (const std::vector<unsigned char>& rhs) const { return !(*this == rhs); }
     /// Test for inequality with a pointer
@@ -690,7 +690,7 @@ public:
     bool operator != (const ShortStringHash& rhs) const { return !(*this == rhs); }
     
     /// Set from type and value strings. Pointers will be set to null, and VariantBuffer or VariantMap types are not supported
-    void FromString(const std::string& type, const std::string& value);
+    void FromString(const String& type, const String& value);
     /// Set buffer type from a memory area
     void SetBuffer(const void* data, unsigned size);
     
@@ -783,11 +783,11 @@ public:
     }
     
     /// Return string or empty on type mismatch
-    const std::string& GetString() const
+    const String& GetString() const
     {
         if (type_ != VAR_STRING)
             return emptyString;
-        return *reinterpret_cast<const std::string*>(value_.ptr_);
+        return *reinterpret_cast<const String*>(value_.ptr_);
     }
     
     /// Return buffer or empty on type mismatch
@@ -843,12 +843,12 @@ public:
     /// Return type
     VariantType GetType() const { return type_; }
     /// Return type name
-    const std::string& GetTypeName() const;
+    const String& GetTypeName() const;
     /// Convert value to string. Pointers are returned as null, and VariantBuffer or VariantMap are not supported and return empty
-    std::string ToString() const;
+    String ToString() const;
     
     /// Return type name for enum value
-    static const std::string& GetTypeName(VariantType type);
+    static const String& GetTypeName(VariantType type);
     
     /// Empty variant
     static const Variant EMPTY;
@@ -863,7 +863,7 @@ private:
     VariantValue value_;
     
     /// Empty string
-    static const std::string emptyString;
+    static const String emptyString;
     /// Empty buffer
     static const std::vector<unsigned char> emptyBuffer;
     /// Empty object reference

+ 32 - 32
Engine/Engine/APITemplates.h

@@ -152,11 +152,11 @@ template <class T, class U> void RegisterSubclass(asIScriptEngine* engine, const
     if (!strcmp(classNameT, classNameU))
         return;
     
-    std::string declReturnT(std::string(classNameT) + "@+ f()");
-    std::string declReturnU(std::string(classNameU) + "@+ f()");
+    String declReturnT(String(classNameT) + "@+ f()");
+    String declReturnU(String(classNameU) + "@+ f()");
     
-    engine->RegisterObjectBehaviour(classNameT, asBEHAVE_IMPLICIT_REF_CAST, declReturnU.c_str(), asFUNCTION((RefCast<T, U>)), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectBehaviour(classNameU, asBEHAVE_IMPLICIT_REF_CAST, declReturnT.c_str(), asFUNCTION((RefCast<U, T>)), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectBehaviour(classNameT, asBEHAVE_IMPLICIT_REF_CAST, declReturnU.CString(), asFUNCTION((RefCast<T, U>)), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectBehaviour(classNameU, asBEHAVE_IMPLICIT_REF_CAST, declReturnT.CString(), asFUNCTION((RefCast<U, T>)), asCALL_CDECL_OBJLAST);
 }
 
 /// Template function for registering a class derived from Serializer
@@ -180,14 +180,14 @@ template <class T> void RegisterSerializer(asIScriptEngine* engine, const char*
     engine->RegisterObjectMethod(className, "bool WritePackedQuaternion(const Quaternion&in)", asMETHODPR(T, WritePackedQuaternion, (const Quaternion&), bool), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "bool WriteColor(const Color&in)", asMETHODPR(T, WriteColor, (const Color&), bool), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "bool WriteBoundingBox(const BoundingBox&in)", asMETHODPR(T, WriteBoundingBox, (const BoundingBox&), bool), asCALL_THISCALL);
-    engine->RegisterObjectMethod(className, "bool WriteString(const String&in)", asMETHODPR(T, WriteString, (const std::string&), bool), asCALL_THISCALL);
-    engine->RegisterObjectMethod(className, "bool WriteID(const String&in)", asMETHODPR(T, WriteID, (const std::string&), bool), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "bool WriteString(const String&in)", asMETHODPR(T, WriteString, (const String&), bool), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "bool WriteID(const String&in)", asMETHODPR(T, WriteID, (const String&), bool), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "bool WriteStringHash(const StringHash&in)", asMETHODPR(T, WriteStringHash, (const StringHash&), bool), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "bool WriteShortStringHash(const ShortStringHash&in)", asMETHODPR(T, WriteShortStringHash, (const ShortStringHash&), bool), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "bool WriteVariant(const Variant&in)", asMETHODPR(T, WriteVariant, (const Variant&), bool), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "bool WriteVariantMap(const VariantMap&in)", asMETHODPR(T, WriteVariantMap, (const VariantMap&), bool), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "bool WriteVLE(uint)", asMETHODPR(T, WriteVLE, (unsigned), bool), asCALL_THISCALL);
-    engine->RegisterObjectMethod(className, "bool WriteLine(const String&in)", asMETHODPR(T, WriteLine, (const std::string&), bool), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "bool WriteLine(const String&in)", asMETHODPR(T, WriteLine, (const String&), bool), asCALL_THISCALL);
 }
 
 /// Template function for registering a class derived from Deserializer
@@ -211,16 +211,16 @@ template <class T> void RegisterDeserializer(asIScriptEngine* engine, const char
     engine->RegisterObjectMethod(className, "Quaternion ReadPackedQuaternion()", asMETHODPR(T, ReadPackedQuaternion, (), Quaternion), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "Color ReadColor()", asMETHODPR(T, ReadColor, (), Color), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "BoundingBox ReadBoundingBox()", asMETHODPR(T, ReadBoundingBox, (), BoundingBox), asCALL_THISCALL);
-    engine->RegisterObjectMethod(className, "String ReadString()", asMETHODPR(T, ReadString, (), std::string), asCALL_THISCALL);
-    engine->RegisterObjectMethod(className, "String ReadID()", asMETHODPR(T, ReadID, (), std::string), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "String ReadString()", asMETHODPR(T, ReadString, (), String), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "String ReadID()", asMETHODPR(T, ReadID, (), String), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "StringHash ReadStringHash()", asMETHODPR(T, ReadStringHash, (), StringHash), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "ShortStringHash ReadShortStringHash()", asMETHODPR(T, ReadShortStringHash, (), ShortStringHash), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "Variant ReadVariant()", asMETHODPR(T, ReadVariant, (), Variant), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "VariantMap ReadVariantMap()", asMETHODPR(T, ReadVariantMap, (), VariantMap), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "uint ReadVLE()", asMETHODPR(T, ReadVLE, (), unsigned), asCALL_THISCALL);
-    engine->RegisterObjectMethod(className, "String ReadLine()", asMETHODPR(T, ReadLine, (), std::string), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "String ReadLine()", asMETHODPR(T, ReadLine, (), String), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "uint Seek(uint)", asMETHODPR(T, Seek, (unsigned), unsigned), asCALL_THISCALL);
-    engine->RegisterObjectMethod(className, "const String& get_name() const", asMETHODPR(T, GetName, () const, const std::string&), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "const String& get_name() const", asMETHODPR(T, GetName, () const, const String&), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "uint get_checksum()", asMETHODPR(T, GetChecksum, (), unsigned), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "uint get_position() const", asMETHODPR(T, GetPosition, () const, unsigned), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "uint get_size() const", asMETHODPR(T, GetSize, () const, unsigned), asCALL_THISCALL);
@@ -242,7 +242,7 @@ template <class T> void RegisterObject(asIScriptEngine* engine, const char* clas
     engine->RegisterObjectBehaviour(className, asBEHAVE_ADDREF, "void f()", asMETHODPR(T, AddRef, (), void), asCALL_THISCALL);
     engine->RegisterObjectBehaviour(className, asBEHAVE_RELEASE, "void f()", asMETHODPR(T, ReleaseRef, (), void), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "ShortStringHash get_type() const", asMETHODPR(T, GetType, () const, ShortStringHash), asCALL_THISCALL);
-    engine->RegisterObjectMethod(className, "const String& get_typeName() const", asMETHODPR(T, GetTypeName, () const, const std::string&), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "const String& get_typeName() const", asMETHODPR(T, GetTypeName, () const, const String&), asCALL_THISCALL);
     RegisterSubclass<Object, T>(engine, "Object", className);
 }
 
@@ -251,7 +251,7 @@ template <class T> T* ConstructObject()
     return new T(GetScriptContext());
 }
 
-template <class T> T* ConstructNamedObject(const std::string& name)
+template <class T> T* ConstructNamedObject(const String& name)
 {
     T* object = new T(GetScriptContext());
     object->SetName(name);
@@ -261,15 +261,15 @@ template <class T> T* ConstructNamedObject(const std::string& name)
 /// Template function for registering a default constructor for a class derived from Object
 template <class T> void RegisterObjectConstructor(asIScriptEngine* engine, const char* className)
 {
-    std::string declFactory(std::string(className) + "@+ f()");
-    engine->RegisterObjectBehaviour(className, asBEHAVE_FACTORY, declFactory.c_str(), asFUNCTION(ConstructObject<T>), asCALL_CDECL);
+    String declFactory(String(className) + "@+ f()");
+    engine->RegisterObjectBehaviour(className, asBEHAVE_FACTORY, declFactory.CString(), asFUNCTION(ConstructObject<T>), asCALL_CDECL);
 }
 
 /// Template function for registering a named constructor for a class derived from Object
 template <class T> void RegisterNamedObjectConstructor(asIScriptEngine* engine, const char* className)
 {
-    std::string declFactoryWithName(std::string(className) + "@+ f(const String&in)");
-    engine->RegisterObjectBehaviour(className, asBEHAVE_FACTORY, declFactoryWithName.c_str(), asFUNCTION(ConstructNamedObject<T>), asCALL_CDECL);
+    String declFactoryWithName(String(className) + "@+ f(const String&in)");
+    engine->RegisterObjectBehaviour(className, asBEHAVE_FACTORY, declFactoryWithName.CString(), asFUNCTION(ConstructNamedObject<T>), asCALL_CDECL);
 }
 
 static const AttributeInfo noAttributeInfo;
@@ -310,8 +310,8 @@ template <class T> void RegisterSerializable(asIScriptEngine* engine, const char
     engine->RegisterObjectMethod(className, "bool Save(File@+)", asFUNCTION(SerializableSave), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod(className, "bool LoadXML(const XMLElement&)", asMETHODPR(T, LoadXML, (const XMLElement&), bool), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "bool SaveXML(XMLElement&)", asMETHODPR(T, SaveXML, (XMLElement&), bool), asCALL_THISCALL);
-    engine->RegisterObjectMethod(className, "bool SetAttribute(const String&in, const Variant&in)", asMETHODPR(T, SetAttribute, (const std::string&, const Variant&), bool), asCALL_THISCALL);
-    engine->RegisterObjectMethod(className, "Variant GetAttribute(const String&in)", asMETHODPR(T, GetAttribute, (const std::string&), Variant), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "bool SetAttribute(const String&in, const Variant&in)", asMETHODPR(T, SetAttribute, (const String&, const Variant&), bool), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "Variant GetAttribute(const String&in)", asMETHODPR(T, GetAttribute, (const String&), Variant), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "uint get_numAttributes() const", asMETHODPR(T, GetNumAttributes, () const, unsigned), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void set_attributes(uint, const Variant&in) const", asMETHODPR(T, SetAttribute, (unsigned, const Variant&), bool), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "Variant get_attributes(uint) const", asMETHODPR(T, GetAttribute, (unsigned), Variant), asCALL_THISCALL);
@@ -330,12 +330,12 @@ template <class T> void RegisterComponent(asIScriptEngine* engine, const char* c
         engine->RegisterObjectMethod(className, "Node@+ get_node() const", asMETHODPR(T, GetNode, () const, Node*), asCALL_THISCALL);
 }
 
-static Component* NodeCreateComponent(const std::string& typeName, bool local, Node* ptr)
+static Component* NodeCreateComponent(const String& typeName, bool local, Node* ptr)
 {
     return ptr->CreateComponent(ShortStringHash(typeName), local);
 }
 
-static Component* NodeGetOrCreateComponent(const std::string& typeName, bool local, Node* ptr)
+static Component* NodeGetOrCreateComponent(const String& typeName, bool local, Node* ptr)
 {
     return ptr->GetOrCreateComponent(ShortStringHash(typeName), local);
 }
@@ -352,19 +352,19 @@ static Component* NodeGetComponent(unsigned index, Node* ptr)
         return components[index];
 }
 
-static Component* NodeGetComponentWithTypeAndIndex(const std::string& typeName, unsigned index, Node* ptr)
+static Component* NodeGetComponentWithTypeAndIndex(const String& typeName, unsigned index, Node* ptr)
 {
     return ptr->GetComponent(ShortStringHash(typeName), index);
 }
 
-static CScriptArray* NodeGetComponentsWithType(const std::string& typeName, Node* ptr)
+static CScriptArray* NodeGetComponentsWithType(const String& typeName, Node* ptr)
 {
     std::vector<Component*> components;
     ptr->GetComponents(components, ShortStringHash(typeName));
     return VectorToHandleArray<Component>(components, "Array<Component@>");
 }
 
-static bool NodeHasComponent(const std::string& typeName, Node* ptr)
+static bool NodeHasComponent(const String& typeName, Node* ptr)
 {
     return ptr->HasComponent(ShortStringHash(typeName));
 }
@@ -376,7 +376,7 @@ static CScriptArray* NodeGetChildren(bool recursive, Node* ptr)
     return VectorToHandleArray<Node>(nodes, "Array<Node@>");
 }
 
-static CScriptArray* NodeGetChildrenWithComponent(std::string& typeName, bool recursive, Node* ptr)
+static CScriptArray* NodeGetChildrenWithComponent(String& typeName, bool recursive, Node* ptr)
 {
     std::vector<Node*> nodes;
     ptr->GetChildrenWithComponent(nodes, ShortStringHash(typeName), recursive);
@@ -412,7 +412,7 @@ static CScriptArray* NodeGetScriptedChildren(bool recursive, Node* ptr)
     return VectorToHandleArray<Node>(nodes, "Array<Node@>");
 }
 
-static CScriptArray* NodeGetScriptedChildrenWithClassName(const std::string& className, bool recursive, Node* ptr)
+static CScriptArray* NodeGetScriptedChildrenWithClassName(const String& className, bool recursive, Node* ptr)
 {
     std::vector<Node*> nodes;
     std::vector<Node*> ret;
@@ -453,7 +453,7 @@ template <class T> void RegisterNode(asIScriptEngine* engine, const char* classN
     engine->RegisterObjectMethod(className, "void Roll(float, bool)", asMETHOD(T, Roll), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void Scale(float)", asMETHODPR(T, Scale, (float), void), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void Scale(const Vector3&in)", asMETHODPR(T, Scale, (const Vector3&), void), asCALL_THISCALL);
-    engine->RegisterObjectMethod(className, "Node@+ CreateChild(const String&in name = \"\", bool local = false)", asMETHODPR(T, CreateChild, (const std::string&, bool), Node*), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "Node@+ CreateChild(const String&in name = \"\", bool local = false)", asMETHODPR(T, CreateChild, (const String&, bool), Node*), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void AddChild(Node@+)", asMETHOD(T, AddChild), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void RemoveChild(Node@+)", asMETHODPR(T, RemoveChild, (Node*), void), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void RemoveAllChildren()", asMETHOD(T, RemoveAllChildren), asCALL_THISCALL);
@@ -464,7 +464,7 @@ template <class T> void RegisterNode(asIScriptEngine* engine, const char* classN
     engine->RegisterObjectMethod(className, "Array<Node@>@ GetChildrenWithComponent(const String&in, bool recursive = false) const", asFUNCTION(NodeGetChildrenWithComponent), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod(className, "Array<Node@>@ GetScriptedChildren(bool recursive = false) const", asFUNCTION(NodeGetScriptedChildren), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod(className, "Array<Node@>@ GetScriptedChildren(const String&in, bool recursive = false) const", asFUNCTION(NodeGetScriptedChildrenWithClassName), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod(className, "Node@+ GetChild(const String&in, bool recursive = false) const", asMETHODPR(T, GetChild, (const std::string&, bool) const, Node*), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "Node@+ GetChild(const String&in, bool recursive = false) const", asMETHODPR(T, GetChild, (const String&, bool) const, Node*), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "Array<Component@>@ GetComponents(const String&in) const", asFUNCTION(NodeGetComponentsWithType), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod(className, "Component@+ GetComponent(const String&in, uint index = 0) const", asFUNCTION(NodeGetComponentWithTypeAndIndex), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod(className, "bool HasComponent(const String&in) const", asFUNCTION(NodeHasComponent), asCALL_CDECL_OBJLAST);
@@ -522,8 +522,8 @@ template <class T> void RegisterResource(asIScriptEngine* engine, const char* cl
     }
     engine->RegisterObjectMethod(className, "bool Load(File@+)", asFUNCTION(ResourceLoad), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod(className, "bool Save(File@+)", asFUNCTION(ResourceSave), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod(className, "void set_name(const String&in) const", asMETHODPR(T, SetName, (const std::string&), void), asCALL_THISCALL);
-    engine->RegisterObjectMethod(className, "const String& get_name() const", asMETHODPR(T, GetName, () const, const std::string&), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void set_name(const String&in) const", asMETHODPR(T, SetName, (const String&), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "const String& get_name() const", asMETHODPR(T, GetName, () const, const String&), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "uint get_memoryUse() const", asMETHODPR(T, GetMemoryUse, () const, unsigned), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "uint get_useTimer()" ,asMETHODPR(T, GetUseTimer, (), unsigned), asCALL_THISCALL);
 }
@@ -620,7 +620,7 @@ template <class T> void RegisterUIElement(asIScriptEngine* engine, const char* c
     RegisterNamedObjectConstructor<T>(engine, className);
     RegisterSubclass<UIElement, T>(engine, "UIElement", className);
     engine->RegisterObjectMethod(className, "void SetStyle(const XMLElement&in)", asMETHODPR(T, SetStyle, (const XMLElement&), void), asCALL_THISCALL);
-    engine->RegisterObjectMethod(className, "void SetStyle(XMLFile@+, const String&in)", asMETHODPR(T, SetStyle, (XMLFile*, const std::string&), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "void SetStyle(XMLFile@+, const String&in)", asMETHODPR(T, SetStyle, (XMLFile*, const String&), void), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void SetStyleAuto(XMLFile@+)", asMETHODPR(T, SetStyleAuto, (XMLFile*), void), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void SetPosition(int, int)", asMETHODPR(T, SetPosition, (int, int), void), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void SetSize(int, int)", asMETHODPR(T, SetSize, (int, int), void), asCALL_THISCALL);
@@ -641,7 +641,7 @@ template <class T> void RegisterUIElement(asIScriptEngine* engine, const char* c
     engine->RegisterObjectMethod(className, "void RemoveChild(UIElement@+)", asMETHOD(T, RemoveChild), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void RemoveAllChildren()", asMETHOD(T, RemoveAllChildren), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "void Remove()", asMETHOD(T, Remove), asCALL_THISCALL);
-    engine->RegisterObjectMethod(className, "UIElement@+ GetChild(const String&in, bool recursive = false) const", asMETHODPR(T, GetChild, (const std::string&, bool) const, UIElement*), asCALL_THISCALL);
+    engine->RegisterObjectMethod(className, "UIElement@+ GetChild(const String&in, bool recursive = false) const", asMETHODPR(T, GetChild, (const String&, bool) const, UIElement*), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "IntVector2 ScreenToElement(const IntVector2&in)", asMETHOD(T, ScreenToElement), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "IntVector2 ElementToScreen(const IntVector2&in)", asMETHOD(T, ElementToScreen), asCALL_THISCALL);
     engine->RegisterObjectMethod(className, "bool IsInside(IntVector2, bool)", asMETHOD(T, IsInside), asCALL_THISCALL);

+ 6 - 6
Engine/Engine/Console.cpp

@@ -42,7 +42,7 @@
 
 static const int DEFAULT_CONSOLE_ROWS = 16;
 static const int DEFAULT_HISTORY_SIZE = 16;
-static const std::string noRow;
+static const String noRow;
 
 OBJECTTYPESTATIC(Console);
 
@@ -166,7 +166,7 @@ bool Console::IsVisible() const
     return background_->IsVisible();
 }
 
-const std::string& Console::GetHistoryRow(unsigned index) const
+const String& Console::GetHistoryRow(unsigned index) const
 {
     return index < history_.size() ? history_[index] : noRow;
 }
@@ -175,8 +175,8 @@ void Console::HandleTextFinished(StringHash eventType, VariantMap& eventData)
 {
     using namespace TextFinished;
     
-    std::string line = lineEdit_->GetText();
-    if (!line.empty())
+    String line = lineEdit_->GetText();
+    if (!line.Empty())
     {
         Script* script = GetSubsystem<Script>();
         if (script)
@@ -188,7 +188,7 @@ void Console::HandleTextFinished(StringHash eventType, VariantMap& eventData)
             history_.erase(history_.begin());
         historyPosition_ = history_.size();
         
-        current_Row.clear();
+        current_Row.Clear();
         lineEdit_->SetText(current_Row);
     }
 }
@@ -248,7 +248,7 @@ void Console::HandleLogMessage(StringHash eventType, VariantMap& eventData)
     using namespace LogMessage;
     
     // Be prepared for possible multi-line messages
-    std::vector<std::string> rows = Split(eventData[P_MESSAGE].GetString(), '\n');
+    std::vector<String> rows = Split(eventData[P_MESSAGE].GetString(), '\n');
     for (unsigned i = 0; i < rows.size(); ++i)
     {
         // Remove the first row, change its text and re-add to the bottom

+ 3 - 3
Engine/Engine/Console.h

@@ -72,7 +72,7 @@ public:
     /// Return current history position
     unsigned GetHistoryPosition() const { return historyPosition_; }
     /// Return history row at index
-    const std::string& GetHistoryRow(unsigned index) const;
+    const String& GetHistoryRow(unsigned index) const;
     
 private:
     /// Handle enter pressed on the line edit
@@ -95,9 +95,9 @@ private:
     /// Line edit
     SharedPtr<LineEdit> lineEdit_;
     /// Command history
-    std::vector<std::string> history_;
+    std::vector<String> history_;
     /// Current row being edited
-    std::string current_Row;
+    String current_Row;
     /// Command history maximum rows
     unsigned historyRows_;
     /// Command history current position

+ 31 - 35
Engine/Engine/CoreAPI.cpp

@@ -37,7 +37,7 @@ static void ConstructStringHashCopy(const StringHash& hash, StringHash* ptr)
     new(ptr) StringHash(hash);
 }
 
-static void ConstructStringHashInit(const std::string& str, StringHash* ptr)
+static void ConstructStringHashInit(const String& str, StringHash* ptr)
 {
     new(ptr) StringHash(str);
 }
@@ -67,7 +67,7 @@ static void ConstructShortStringHashCopyLong(const StringHash& hash, ShortString
     new(ptr) ShortStringHash(hash);
 }
 
-static void ConstructShortStringHashInit(const std::string& str, ShortStringHash* ptr)
+static void ConstructShortStringHashInit(const String& str, ShortStringHash* ptr)
 {
     new(ptr) ShortStringHash(str);
 }
@@ -93,7 +93,7 @@ static void RegisterStringHash(asIScriptEngine* engine)
     engine->RegisterObjectMethod("StringHash", "bool opEquals(const StringHash&in) const", asMETHOD(StringHash, operator ==), asCALL_THISCALL);
     engine->RegisterObjectMethod("StringHash", "int opCmp(const StringHash&in) const", asFUNCTION(StringHashCmp), asCALL_CDECL_OBJFIRST);
     engine->RegisterObjectMethod("StringHash", "StringHash opAdd(const StringHash&in) const", asMETHOD(StringHash, operator +), asCALL_THISCALL);
-    engine->RegisterObjectMethod("StringHash", "String ToString() const", asFUNCTIONPR(ToString, (const StringHash&), std::string), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("StringHash", "String ToString() const", asFUNCTIONPR(ToString, (const StringHash&), String), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("StringHash", "uint get_value()", asMETHOD(StringHash, GetValue), asCALL_THISCALL);
     
     engine->RegisterObjectType("ShortStringHash", sizeof(ShortStringHash), asOBJ_VALUE | asOBJ_POD | asOBJ_APP_CLASS_CAK);
@@ -104,7 +104,7 @@ static void RegisterStringHash(asIScriptEngine* engine)
     engine->RegisterObjectMethod("ShortStringHash", "ShortStringHash &opAssign(const ShortStringHash&in)", asMETHODPR(ShortStringHash, operator =, (const ShortStringHash&), ShortStringHash&), asCALL_THISCALL);
     engine->RegisterObjectMethod("ShortStringHash", "bool opEquals(const ShortStringHash&in) const", asMETHOD(ShortStringHash, operator ==), asCALL_THISCALL);
     engine->RegisterObjectMethod("ShortStringHash", "int opCmp(const ShortStringHash&in) const", asFUNCTION(ShortStringHashCmp), asCALL_CDECL_OBJFIRST);
-    engine->RegisterObjectMethod("ShortStringHash", "String ToString() const", asFUNCTIONPR(ToString, (const ShortStringHash&), std::string), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("ShortStringHash", "String ToString() const", asFUNCTIONPR(ToString, (const ShortStringHash&), String), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("ShortStringHash", "uint16 get_value()", asMETHOD(ShortStringHash, GetValue), asCALL_THISCALL);
 }
 
@@ -235,7 +235,7 @@ static void ConstructVariantColor(const Color& value, Variant* ptr)
     new(ptr) Variant(value);
 }
 
-static void ConstructVariantString(const std::string& value, Variant* ptr)
+static void ConstructVariantString(const String& value, Variant* ptr)
 {
     new(ptr) Variant(value);
 }
@@ -300,17 +300,17 @@ static void DestructVariantMap(VariantMap* ptr)
     ptr->~VariantMap();
 }
 
-static Variant& VariantMapAt(const std::string& key, VariantMap& map)
+static Variant& VariantMapAt(const String& key, VariantMap& map)
 {
     return map[ShortStringHash(key)];
 }
 
-static bool VariantMapContains(const std::string& key, VariantMap& map)
+static bool VariantMapContains(const String& key, VariantMap& map)
 {
     return map.find(ShortStringHash(key)) != map.end();
 }
 
-static void VariantMapErase(const std::string& key, VariantMap& map)
+static void VariantMapErase(const String& key, VariantMap& map)
 {
     map.erase(ShortStringHash(key));
 }
@@ -386,7 +386,7 @@ static void RegisterVariant(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Variant", "Variant &opAssign(const Vector3&in)", asMETHODPR(Variant, operator =, (const Vector3&), Variant&), asCALL_THISCALL);
     engine->RegisterObjectMethod("Variant", "Variant &opAssign(const Quaternion&in)", asMETHODPR(Variant, operator =, (const Quaternion&), Variant&), asCALL_THISCALL);
     engine->RegisterObjectMethod("Variant", "Variant &opAssign(const Color&in)", asMETHODPR(Variant, operator =, (const Color&), Variant&), asCALL_THISCALL);
-    engine->RegisterObjectMethod("Variant", "Variant &opAssign(const String&in)", asMETHODPR(Variant, operator =, (const std::string&), Variant&), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Variant", "Variant &opAssign(const String&in)", asMETHODPR(Variant, operator =, (const String&), Variant&), asCALL_THISCALL);
     engine->RegisterObjectMethod("Variant", "Variant &opAssign(const Array<Variant>@+)", asFUNCTION(VariantAssignVariantVector), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Variant", "Variant &opAssign(const VariantMap&in)", asMETHODPR(Variant, operator =, (const VariantMap&), Variant&), asCALL_THISCALL);
     engine->RegisterObjectMethod("Variant", "bool opEquals(const Variant&in) const", asMETHODPR(Variant, operator ==, (const Variant&) const, bool), asCALL_THISCALL);
@@ -400,7 +400,7 @@ static void RegisterVariant(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Variant", "bool opEquals(const Vector3&in) const", asMETHODPR(Variant, operator ==, (const Vector3&) const, bool), asCALL_THISCALL);
     engine->RegisterObjectMethod("Variant", "bool opEquals(const Quaternion&in) const", asMETHODPR(Variant, operator ==, (const Quaternion&) const, bool), asCALL_THISCALL);
     engine->RegisterObjectMethod("Variant", "bool opEquals(const Color&in) const", asMETHODPR(Variant, operator ==, (const Color&) const, bool), asCALL_THISCALL);
-    engine->RegisterObjectMethod("Variant", "bool opEquals(const String&in) const", asMETHODPR(Variant, operator ==, (const std::string&) const, bool), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Variant", "bool opEquals(const String&in) const", asMETHODPR(Variant, operator ==, (const String&) const, bool), asCALL_THISCALL);
     engine->RegisterObjectMethod("Variant", "bool opEquals(const Array<Variant>@+)", asFUNCTION(VariantEqualsVariantVector), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Variant", "bool opEquals(const VariantMap&in) const", asMETHODPR(Variant, operator ==, (const VariantMap&) const, bool), asCALL_THISCALL);
     engine->RegisterObjectMethod("Variant", "int GetInt() const", asMETHOD(Variant, GetInt), asCALL_THISCALL);
@@ -420,7 +420,7 @@ static void RegisterVariant(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Variant", "void FromString(const String&in, const String&in)", asMETHOD(Variant, FromString), asCALL_THISCALL);
     engine->RegisterObjectMethod("Variant", "String ToString() const", asMETHOD(Variant, ToString), asCALL_THISCALL);
     engine->RegisterObjectMethod("Variant", "VariantType get_type() const", asMETHOD(Variant, GetType), asCALL_THISCALL);
-    engine->RegisterObjectMethod("Variant", "const String &get_typeName() const", asMETHODPR(Variant, GetTypeName, () const, const std::string&), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Variant", "const String &get_typeName() const", asMETHODPR(Variant, GetTypeName, () const, const String&), asCALL_THISCALL);
     
     engine->RegisterObjectBehaviour("VariantMap", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructVariantMap), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectBehaviour("VariantMap", asBEHAVE_CONSTRUCT, "void f(const VariantMap&in)", asFUNCTION(ConstructVariantMapCopy), asCALL_CDECL_OBJLAST);
@@ -434,20 +434,16 @@ static void RegisterVariant(asIScriptEngine* engine)
     engine->RegisterObjectMethod("VariantMap", "uint get_length() const", asMETHOD(VariantMap, size), asCALL_THISCALL);
 }
 
-static CScriptArray* StringSplit(char separator, const std::string* str)
+static CScriptArray* StringSplit(char separator, const String* str)
 {
-    std::vector<std::string> result = Split(*str, separator);
-    return VectorToArray<std::string>(result, "Array<String>");
+    std::vector<String> result = Split(*str, separator);
+    return VectorToArray<String>(result, "Array<String>");
 }
 
 static void RegisterStringUtils(asIScriptEngine* engine)
 {
     // Register most of StringUtils as string's const methods, or objects' ToString() const methods for convenience
     engine->RegisterObjectMethod("String", "Array<String>@ Split(uint8) const", asFUNCTION(StringSplit), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("String", "String Replace(uint8, uint8) const", asFUNCTIONPR(Replace, (const std::string&, char, char), std::string), asCALL_CDECL_OBJFIRST);
-    engine->RegisterObjectMethod("String", "String Replace(const String&in, const String&in) const", asFUNCTIONPR(Replace, (const std::string&, const std::string&, const std::string&), std::string), asCALL_CDECL_OBJFIRST);
-    engine->RegisterObjectMethod("String", "String ToUpper() const", asFUNCTION(ToUpper), asCALL_CDECL_OBJLAST);
-    engine->RegisterObjectMethod("String", "String ToLower() const", asFUNCTION(ToLower), 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);
@@ -459,10 +455,10 @@ static void RegisterStringUtils(asIScriptEngine* engine)
     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() const", asFUNCTION(ToVector4), asCALL_CDECL_OBJLAST);
-    engine->RegisterGlobalFunction("String ToString(bool)", asFUNCTIONPR(ToString, (bool), std::string), asCALL_CDECL);
-    engine->RegisterGlobalFunction("String ToString(float)", asFUNCTIONPR(ToString, (float), std::string), asCALL_CDECL);
-    engine->RegisterGlobalFunction("String ToString(int)", asFUNCTIONPR(ToString, (int), std::string), asCALL_CDECL);
-    engine->RegisterGlobalFunction("String ToString(uint)", asFUNCTIONPR(ToString, (unsigned), std::string), asCALL_CDECL);
+    engine->RegisterGlobalFunction("String ToString(bool)", asFUNCTIONPR(ToString, (bool), String), asCALL_CDECL);
+    engine->RegisterGlobalFunction("String ToString(float)", asFUNCTIONPR(ToString, (float), String), asCALL_CDECL);
+    engine->RegisterGlobalFunction("String ToString(int)", asFUNCTIONPR(ToString, (int), String), asCALL_CDECL);
+    engine->RegisterGlobalFunction("String ToString(uint)", asFUNCTIONPR(ToString, (unsigned), String), asCALL_CDECL);
     engine->RegisterGlobalFunction("String ToStringHex(int)", asFUNCTION(ToStringHex), asCALL_CDECL);
 }
 
@@ -493,12 +489,12 @@ static void RegisterTimer(asIScriptEngine* engine)
 
 static CScriptArray* GetArgumentsToArray()
 {
-    return VectorToArray<std::string>(GetArguments(), "Array<String>");
+    return VectorToArray<String>(GetArguments(), "Array<String>");
 }
 
-static void ShowErrorDialog(const std::string& title, const std::string& message)
+static void ShowErrorDialog(const String& title, const String& message)
 {
-    ErrorDialog(title.c_str(), message.c_str());
+    ErrorDialog(title.CString(), message.CString());
 }
 
 static void RegisterProcessUtils(asIScriptEngine* engine)
@@ -527,52 +523,52 @@ static void DestructAttributeInfo(AttributeInfo* ptr)
 
 static CScriptArray* AttributeInfoGetEnumNames(AttributeInfo* ptr)
 {
-    std::vector<std::string> enumNames;
-    const std::string* enumNamePtrs = ptr->enumNames_;
-    while ((enumNamePtrs) && (enumNamePtrs->length()))
+    std::vector<String> enumNames;
+    const String* enumNamePtrs = ptr->enumNames_;
+    while ((enumNamePtrs) && (enumNamePtrs->Length()))
     {
         enumNames.push_back(*enumNamePtrs);
         ++enumNamePtrs;
     }
-    return VectorToArray<std::string>(enumNames, "Array<String>");
+    return VectorToArray<String>(enumNames, "Array<String>");
 }
 
-static void SendEvent(const std::string& eventType, VariantMap& parameters)
+static void SendEvent(const String& eventType, VariantMap& parameters)
 {
     Object* sender = GetScriptContextEventListenerObject();
     if (sender)
         sender->SendEvent(StringHash(eventType), parameters);
 }
 
-static void SendTargetedEvent(Object* receiver, const std::string& eventType, VariantMap& parameters)
+static void SendTargetedEvent(Object* receiver, const String& eventType, VariantMap& parameters)
 {
     Object* sender = GetScriptContextEventListenerObject();
     if (sender)
         sender->SendEvent(receiver, StringHash(eventType), parameters);
 }
 
-static void SubscribeToEvent(const std::string& eventType, const std::string& handlerName)
+static void SubscribeToEvent(const String& eventType, const String& handlerName)
 {
     ScriptEventListener* listener = GetScriptContextEventListener();
     if (listener)
         listener->AddEventHandler(StringHash(eventType), handlerName);
 }
 
-static void SubscribeToSenderEvent(Object* sender, const std::string& eventType, const std::string& handlerName)
+static void SubscribeToSenderEvent(Object* sender, const String& eventType, const String& handlerName)
 {
     ScriptEventListener* listener = GetScriptContextEventListener();
     if (listener)
         listener->AddEventHandler(sender, StringHash(eventType), handlerName);
 }
 
-static void UnsubscribeFromEvent(const std::string& eventType)
+static void UnsubscribeFromEvent(const String& eventType)
 {
     Object* listener = GetScriptContextEventListenerObject();
     if (listener)
         listener->UnsubscribeFromEvent(StringHash(eventType));
 }
 
-static void UnsubscribeFromSenderEvent(Object* sender, const std::string& eventType)
+static void UnsubscribeFromSenderEvent(Object* sender, const String& eventType)
 {
     Object* listener = GetScriptContextEventListenerObject();
     if (listener)

+ 3 - 3
Engine/Engine/DebugHud.cpp

@@ -101,7 +101,7 @@ void DebugHud::Update(float timeStep)
     
     if (statsText_->IsVisible())
     {
-        std::string stats = 
+        String stats = 
             "Triangles " + ToString(graphics->GetNumPrimitives()) +
             "\nBatches " + ToString(graphics->GetNumBatches()) +
             "\nViews " + ToString(renderer->GetNumViews()) + 
@@ -114,7 +114,7 @@ void DebugHud::Update(float timeStep)
     
     if (modeText_->IsVisible())
     {
-        std::string mode;
+        String mode;
         
         RenderMode renderMode = graphics->GetRenderMode();
         if (renderMode == RENDER_FORWARD)
@@ -198,7 +198,7 @@ void DebugHud::Update(float timeStep)
         {
             if (profilerText_->IsVisible())
             {
-                std::string profilerOutput = profiler->GetData(false, true, false);
+                String profilerOutput = profiler->GetData(false, true, false);
                 profilerText_->SetText(profilerOutput);
             }
             

+ 14 - 14
Engine/Engine/Engine.cpp

@@ -68,7 +68,7 @@ Engine::~Engine()
 {
 }
 
-bool Engine::Initialize(const std::string& windowTitle, const std::string& logName, const std::vector<std::string>& arguments)
+bool Engine::Initialize(const String& windowTitle, const String& logName, const std::vector<String>& arguments)
 {
     if (initialized_)
         return true;
@@ -90,9 +90,9 @@ bool Engine::Initialize(const std::string& windowTitle, const std::string& logNa
     
     for (unsigned i = 0; i < arguments.size(); ++i)
     {
-        if ((arguments[i][0] == '-') && (arguments[i].length() >= 2))
+        if ((arguments[i][0] == '-') && (arguments[i].Length() >= 2))
         {
-            std::string argument = ToLower(arguments[i].substr(1));
+            String argument = arguments[i].Substring(1).ToLower();
             
             if (argument == "headless")
                 headless_ = true;
@@ -119,28 +119,28 @@ bool Engine::Initialize(const std::string& windowTitle, const std::string& logNa
                 switch (tolower(argument[0]))
                 {
                 case 'x':
-                    if (arguments[i].length() > 1)
-                        width = ToInt(argument.substr(1));
+                    if (arguments[i].Length() > 1)
+                        width = ToInt(argument.Substring(1));
                     break;
                     
                 case 'y':
-                    if (arguments[i].length() > 1)
-                        height = ToInt(argument.substr(1));
+                    if (arguments[i].Length() > 1)
+                        height = ToInt(argument.Substring(1));
                     break;
                 
                 case 'm':
-                    if (arguments[i].length() > 1)
-                        multiSample = ToInt(argument.substr(1));
+                    if (arguments[i].Length() > 1)
+                        multiSample = ToInt(argument.Substring(1));
                     break;
                     
                 case 'b':
-                    if (arguments[i].length() > 1)
-                        buffer = ToInt(argument.substr(1));
+                    if (arguments[i].Length() > 1)
+                        buffer = ToInt(argument.Substring(1));
                     break;
                     
                 case 'r':
-                    if (arguments[i].length() > 1)
-                        mixRate = ToInt(argument.substr(1));
+                    if (arguments[i].Length() > 1)
+                        mixRate = ToInt(argument.Substring(1));
                     break;
                     
                 case 'v':
@@ -170,7 +170,7 @@ bool Engine::Initialize(const std::string& windowTitle, const std::string& logNa
     // Add default resource paths: CoreData package or directory, Data package or directory, system fonts directory
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     FileSystem* fileSystem = GetSubsystem<FileSystem>();
-    std::string exePath = fileSystem->GetProgramDir();
+    String exePath = fileSystem->GetProgramDir();
     if (fileSystem->FileExists(exePath + "CoreData.pak"))
     {
         SharedPtr<PackageFile> package(new PackageFile(context_));

+ 2 - 2
Engine/Engine/Engine.h

@@ -41,8 +41,8 @@ public:
     virtual ~Engine();
     
     /// Initialize and show the application window. Return true if successful
-    bool Initialize(const std::string& windowTitle = "Urho3D", const std::string& logName = "Urho3D.log", const std::vector<std::string>&
-        arguments = std::vector<std::string>());
+    bool Initialize(const String& windowTitle = "Urho3D", const String& logName = "Urho3D.log", const std::vector<String>&
+        arguments = std::vector<String>());
     /// Initialize script subsystem and register the script API. Return true if successful (engine must be initialized first)
     bool InitializeScripting();
     /// Run one frame

+ 6 - 6
Engine/Engine/GraphicsAPI.cpp

@@ -104,7 +104,7 @@ static void RegisterSkeleton(asIScriptEngine* engine)
     engine->RegisterObjectBehaviour("Skeleton", asBEHAVE_ADDREF, "void f()", asFUNCTION(FakeAddRef), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectBehaviour("Skeleton", asBEHAVE_RELEASE, "void f()", asFUNCTION(FakeReleaseRef), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Skeleton", "void Reset()", asMETHOD(Skeleton, Reset), asCALL_THISCALL);
-    engine->RegisterObjectMethod("Skeleton", "Bone@+ GetBone(const String&in) const", asMETHODPR(Skeleton, GetBone, (const std::string&), Bone*), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Skeleton", "Bone@+ GetBone(const String&in) const", asMETHODPR(Skeleton, GetBone, (const String&), Bone*), asCALL_THISCALL);
     engine->RegisterObjectMethod("Skeleton", "Bone@+ get_rootBone() const", asMETHOD(Skeleton, GetRootBone), asCALL_THISCALL);
     engine->RegisterObjectMethod("Skeleton", "uint get_numBones() const", asMETHOD(Skeleton, GetNumBones), asCALL_THISCALL);
     engine->RegisterObjectMethod("Skeleton", "Bone@+ get_bones(uint)", asMETHODPR(Skeleton, GetBone, (unsigned), Bone*), asCALL_THISCALL);
@@ -259,7 +259,7 @@ static Vector4 MaterialGetPixelShaderParameter(PSParameter parameter, Material*
         return i->second;
 }
 
-static Material* MaterialClone(const std::string& cloneName, Material* ptr)
+static Material* MaterialClone(const String& cloneName, Material* ptr)
 {
     SharedPtr<Material> clonedMaterial = ptr->Clone(cloneName);
     // The shared pointer will go out of scope, so have to increment the reference count
@@ -584,7 +584,7 @@ static void RegisterAnimatedModel(asIScriptEngine* engine)
     RegisterDrawable<AnimatedModel>(engine, "AnimatedModel");
     engine->RegisterObjectMethod("AnimatedModel", "AnimationState@+ AddAnimationState(Animation@+)", asMETHOD(AnimatedModel, AddAnimationState), asCALL_THISCALL);
     engine->RegisterObjectMethod("AnimatedModel", "void RemoveAnimationState(Animation@+)", asMETHODPR(AnimatedModel, RemoveAnimationState, (Animation*), void), asCALL_THISCALL);
-    engine->RegisterObjectMethod("AnimatedModel", "void RemoveAnimationState(const String&in)", asMETHODPR(AnimatedModel, RemoveAnimationState, (const std::string&), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod("AnimatedModel", "void RemoveAnimationState(const String&in)", asMETHODPR(AnimatedModel, RemoveAnimationState, (const String&), void), asCALL_THISCALL);
     engine->RegisterObjectMethod("AnimatedModel", "void RemoveAnimationState(AnimationState@+)", asMETHODPR(AnimatedModel, RemoveAnimationState, (AnimationState*), void), asCALL_THISCALL);
     engine->RegisterObjectMethod("AnimatedModel", "void RemoveAllAnimationStates()", asMETHOD(AnimatedModel, RemoveAllAnimationStates), asCALL_THISCALL);
     engine->RegisterObjectMethod("AnimatedModel", "void SetMorphWeight(uint, float)", asMETHODPR(AnimatedModel, SetMorphWeight, (unsigned, float), void), asCALL_THISCALL);
@@ -607,10 +607,10 @@ static void RegisterAnimatedModel(asIScriptEngine* engine)
     engine->RegisterObjectMethod("AnimatedModel", "float get_invisibleLodFactor() const", asMETHOD(AnimatedModel, GetInvisibleLodFactor), asCALL_THISCALL);
     engine->RegisterObjectMethod("AnimatedModel", "Skeleton@+ get_skeleton()", asMETHOD(AnimatedModel, GetSkeleton), asCALL_THISCALL);
     engine->RegisterObjectMethod("AnimatedModel", "uint get_numAnimationStates() const", asMETHOD(AnimatedModel, GetNumAnimationStates), asCALL_THISCALL);
-    engine->RegisterObjectMethod("AnimatedModel", "AnimationState@+ get_animationStates(const String&in) const", asMETHODPR(AnimatedModel, GetAnimationState, (const std::string&) const, AnimationState*), asCALL_THISCALL);
+    engine->RegisterObjectMethod("AnimatedModel", "AnimationState@+ get_animationStates(const String&in) const", asMETHODPR(AnimatedModel, GetAnimationState, (const String&) const, AnimationState*), asCALL_THISCALL);
     engine->RegisterObjectMethod("AnimatedModel", "uint get_numMorphs() const", asMETHOD(AnimatedModel, GetNumMorphs), asCALL_THISCALL);
-    engine->RegisterObjectMethod("AnimatedModel", "void set_morphWeight(const String&in, float)", asMETHODPR(AnimatedModel, SetMorphWeight, (const std::string&, float), void), asCALL_THISCALL);
-    engine->RegisterObjectMethod("AnimatedModel", "float getMorphWeight(const String&in) const", asMETHODPR(AnimatedModel, GetMorphWeight, (const std::string&) const, float), asCALL_THISCALL);
+    engine->RegisterObjectMethod("AnimatedModel", "void set_morphWeight(const String&in, float)", asMETHODPR(AnimatedModel, SetMorphWeight, (const String&, float), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod("AnimatedModel", "float getMorphWeight(const String&in) const", asMETHODPR(AnimatedModel, GetMorphWeight, (const String&) const, float), asCALL_THISCALL);
 }
 
 static void RegisterAnimationController(asIScriptEngine* engine)

+ 16 - 16
Engine/Engine/IOAPI.cpp

@@ -43,7 +43,7 @@ static Log* GetLog()
     return GetScriptContext()->GetSubsystem<Log>();
 }
 
-static void Print(const std::string& value)
+static void Print(const String& value)
 {
     GetLog()->WriteRaw(value + "\n");
 }
@@ -63,27 +63,27 @@ static void Print(bool value)
     GetLog()->WriteRaw(ToString(value) + "\n");
 }
 
-static void LogWrite(const std::string& str, Log* ptr)
+static void LogWrite(const String& str, Log* ptr)
 {
     ptr->WriteRaw(str + "\n");
 }
 
-static void LogDebug(const std::string& str, Log* ptr)
+static void LogDebug(const String& str, Log* ptr)
 {
     ptr->Write(LOG_DEBUG, str);
 }
 
-static void LogInfo(const std::string& str, Log* ptr)
+static void LogInfo(const String& str, Log* ptr)
 {
     ptr->Write(LOG_INFO, str);
 }
 
-static void LogWarning(const std::string& str, Log* ptr)
+static void LogWarning(const String& str, Log* ptr)
 {
     ptr->Write(LOG_WARNING, str);
 }
 
-static void LogError(const std::string& str, Log* ptr)
+static void LogError(const String& str, Log* ptr)
 {
     ptr->Write(LOG_ERROR, str);
 }
@@ -108,7 +108,7 @@ static void RegisterLog(asIScriptEngine* engine)
     engine->RegisterGlobalFunction("Log@+ get_log()", asFUNCTION(GetLog), asCALL_CDECL);
     
     // Register also Print() functions for convenience
-    engine->RegisterGlobalFunction("void Print(const String&in)", asFUNCTIONPR(Print, (const std::string&), void), asCALL_CDECL);
+    engine->RegisterGlobalFunction("void Print(const String&in)", asFUNCTIONPR(Print, (const String&), void), asCALL_CDECL);
     engine->RegisterGlobalFunction("void Print(int)", asFUNCTIONPR(Print, (int), void), asCALL_CDECL);
     engine->RegisterGlobalFunction("void Print(float)", asFUNCTIONPR(Print, (float), void), asCALL_CDECL);
     engine->RegisterGlobalFunction("void Print(bool)", asFUNCTIONPR(Print, (bool), void), asCALL_CDECL);
@@ -119,7 +119,7 @@ static File* ConstructFile()
     return new File(GetScriptContext());
 }
 
-static File* ConstructFileAndOpen(const std::string& fileName, FileMode mode)
+static File* ConstructFileAndOpen(const String& fileName, FileMode mode)
 {
     return new File(GetScriptContext(), fileName, mode);
 }
@@ -185,22 +185,22 @@ static FileSystem* GetFileSystem()
     return GetScriptContext()->GetSubsystem<FileSystem>();
 }
 
-static CScriptArray* FileSystemScanDir(const std::string& pathName, const std::string& filter, unsigned flags, bool recursive, FileSystem* ptr)
+static CScriptArray* FileSystemScanDir(const String& pathName, const String& filter, unsigned flags, bool recursive, FileSystem* ptr)
 {
-    std::vector<std::string> result;
+    std::vector<String> result;
     ptr->ScanDir(result, pathName, filter, flags, recursive);
-    return VectorToArray<std::string>(result, "Array<String>");
+    return VectorToArray<String>(result, "Array<String>");
 }
 
-static int FileSystemSystemRun(const std::string& fileName, CScriptArray* srcArguments, FileSystem* ptr)
+static int FileSystemSystemRun(const String& fileName, CScriptArray* srcArguments, FileSystem* ptr)
 {
     if (!srcArguments)
         return -1;
     
     unsigned numArguments = srcArguments->GetSize();
-    std::vector<std::string> destArguments(numArguments);
+    std::vector<String> destArguments(numArguments);
     for (unsigned i = 0; i < numArguments; ++i)
-        destArguments[i] = *(static_cast<std::string*>(srcArguments->At(i)));
+        destArguments[i] = *(static_cast<String*>(srcArguments->At(i)));
     
     return ptr->SystemRun(fileName, destArguments);
 }
@@ -229,7 +229,7 @@ static void RegisterSerialization(asIScriptEngine* engine)
     RegisterObject<File>(engine, "File");
     engine->RegisterObjectBehaviour("File", asBEHAVE_FACTORY, "File@+ f()", asFUNCTION(ConstructFile), asCALL_CDECL);
     engine->RegisterObjectBehaviour("File", asBEHAVE_FACTORY, "File@+ f(const String&in, FileMode)", asFUNCTION(ConstructFileAndOpen), asCALL_CDECL);
-    engine->RegisterObjectMethod("File", "bool Open(const String&in, FileMode)", asMETHODPR(File, Open, (const std::string&, FileMode), bool), asCALL_THISCALL);
+    engine->RegisterObjectMethod("File", "bool Open(const String&in, FileMode)", asMETHODPR(File, Open, (const String&, FileMode), bool), asCALL_THISCALL);
     engine->RegisterObjectMethod("File", "void Close()", asMETHOD(File, Close), asCALL_THISCALL);
     engine->RegisterObjectMethod("File", "FileMode get_mode() const", asMETHOD(File, GetMode), asCALL_THISCALL);
     engine->RegisterObjectMethod("File", "bool get_open()", asMETHOD(File, IsOpen), asCALL_THISCALL);
@@ -290,7 +290,7 @@ static PackageFile* ConstructPackageFile()
     return new PackageFile(GetScriptContext());
 }
 
-static PackageFile* ConstructAndOpenPackageFile(const std::string& fileName)
+static PackageFile* ConstructAndOpenPackageFile(const String& fileName)
 {
     return new PackageFile(GetScriptContext(), fileName);
 }

+ 6 - 6
Engine/Engine/MathAPI.cpp

@@ -155,7 +155,7 @@ static void RegisterIntVector2(asIScriptEngine* engine)
     engine->RegisterObjectMethod("IntVector2", "IntVector2 opSub(const IntVector2&in) const", asMETHODPR(IntVector2, operator -, (const IntVector2&) const, IntVector2), asCALL_THISCALL);
     engine->RegisterObjectMethod("IntVector2", "IntVector2 opMul(int) const", asMETHODPR(IntVector2, operator *, (int) const, IntVector2), asCALL_THISCALL);
     engine->RegisterObjectMethod("IntVector2", "IntVector2 opDiv(int) const", asMETHODPR(IntVector2, operator /, (int) const, IntVector2), asCALL_THISCALL);
-    engine->RegisterObjectMethod("IntVector2", "String ToString() const", asFUNCTIONPR(ToString, (const IntVector2&), std::string), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("IntVector2", "String ToString() const", asFUNCTIONPR(ToString, (const IntVector2&), String), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectProperty("IntVector2", "int x", offsetof(IntVector2, x_));
     engine->RegisterObjectProperty("IntVector2", "int y", offsetof(IntVector2, y_));
 }
@@ -202,7 +202,7 @@ static void RegisterVector2(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Vector2", "float AbsDotProduct(const Vector2&in) const", asMETHOD(Vector2, AbsDotProduct), asCALL_THISCALL);
     engine->RegisterObjectMethod("Vector2", "Vector2 Lerp(const Vector2&in, float) const", asMETHOD(Vector2, Lerp), asCALL_THISCALL);
     engine->RegisterObjectMethod("Vector2", "Vector2 GetNormalized() const", asMETHOD(Vector2, GetNormalized), asCALL_THISCALL);
-    engine->RegisterObjectMethod("Vector2", "String ToString() const", asFUNCTIONPR(ToString, (const Vector2&), std::string), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("Vector2", "String ToString() const", asFUNCTIONPR(ToString, (const Vector2&), String), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Vector2", "float get_length() const", asMETHOD(Vector2, GetLength), asCALL_THISCALL);
     engine->RegisterObjectMethod("Vector2", "float get_lengthSquared() const", asMETHOD(Vector2, GetLengthSquared), asCALL_THISCALL);
     engine->RegisterObjectProperty("Vector2", "float x", offsetof(Vector2, x_));
@@ -252,7 +252,7 @@ static void RegisterVector3(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Vector3", "Vector3 CrossProduct(const Vector3&in) const", asMETHOD(Vector3, CrossProduct), asCALL_THISCALL);
     engine->RegisterObjectMethod("Vector3", "Vector3 Lerp(const Vector3&in, float) const", asMETHOD(Vector3, Lerp), asCALL_THISCALL);
     engine->RegisterObjectMethod("Vector3", "Vector3 GetNormalized() const", asMETHOD(Vector3, GetNormalized), asCALL_THISCALL);
-    engine->RegisterObjectMethod("Vector3", "String ToString() const", asFUNCTIONPR(ToString, (const Vector3&), std::string), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("Vector3", "String ToString() const", asFUNCTIONPR(ToString, (const Vector3&), String), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Vector3", "float get_length() const", asMETHOD(Vector3, GetLength), asCALL_THISCALL);
     engine->RegisterObjectMethod("Vector3", "float get_lengthSquared() const", asMETHOD(Vector3, GetLengthSquared), asCALL_THISCALL);
     engine->RegisterObjectProperty("Vector3", "float x", offsetof(Vector3, x_));
@@ -300,7 +300,7 @@ static void RegisterVector4(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Vector4", "float DotProduct(const Vector4&in) const", asMETHOD(Vector4, DotProduct), asCALL_THISCALL);
     engine->RegisterObjectMethod("Vector4", "float AbsDotProduct(const Vector4&in) const", asMETHOD(Vector4, AbsDotProduct), asCALL_THISCALL);
     engine->RegisterObjectMethod("Vector4", "Vector4 Lerp(const Vector4&in, float) const", asMETHOD(Vector4, Lerp), asCALL_THISCALL);
-    engine->RegisterObjectMethod("Vector4", "String ToString() const", asFUNCTIONPR(ToString, (const Vector4&), std::string), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("Vector4", "String ToString() const", asFUNCTIONPR(ToString, (const Vector4&), String), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectProperty("Vector4", "float x", offsetof(Vector4, x_));
     engine->RegisterObjectProperty("Vector4", "float y", offsetof(Vector4, y_));
     engine->RegisterObjectProperty("Vector4", "float z", offsetof(Vector4, z_));
@@ -361,7 +361,7 @@ static void RegisterQuaternion(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Quaternion", "float DotProduct(const Quaternion&in) const", asMETHOD(Quaternion, DotProduct), asCALL_THISCALL);
     engine->RegisterObjectMethod("Quaternion", "Quaternion Nlerp(const Quaternion&in, float) const", asMETHOD(Quaternion, Nlerp), asCALL_THISCALL);
     engine->RegisterObjectMethod("Quaternion", "Quaternion Slerp(const Quaternion&in, float) const", asMETHOD(Quaternion, Slerp), asCALL_THISCALL);
-    engine->RegisterObjectMethod("Quaternion", "String ToString() const", asFUNCTIONPR(ToString, (const Quaternion&), std::string), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("Quaternion", "String ToString() const", asFUNCTIONPR(ToString, (const Quaternion&), String), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Quaternion", "Vector3 get_eulerAngles() const", asMETHOD(Quaternion, GetEulerAngles), asCALL_THISCALL);
     engine->RegisterObjectMethod("Quaternion", "float get_yaw() const", asMETHOD(Quaternion, GetYaw), asCALL_THISCALL);
     engine->RegisterObjectMethod("Quaternion", "float get_pitch() const", asMETHOD(Quaternion, GetPitch), asCALL_THISCALL);
@@ -604,7 +604,7 @@ static void RegisterColor(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Color", "Color opMul(float) const", asMETHOD(Color, operator *), asCALL_THISCALL);
     engine->RegisterObjectMethod("Color", "Color opAdd(const Color&in) const", asMETHOD(Color, operator +), asCALL_THISCALL);
     engine->RegisterObjectMethod("Color", "Color Lerp(const Color&in, float) const", asMETHOD(Color, Lerp), asCALL_THISCALL);
-    engine->RegisterObjectMethod("Color", "String ToString() const", asFUNCTIONPR(ToString, (const Color&), std::string), asCALL_CDECL_OBJLAST);
+    engine->RegisterObjectMethod("Color", "String ToString() const", asFUNCTIONPR(ToString, (const Color&), String), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("Color", "Vector3 get_rgb() const", asMETHOD(Color, GetRGB), asCALL_THISCALL);
     engine->RegisterObjectMethod("Color", "float get_intensity() const", asMETHOD(Color, GetIntensity), asCALL_THISCALL);
     engine->RegisterObjectProperty("Color", "float r", offsetof(Color, r_));

+ 2 - 1
Engine/Engine/Precompiled.h

@@ -23,6 +23,7 @@
 
 #pragma once
 
+#include "StringBase.h"
+
 #include <map>
-#include <string>
 #include <vector>

+ 11 - 11
Engine/Engine/ResourceAPI.cpp

@@ -32,12 +32,12 @@ void RegisterResource(asIScriptEngine* engine)
     RegisterResource<Resource>(engine, "Resource");
 }
 
-static Resource* ResourceCacheGetResource(const std::string& type, const std::string& name, ResourceCache* ptr)
+static Resource* ResourceCacheGetResource(const String& type, const String& name, ResourceCache* ptr)
 {
     return ptr->GetResource(ShortStringHash(type), name);
 }
 
-static File* ResourceCacheGetFile(const std::string& name, ResourceCache* ptr)
+static File* ResourceCacheGetFile(const String& name, ResourceCache* ptr)
 {
     SharedPtr<File> file = ptr->GetFile(name);
     // The shared pointer will go out of scope, so have to increment the reference count
@@ -47,32 +47,32 @@ static File* ResourceCacheGetFile(const std::string& name, ResourceCache* ptr)
     return file.GetPtr();
 }
 
-static void ResourceCacheReleaseResource(const std::string& type, const std::string& name, bool force, ResourceCache* ptr)
+static void ResourceCacheReleaseResource(const String& type, const String& name, bool force, ResourceCache* ptr)
 {
     ptr->ReleaseResource(ShortStringHash(type), name, force);
 }
 
-static void ResourceCacheReleaseResources(const std::string& type, bool force, ResourceCache* ptr)
+static void ResourceCacheReleaseResources(const String& type, bool force, ResourceCache* ptr)
 {
     ptr->ReleaseResources(ShortStringHash(type), force);
 }
 
-static void ResourceCacheReleaseResourcesPartial(const std::string& type, const std::string& partialName, bool force, ResourceCache* ptr)
+static void ResourceCacheReleaseResourcesPartial(const String& type, const String& partialName, bool force, ResourceCache* ptr)
 {
     ptr->ReleaseResources(ShortStringHash(type), partialName, force);
 }
 
-static void ResourceCacheSetMemoryBudget(const std::string& type, unsigned budget, ResourceCache* ptr)
+static void ResourceCacheSetMemoryBudget(const String& type, unsigned budget, ResourceCache* ptr)
 {
     ptr->SetMemoryBudget(ShortStringHash(type), budget);
 }
 
-static unsigned ResourceCacheGetMemoryBudget(const std::string& type, ResourceCache* ptr)
+static unsigned ResourceCacheGetMemoryBudget(const String& type, ResourceCache* ptr)
 {
     return ptr->GetMemoryBudget(ShortStringHash(type));
 }
 
-static unsigned ResourceCacheGetMemoryUse(const std::string& type, ResourceCache* ptr)
+static unsigned ResourceCacheGetMemoryUse(const String& type, ResourceCache* ptr)
 {
     return ptr->GetMemoryUse(ShortStringHash(type));
 }
@@ -90,13 +90,13 @@ static void RegisterResourceCache(asIScriptEngine* engine)
     engine->RegisterObjectMethod("ResourceCache", "bool AddManualResource(Resource@+)", asMETHOD(ResourceCache, AddManualResource), asCALL_THISCALL);
     engine->RegisterObjectMethod("ResourceCache", "void RemoveResourcePath(const String&in)", asMETHOD(ResourceCache, RemoveResourcePath), asCALL_THISCALL);
     engine->RegisterObjectMethod("ResourceCache", "void RemovePackageFile(PackageFile@+, bool, bool)", asMETHODPR(ResourceCache, RemovePackageFile, (PackageFile*, bool, bool), void), asCALL_THISCALL);
-    engine->RegisterObjectMethod("ResourceCache", "void RemovePackageFile(const String&in, bool, bool)", asMETHODPR(ResourceCache, RemovePackageFile, (const std::string&, bool, bool), void), asCALL_THISCALL);
+    engine->RegisterObjectMethod("ResourceCache", "void RemovePackageFile(const String&in, bool, bool)", asMETHODPR(ResourceCache, RemovePackageFile, (const String&, bool, bool), void), asCALL_THISCALL);
     engine->RegisterObjectMethod("ResourceCache", "void ReleaseResource(const String&in, const String&in, bool)", asFUNCTION(ResourceCacheReleaseResource), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("ResourceCache", "void ReleaseResources(const String&in, bool)", asFUNCTION(ResourceCacheReleaseResources), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("ResourceCache", "void ReleaseResources(const String&in, const String&in, bool)", asFUNCTION(ResourceCacheReleaseResourcesPartial), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("ResourceCache", "void ReleaseAllResources(bool)", asMETHOD(ResourceCache, ReleaseAllResources), asCALL_THISCALL);
     engine->RegisterObjectMethod("ResourceCache", "bool ReloadResource(Resource@+)", asMETHOD(ResourceCache, ReloadResource), asCALL_THISCALL);
-    engine->RegisterObjectMethod("ResourceCache", "bool Exists(const String&in) const", asMETHODPR(ResourceCache, Exists, (const std::string&) const, bool), asCALL_THISCALL);
+    engine->RegisterObjectMethod("ResourceCache", "bool Exists(const String&in) const", asMETHODPR(ResourceCache, Exists, (const String&) const, bool), asCALL_THISCALL);
     engine->RegisterObjectMethod("ResourceCache", "File@ GetFile(const String&in)", asFUNCTION(ResourceCacheGetFile), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("ResourceCache", "String GetPreferredResourcePath(const String&in)", asMETHOD(ResourceCache, GetPreferredResourcePath), asCALL_THISCALL);
     engine->RegisterObjectMethod("ResourceCache", "Resource@+ GetResource(const String&in, const String&in)", asFUNCTION(ResourceCacheGetResource), asCALL_CDECL_OBJLAST);
@@ -163,7 +163,7 @@ static XMLElement XMLElementGetNextElementDefault(XMLElement* ptr)
 
 static CScriptArray* XMLElementGetAttributeNames(XMLElement* ptr)
 {
-    return VectorToArray<std::string>(ptr->GetAttributeNames(), "Array<String>");
+    return VectorToArray<String>(ptr->GetAttributeNames(), "Array<String>");
 }
 
 static CScriptArray* XMLElementGetVariantVector(XMLElement* ptr)

+ 13 - 13
Engine/Engine/ScriptAPI.cpp

@@ -27,9 +27,9 @@
 #include "ScriptAPI.h"
 #include "ScriptFile.h"
 
-static const std::string noClassName;
+static const String noClassName;
 
-static bool ScriptFileExecute(const std::string& declaration, CScriptArray* srcParams, ScriptFile* ptr)
+static bool ScriptFileExecute(const String& declaration, CScriptArray* srcParams, ScriptFile* ptr)
 {
     if (!srcParams)
         return false;
@@ -43,7 +43,7 @@ static bool ScriptFileExecute(const std::string& declaration, CScriptArray* srcP
     return ptr->Execute(declaration, destParams);
 }
 
-static asIScriptObject* NodeCreateScriptObjectWithFile(ScriptFile* file, const std::string& className, Node* ptr)
+static asIScriptObject* NodeCreateScriptObjectWithFile(ScriptFile* file, const String& className, Node* ptr)
 {
     if (!file)
         return 0;
@@ -77,7 +77,7 @@ static void RegisterScriptFile(asIScriptEngine* engine)
     engine->RegisterGlobalFunction("ScriptFile@+ get_scriptFile()", asFUNCTION(GetScriptContextFile), asCALL_CDECL);
 }
 
-static asIScriptObject* NodeCreateScriptObject(const std::string& scriptFileName, const std::string& className, Node* ptr)
+static asIScriptObject* NodeCreateScriptObject(const String& scriptFileName, const String& className, Node* ptr)
 {
     ResourceCache* cache = GetScriptContext()->GetSubsystem<ResourceCache>();
     return NodeCreateScriptObjectWithFile(cache->GetResource<ScriptFile>(scriptFileName), className, ptr);
@@ -101,7 +101,7 @@ asIScriptObject* NodeGetScriptObject(Node* ptr)
     return 0;
 }
 
-asIScriptObject* NodeGetNamedScriptObject(const std::string& className, Node* ptr)
+asIScriptObject* NodeGetNamedScriptObject(const String& className, Node* ptr)
 {
     const std::vector<SharedPtr<Component> >& components = ptr->GetComponents();
     for (std::vector<SharedPtr<Component> >::const_iterator i = components.begin(); i != components.end(); ++i)
@@ -121,7 +121,7 @@ asIScriptObject* NodeGetNamedScriptObject(const std::string& className, Node* pt
     return 0;
 }
 
-static bool ScriptInstanceExecute(const std::string& declaration, CScriptArray* srcParams, ScriptInstance* ptr)
+static bool ScriptInstanceExecute(const String& declaration, CScriptArray* srcParams, ScriptInstance* ptr)
 {
     if (!srcParams)
         return false;
@@ -136,12 +136,12 @@ static bool ScriptInstanceExecute(const std::string& declaration, CScriptArray*
     return ptr->Execute(declaration, destParams);
 }
 
-static bool ScriptInstanceExecuteNoParams(const std::string& declaration, ScriptInstance* ptr)
+static bool ScriptInstanceExecuteNoParams(const String& declaration, ScriptInstance* ptr)
 {
     return ptr->Execute(declaration);
 }
 
-static void ScriptInstanceDelayedExecute(float delay, const std::string& declaration, CScriptArray* srcParams, ScriptInstance* ptr)
+static void ScriptInstanceDelayedExecute(float delay, const String& declaration, CScriptArray* srcParams, ScriptInstance* ptr)
 {
     if (!srcParams)
         return;
@@ -156,7 +156,7 @@ static void ScriptInstanceDelayedExecute(float delay, const std::string& declara
     ptr->DelayedExecute(delay, declaration, destParams);
 }
 
-static void ScriptInstanceDelayedExecuteNoParams(float delay, const std::string& declaration, ScriptInstance* ptr)
+static void ScriptInstanceDelayedExecuteNoParams(float delay, const String& declaration, ScriptInstance* ptr)
 {
     ptr->DelayedExecute(delay, declaration);
 }
@@ -198,7 +198,7 @@ static int SelfGetFixedUpdateFps()
         return 0;
 }
 
-static const std::string& SelfGetClassName()
+static const String& SelfGetClassName()
 {
     ScriptInstance* ptr = GetScriptContextInstance();
     if (ptr)
@@ -207,7 +207,7 @@ static const std::string& SelfGetClassName()
         return noClassName;
 }
 
-static void SelfDelayedExecute(float delay, const std::string& declaration, CScriptArray* srcParams)
+static void SelfDelayedExecute(float delay, const String& declaration, CScriptArray* srcParams)
 {
     ScriptInstance* ptr = GetScriptContextInstance();
     if ((!ptr) || (!srcParams))
@@ -223,7 +223,7 @@ static void SelfDelayedExecute(float delay, const std::string& declaration, CScr
     ptr->DelayedExecute(delay, declaration, destParams);
 }
 
-static void SelfDelayedExecuteNoParams(float delay, const std::string& declaration)
+static void SelfDelayedExecuteNoParams(float delay, const String& declaration)
 {
     ScriptInstance* ptr = GetScriptContextInstance();
     if (ptr)
@@ -254,7 +254,7 @@ static void RegisterScriptInstance(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Node", "ScriptObject@+ get_scriptObject() const", asFUNCTION(NodeGetScriptObject), asCALL_CDECL_OBJLAST);
     
     RegisterComponent<ScriptInstance>(engine, "ScriptInstance");
-    engine->RegisterObjectMethod("ScriptInstance", "bool CreateObject(ScriptFile@+, const String&in)", asMETHODPR(ScriptInstance, CreateObject, (ScriptFile*, const std::string&), bool), asCALL_THISCALL);
+    engine->RegisterObjectMethod("ScriptInstance", "bool CreateObject(ScriptFile@+, const String&in)", asMETHODPR(ScriptInstance, CreateObject, (ScriptFile*, const String&), bool), asCALL_THISCALL);
     engine->RegisterObjectMethod("ScriptInstance", "bool Execute(const String&in, const Array<Variant>@+)", asFUNCTION(ScriptInstanceExecute), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("ScriptInstance", "bool Execute(const String&in)", asFUNCTION(ScriptInstanceExecuteNoParams), asCALL_CDECL_OBJLAST);
     engine->RegisterObjectMethod("ScriptInstance", "void DelayedExecute(float, const String&in, const Array<Variant>@+)", asFUNCTION(ScriptInstanceDelayedExecute), asCALL_CDECL_OBJLAST);

+ 3 - 3
Engine/Engine/UIAPI.cpp

@@ -260,7 +260,7 @@ static void RegisterListView(asIScriptEngine* engine)
 static void RegisterText(asIScriptEngine* engine)
 {
     RegisterUIElement<Text>(engine, "Text");
-    engine->RegisterObjectMethod("Text", "bool SetFont(const String&in, int)", asMETHODPR(Text, SetFont, (const std::string&, int), bool), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Text", "bool SetFont(const String&in, int)", asMETHODPR(Text, SetFont, (const String&, int), bool), asCALL_THISCALL);
     engine->RegisterObjectMethod("Text", "bool SetFont(Font@+, int)", asMETHODPR(Text, SetFont, (Font*, int), bool), asCALL_THISCALL);
     engine->RegisterObjectMethod("Text", "void SetSelection(uint, uint)", asMETHOD(Text, SetSelection), asCALL_THISCALL);
     engine->RegisterObjectMethod("Text", "void ClearSelection()", asMETHOD(Text, ClearSelection), asCALL_THISCALL);
@@ -372,10 +372,10 @@ static void FileSelectorSetFilters(CScriptArray* filters, unsigned defaultIndex,
         return;
     
     unsigned numFilters = filters->GetSize();
-    std::vector<std::string> destFilters(numFilters);
+    std::vector<String> destFilters(numFilters);
     
     for (unsigned i = 0; i < numFilters; ++i)
-        destFilters[i] = *(static_cast<std::string*>(filters->At(i)));
+        destFilters[i] = *(static_cast<String*>(filters->At(i)));
     
     ptr->SetFilters(destFilters, defaultIndex);
 }

+ 4 - 4
Engine/Graphics/AnimatedModel.cpp

@@ -441,7 +441,7 @@ void AnimatedModel::RemoveAnimationState(Animation* animation)
         RemoveAnimationState(animation->GetNameHash());
 }
 
-void AnimatedModel::RemoveAnimationState(const std::string& animationName)
+void AnimatedModel::RemoveAnimationState(const String& animationName)
 {
     RemoveAnimationState(StringHash(animationName));
 }
@@ -519,7 +519,7 @@ void AnimatedModel::SetMorphWeight(unsigned index, float weight)
     }
 }
 
-void AnimatedModel::SetMorphWeight(const std::string& name, float weight)
+void AnimatedModel::SetMorphWeight(const String& name, float weight)
 {
     for (unsigned i = 0; i < morphs_.size(); ++i)
     {
@@ -567,7 +567,7 @@ float AnimatedModel::GetMorphWeight(unsigned index) const
     return index < morphs_.size() ? morphs_[index].weight_ : 0.0f;
 }
 
-float AnimatedModel::GetMorphWeight(const std::string& name) const
+float AnimatedModel::GetMorphWeight(const String& name) const
 {
     for (std::vector<ModelMorph>::const_iterator i = morphs_.begin(); i != morphs_.end(); ++i)
     {
@@ -600,7 +600,7 @@ AnimationState* AnimatedModel::GetAnimationState(Animation* animation) const
     return 0;
 }
 
-AnimationState* AnimatedModel::GetAnimationState(const std::string& animationName) const
+AnimationState* AnimatedModel::GetAnimationState(const String& animationName) const
 {
     for (std::vector<SharedPtr<AnimationState> >::const_iterator i = animationStates_.begin(); i != animationStates_.end(); ++i)
     {

+ 4 - 4
Engine/Graphics/AnimatedModel.h

@@ -74,7 +74,7 @@ public:
     /// Remove an animation by animation pointer
     void RemoveAnimationState(Animation* animation);
     /// Remove an animation by animation name
-    void RemoveAnimationState(const std::string& animationName);
+    void RemoveAnimationState(const String& animationName);
     /// Remove an animation by animation name hash
     void RemoveAnimationState(StringHash animationNameHash);
     /// Remove an animation by AnimationState pointer
@@ -88,7 +88,7 @@ public:
     /// Set vertex morph weight by index
     void SetMorphWeight(unsigned index, float weight);
     /// Set vertex morph weight by name
-    void SetMorphWeight(const std::string& name, float weight);
+    void SetMorphWeight(const String& name, float weight);
     /// Set vertex morph weight by name hash
     void SetMorphWeight(StringHash nameHash, float weight);
     /// Reset all vertex morphs to zero
@@ -103,7 +103,7 @@ public:
     /// Return animation state by animation pointer
     AnimationState* GetAnimationState(Animation* animation) const;
     /// Return animation state by animation name
-    AnimationState* GetAnimationState(const std::string& animationName) const;
+    AnimationState* GetAnimationState(const String& animationName) const;
     /// Return animation state by animation name hash
     AnimationState* GetAnimationState(const StringHash animationNameHash) const;
     /// Return animation state by index
@@ -121,7 +121,7 @@ public:
     /// Return vertex morph weight by index
     float GetMorphWeight(unsigned index) const;
     /// Return vertex morph weight by name
-    float GetMorphWeight(const std::string& name) const;
+    float GetMorphWeight(const String& name) const;
     /// Return vertex morph weight by name hash
     float GetMorphWeight(StringHash nameHash) const;
     /// Return whether is the master (first) animated model

+ 2 - 2
Engine/Graphics/Animation.cpp

@@ -150,7 +150,7 @@ bool Animation::Save(Serializer& dest)
     return true;
 }
 
-void Animation::SetAnimationName(const std::string& name)
+void Animation::SetAnimationName(const String& name)
 {
     animationName_ = name;
     animationNameHash_ = StringHash(name);
@@ -176,7 +176,7 @@ const AnimationTrack* Animation::GetTrack(unsigned index) const
     return index < tracks_.size() ? &tracks_[index] : 0;
 }
 
-const AnimationTrack* Animation::GetTrack(const std::string& name) const
+const AnimationTrack* Animation::GetTrack(const String& name) const
 {
     for (std::vector<AnimationTrack>::const_iterator i = tracks_.begin(); i != tracks_.end(); ++i)
     {

+ 5 - 5
Engine/Graphics/Animation.h

@@ -48,7 +48,7 @@ struct AnimationTrack
     void GetKeyFrameIndex(float time, unsigned& index) const;
     
     /// Bone name
-    std::string name_;
+    String name_;
     /// Bone name hash
     StringHash nameHash_;
     /// Bitmask of included data (position, rotation, scale)
@@ -80,14 +80,14 @@ public:
     virtual bool Save(Serializer& dest);
     
     /// Set animation name
-    void SetAnimationName(const std::string& name);
+    void SetAnimationName(const String& name);
     /// Set animation length
     void SetLength(float length);
     /// Set all animation tracks
     void SetTracks(const std::vector<AnimationTrack>& tracks);
     
     /// Return animation name
-    const std::string& GetAnimationName() const { return animationName_; }
+    const String& GetAnimationName() const { return animationName_; }
     /// Return animation name hash
     StringHash GetAnimationNameHash() const { return animationNameHash_; }
     /// Return animation length
@@ -99,13 +99,13 @@ public:
     /// Return animation track by index
     const AnimationTrack* GetTrack(unsigned index) const;
     /// Return animation track by bone name
-    const AnimationTrack* GetTrack(const std::string& name) const;
+    const AnimationTrack* GetTrack(const String& name) const;
     /// Return animation track by bone name hash
     const AnimationTrack* GetTrack(StringHash nameHash) const;
     
 private:
     /// Animation name
-    std::string animationName_;
+    String animationName_;
     /// Animation name hash
     StringHash animationNameHash_;
     /// Animation length

+ 29 - 29
Engine/Graphics/AnimationController.cpp

@@ -36,7 +36,7 @@
 
 #include "DebugNew.h"
 
-static std::string noBoneName;
+static String noBoneName;
 
 OBJECTTYPESTATIC(AnimationController);
 
@@ -165,7 +165,7 @@ void AnimationController::Update(float timeStep)
     }
 }
 
-bool AnimationController::Play(const std::string& name, int layer, bool looped, float fadeInTime)
+bool AnimationController::Play(const String& name, int layer, bool looped, float fadeInTime)
 {
     AnimatedModel* model = GetComponent<AnimatedModel>();
     if (!model)
@@ -207,13 +207,13 @@ bool AnimationController::Play(const std::string& name, int layer, bool looped,
     return true;
 }
 
-bool AnimationController::PlayExclusive(const std::string& name, int layer, bool looped, float fadeTime)
+bool AnimationController::PlayExclusive(const String& name, int layer, bool looped, float fadeTime)
 {
     FadeOthers(name, 0.0f, fadeTime);
     return Play(name, layer, looped, fadeTime);
 }
 
-bool AnimationController::Stop(const std::string& name, float fadeOutTime)
+bool AnimationController::Stop(const String& name, float fadeOutTime)
 {
     AnimatedModel* model = GetComponent<AnimatedModel>();
     if (!model)
@@ -305,7 +305,7 @@ void AnimationController::StopAll(float fadeOutTime)
     }
 }
 
-bool AnimationController::Fade(const std::string& name, float targetWeight, float fadeTime)
+bool AnimationController::Fade(const String& name, float targetWeight, float fadeTime)
 {
     unsigned index;
     AnimationState* state;
@@ -318,7 +318,7 @@ bool AnimationController::Fade(const std::string& name, float targetWeight, floa
     return true;
 }
 
-bool AnimationController::FadeOthers(const std::string& name, float targetWeight, float fadeTime)
+bool AnimationController::FadeOthers(const String& name, float targetWeight, float fadeTime)
 {
     unsigned index;
     AnimationState* state;
@@ -345,7 +345,7 @@ bool AnimationController::FadeOthers(const std::string& name, float targetWeight
     return true;
 }
 
-bool AnimationController::SetLayer(const std::string& name, int layer)
+bool AnimationController::SetLayer(const String& name, int layer)
 {
     AnimationState* state = FindAnimationState(name);
     if (!state)
@@ -355,7 +355,7 @@ bool AnimationController::SetLayer(const std::string& name, int layer)
     return true;
 }
 
-bool AnimationController::SetStartBone(const std::string& name, const std::string& startBoneName)
+bool AnimationController::SetStartBone(const String& name, const String& startBoneName)
 {
     AnimationState* state = FindAnimationState(name);
     if (!state)
@@ -367,7 +367,7 @@ bool AnimationController::SetStartBone(const std::string& name, const std::strin
     return true;
 }
 
-bool AnimationController::SetTime(const std::string& name, float time)
+bool AnimationController::SetTime(const String& name, float time)
 {
     AnimationState* state = FindAnimationState(name);
     if (!state)
@@ -377,7 +377,7 @@ bool AnimationController::SetTime(const std::string& name, float time)
     return true;
 }
 
-bool AnimationController::SetSpeed(const std::string& name, float speed)
+bool AnimationController::SetSpeed(const String& name, float speed)
 {
     unsigned index;
     AnimationState* state;
@@ -389,7 +389,7 @@ bool AnimationController::SetSpeed(const std::string& name, float speed)
     return true;
 }
 
-bool AnimationController::SetWeight(const std::string& name, float weight)
+bool AnimationController::SetWeight(const String& name, float weight)
 {
     unsigned index;
     AnimationState* state;
@@ -403,7 +403,7 @@ bool AnimationController::SetWeight(const std::string& name, float weight)
     return true;
 }
 
-bool AnimationController::SetLooped(const std::string& name, bool enable)
+bool AnimationController::SetLooped(const String& name, bool enable)
 {
     AnimationState* state = FindAnimationState(name);
     if (!state)
@@ -413,7 +413,7 @@ bool AnimationController::SetLooped(const std::string& name, bool enable)
     return true;
 }
 
-bool AnimationController::SetAutoFade(const std::string& name, float fadeOutTime)
+bool AnimationController::SetAutoFade(const String& name, float fadeOutTime)
 {
     unsigned index;
     AnimationState* state;
@@ -425,7 +425,7 @@ bool AnimationController::SetAutoFade(const std::string& name, float fadeOutTime
     return true;
 }
 
-bool AnimationController::IsPlaying(const std::string& name) const
+bool AnimationController::IsPlaying(const String& name) const
 {
     unsigned index;
     AnimationState* state;
@@ -433,7 +433,7 @@ bool AnimationController::IsPlaying(const std::string& name) const
     return index != M_MAX_UNSIGNED;
 }
 
-bool AnimationController::IsFadingIn(const std::string& name) const
+bool AnimationController::IsFadingIn(const String& name) const
 {
     unsigned index;
     AnimationState* state;
@@ -444,7 +444,7 @@ bool AnimationController::IsFadingIn(const std::string& name) const
     return (animations_[index].fadeTime_) && (animations_[index].targetWeight_ > state->GetWeight());
 }
 
-bool AnimationController::IsFadingOut(const std::string& name) const
+bool AnimationController::IsFadingOut(const String& name) const
 {
     unsigned index;
     AnimationState* state;
@@ -456,7 +456,7 @@ bool AnimationController::IsFadingOut(const std::string& name) const
         || ((!state->IsLooped()) && (state->GetTime() >= state->GetLength()) && (animations_[index].autoFadeTime_));
 }
 
-int AnimationController::GetLayer(const std::string& name) const
+int AnimationController::GetLayer(const String& name) const
 {
     AnimationState* state = FindAnimationState(name);
     if (!state)
@@ -464,7 +464,7 @@ int AnimationController::GetLayer(const std::string& name) const
     return state->GetLayer();
 }
 
-Bone* AnimationController::GetStartBone(const std::string& name) const
+Bone* AnimationController::GetStartBone(const String& name) const
 {
     AnimationState* state = FindAnimationState(name);
     if (!state)
@@ -472,37 +472,37 @@ Bone* AnimationController::GetStartBone(const std::string& name) const
     return state->GetStartBone();
 }
 
-const std::string& AnimationController::GetStartBoneName(const std::string& name) const
+const String& AnimationController::GetStartBoneName(const String& name) const
 {
     Bone* bone = GetStartBone(name);
     return bone ? bone->name_ : noBoneName;
 }
 
-float AnimationController::GetTime(const std::string& name) const
+float AnimationController::GetTime(const String& name) const
 {
     AnimationState* state = FindAnimationState(name);
     return state ? state->GetTime() : 0.0f;
 }
 
-float AnimationController::GetWeight(const std::string& name) const
+float AnimationController::GetWeight(const String& name) const
 {
     AnimationState* state = FindAnimationState(name);
     return state ? state->GetWeight() : 0.0f;
 }
 
-bool AnimationController::IsLooped(const std::string& name) const
+bool AnimationController::IsLooped(const String& name) const
 {
     AnimationState* state = FindAnimationState(name);
     return state ? state->IsLooped() : false;
 }
 
-float AnimationController::GetLength(const std::string& name) const
+float AnimationController::GetLength(const String& name) const
 {
     AnimationState* state = FindAnimationState(name);
     return state ? state->GetLength() : 0.0f;
 }
 
-float AnimationController::GetSpeed(const std::string& name) const
+float AnimationController::GetSpeed(const String& name) const
 {
     unsigned index;
     AnimationState* state;
@@ -512,7 +512,7 @@ float AnimationController::GetSpeed(const std::string& name) const
     return animations_[index].speed_;
 }
 
-float AnimationController::GetFadeTarget(const std::string& name) const
+float AnimationController::GetFadeTarget(const String& name) const
 {
     unsigned index;
     AnimationState* state;
@@ -522,7 +522,7 @@ float AnimationController::GetFadeTarget(const std::string& name) const
     return animations_[index].targetWeight_;
 }
 
-float AnimationController::GetFadeTime(const std::string& name) const
+float AnimationController::GetFadeTime(const String& name) const
 {
     unsigned index;
     AnimationState* state;
@@ -532,7 +532,7 @@ float AnimationController::GetFadeTime(const std::string& name) const
     return animations_[index].targetWeight_;
 }
 
-float AnimationController::GetAutoFade(const std::string& name) const
+float AnimationController::GetAutoFade(const String& name) const
 {
     unsigned index;
     AnimationState* state;
@@ -552,7 +552,7 @@ void AnimationController::OnNodeSet(Node* node)
     }
 }
 
-void AnimationController::FindAnimation(const std::string& name, unsigned& index, AnimationState*& state) const
+void AnimationController::FindAnimation(const String& name, unsigned& index, AnimationState*& state) const
 {
     AnimatedModel* model = GetComponent<AnimatedModel>();
     StringHash nameHash(name);
@@ -577,7 +577,7 @@ void AnimationController::FindAnimation(const std::string& name, unsigned& index
     }
 }
 
-AnimationState* AnimationController::FindAnimationState(const std::string& name) const
+AnimationState* AnimationController::FindAnimationState(const String& name) const
 {
     AnimatedModel* model = GetComponent<AnimatedModel>();
     return model ? model->GetAnimationState(name) : 0;

+ 28 - 28
Engine/Graphics/AnimationController.h

@@ -75,63 +75,63 @@ public:
     /// Update the animations. Is called from HandleScenePostUpdate()
     void Update(float timeStep);
     /// Play an animation and set full target weight. Name must be the full resource name. Return true on success
-    bool Play(const std::string& name, int layer, bool looped, float fadeInTime = 0.0f);
+    bool Play(const String& name, int layer, bool looped, float fadeInTime = 0.0f);
     /// Play an animation, set full target weight and fade out all other animations on the same layer. Name must be the full resource name. Return true on success
-    bool PlayExclusive(const std::string& name, int layer, bool looped, float fadeTime = 0.0f);
+    bool PlayExclusive(const String& name, int layer, bool looped, float fadeTime = 0.0f);
     /// Stop an animation. Zero fadetime is instant. Return true on success
-    bool Stop(const std::string& name, float fadeOutTime = 0.0f);
+    bool Stop(const String& name, float fadeOutTime = 0.0f);
     /// Stop all animations on a specific layer. Zero fadetime is instant
     void StopLayer(int layer, float fadeOutTime = 0.0f);
     /// Stop all animations. Zero fadetime is instant
     void StopAll(float fadeTime = 0.0f);
     /// Fade animation to target weight. Return true on success
-    bool Fade(const std::string& name, float targetWeight, float fadeTime);
+    bool Fade(const String& name, float targetWeight, float fadeTime);
     /// Fade other animations on the same layer to target weight. Return true on success
-    bool FadeOthers(const std::string& name, float targetWeight, float fadeTime);
+    bool FadeOthers(const String& name, float targetWeight, float fadeTime);
     
     /// Set animation blending layer priority. Return true on success
-    bool SetLayer(const std::string& name, int layer);
+    bool SetLayer(const String& name, int layer);
     /// Set animation start bone. Return true on success
-    bool SetStartBone(const std::string& name, const std::string& startBoneName);
+    bool SetStartBone(const String& name, const String& startBoneName);
     /// Set animation time position. Return true on success
-    bool SetTime(const std::string& name, float time);
+    bool SetTime(const String& name, float time);
     /// Set animation weight. Return true on success
-    bool SetWeight(const std::string& name, float weight);
+    bool SetWeight(const String& name, float weight);
     /// Set animation looping. Return true on success
-    bool SetLooped(const std::string& name, bool enable);
+    bool SetLooped(const String& name, bool enable);
     /// Set animation speed. Return true on success
-    bool SetSpeed(const std::string& name, float speed);
+    bool SetSpeed(const String& name, float speed);
     /// Set animation autofade on stop (non-looped animations only.) Zero time disables. Return true on success
-    bool SetAutoFade(const std::string& name, float fadeOutTime);
+    bool SetAutoFade(const String& name, float fadeOutTime);
     
     /// Return whether an animation is active
-    bool IsPlaying(const std::string& name) const;
+    bool IsPlaying(const String& name) const;
     /// Return whether an animation is fading in
-    bool IsFadingIn(const std::string& name) const;
+    bool IsFadingIn(const String& name) const;
     /// Return whether an animation is fading out
-    bool IsFadingOut(const std::string& name) const;
+    bool IsFadingOut(const String& name) const;
     /// Return animation blending layer
-    int GetLayer(const std::string& name) const;
+    int GetLayer(const String& name) const;
     /// Return animation start bone, or null if no such animation
-    Bone* GetStartBone(const std::string& name) const;
+    Bone* GetStartBone(const String& name) const;
     /// Return animation start bone name, or null if no such animation
-    const std::string& GetStartBoneName(const std::string& name) const;
+    const String& GetStartBoneName(const String& name) const;
     /// Return animation time position
-    float GetTime(const std::string& name) const;
+    float GetTime(const String& name) const;
     /// Return animation weight
-    float GetWeight(const std::string& name) const;
+    float GetWeight(const String& name) const;
     /// Return animation looping
-    bool IsLooped(const std::string& name) const;
+    bool IsLooped(const String& name) const;
     /// Return animation length
-    float GetLength(const std::string& name) const;
+    float GetLength(const String& name) const;
     /// Return animation speed
-    float GetSpeed(const std::string& name) const;
+    float GetSpeed(const String& name) const;
     /// Return animation fade target weight
-    float GetFadeTarget(const std::string& name) const;
+    float GetFadeTarget(const String& name) const;
     /// Return animation fade time
-    float GetFadeTime(const std::string& name) const;
+    float GetFadeTime(const String& name) const;
     /// Return animation autofade time
-    float GetAutoFade(const std::string& name) const;
+    float GetAutoFade(const String& name) const;
 
 protected:
     /// Handle node being assigned
@@ -139,9 +139,9 @@ protected:
 
 private:
     /// Find the internal index and animation state of an animation
-    void FindAnimation(const std::string& name, unsigned& index, AnimationState*& state) const;
+    void FindAnimation(const String& name, unsigned& index, AnimationState*& state) const;
     /// Find the animation state only
-    AnimationState* FindAnimationState(const std::string& name) const;
+    AnimationState* FindAnimationState(const String& name) const;
     /// Handle scene post-update event
     void HandleScenePostUpdate(StringHash eventType, VariantMap& eventData);
     

+ 16 - 16
Engine/Graphics/Graphics.cpp

@@ -146,7 +146,7 @@ static const D3DSTENCILOP d3dStencilOp[] =
     D3DSTENCILOP_DECR
 };
 
-static const std::string noParameter;
+static const String noParameter;
 static const DWORD windowStyle = WS_OVERLAPPEDWINDOW & ~WS_THICKFRAME & ~WS_MAXIMIZEBOX;
 
 static LRESULT CALLBACK wndProc(HWND wnd, UINT msg, WPARAM wParam, LPARAM lParam);
@@ -240,11 +240,11 @@ void Graphics::MessagePump()
     }
 }
 
-void Graphics::SetWindowTitle(const std::string& windowTitle)
+void Graphics::SetWindowTitle(const String& windowTitle)
 {
     windowTitle_ = windowTitle;
     if (impl_->window_)
-        SetWindowText(impl_->window_, windowTitle_.c_str());
+        SetWindowText(impl_->window_, windowTitle_.CString());
 }
 
 bool Graphics::SetMode(RenderMode mode, int width, int height, bool fullscreen, bool vsync, int multiSample)
@@ -1955,36 +1955,36 @@ VertexBuffer* Graphics::GetVertexBuffer(unsigned index) const
     return index < MAX_VERTEX_STREAMS ? vertexBuffer_[index] : 0;
 }
 
-VSParameter Graphics::GetVSParameter(const std::string& name)
+VSParameter Graphics::GetVSParameter(const String& name)
 {
-    std::map<std::string, VSParameter>::iterator i = vsParameters_.find(name);
+    std::map<String, VSParameter>::iterator i = vsParameters_.find(name);
     if (i != vsParameters_.end())
         return i->second;
     else
         return MAX_VS_PARAMETERS;
 }
 
-PSParameter Graphics::GetPSParameter(const std::string& name)
+PSParameter Graphics::GetPSParameter(const String& name)
 {
-    std::map<std::string, PSParameter>::iterator i = psParameters_.find(name);
+    std::map<String, PSParameter>::iterator i = psParameters_.find(name);
     if (i != psParameters_.end())
         return i->second;
     else
         return MAX_PS_PARAMETERS;
 }
 
-TextureUnit Graphics::GetTextureUnit(const std::string& name)
+TextureUnit Graphics::GetTextureUnit(const String& name)
 {
-    std::map<std::string, TextureUnit>::iterator i = textureUnits_.find(name);
+    std::map<String, TextureUnit>::iterator i = textureUnits_.find(name);
     if (i != textureUnits_.end())
         return i->second;
     else
         return MAX_TEXTURE_UNITS;
 }
 
-const std::string& Graphics::GetVSParameterName(VSParameter parameter)
+const String& Graphics::GetVSParameterName(VSParameter parameter)
 {
-    for (std::map<std::string, VSParameter>::iterator i = vsParameters_.begin(); i != vsParameters_.end(); ++i)
+    for (std::map<String, VSParameter>::iterator i = vsParameters_.begin(); i != vsParameters_.end(); ++i)
     {
         if (i->second == parameter)
             return i->first;
@@ -1992,9 +1992,9 @@ const std::string& Graphics::GetVSParameterName(VSParameter parameter)
     return noParameter;
 }
 
-const std::string& Graphics::GetPSParameterName(PSParameter parameter)
+const String& Graphics::GetPSParameterName(PSParameter parameter)
 {
-    for (std::map<std::string, PSParameter>::iterator i = psParameters_.begin(); i != psParameters_.end(); ++i)
+    for (std::map<String, PSParameter>::iterator i = psParameters_.begin(); i != psParameters_.end(); ++i)
     {
         if (i->second == parameter)
             return i->first;
@@ -2002,9 +2002,9 @@ const std::string& Graphics::GetPSParameterName(PSParameter parameter)
     return noParameter;
 }
 
-const std::string& Graphics::GetTextureUnitName(TextureUnit unit)
+const String& Graphics::GetTextureUnitName(TextureUnit unit)
 {
-    for (std::map<std::string, TextureUnit>::iterator i = textureUnits_.begin(); i != textureUnits_.end(); ++i)
+    for (std::map<String, TextureUnit>::iterator i = textureUnits_.begin(); i != textureUnits_.end(); ++i)
     {
         if (i->second == unit)
             return i->first;
@@ -2080,7 +2080,7 @@ bool Graphics::OpenWindow(int width, int height)
     
     RECT rect = {0, 0, width, height};
     AdjustWindowRect(&rect, windowStyle, false);
-    impl_->window_ = CreateWindow("D3DWindow", windowTitle_.c_str(), windowStyle, CW_USEDEFAULT, CW_USEDEFAULT,
+    impl_->window_ = CreateWindow("D3DWindow", windowTitle_.CString(), windowStyle, CW_USEDEFAULT, CW_USEDEFAULT,
         rect.right, rect.bottom, 0, 0, impl_->instance_, 0); 
     
     if (!impl_->window_)

+ 12 - 12
Engine/Graphics/Graphics.h

@@ -63,7 +63,7 @@ public:
     /// Pump operating system messages
     void MessagePump();
     /// Set window title
-    void SetWindowTitle(const std::string& windowTitle);
+    void SetWindowTitle(const String& windowTitle);
     /// Set screen mode. In deferred rendering modes multisampling means edge filtering instead of MSAA
     bool SetMode(RenderMode mode, int width, int height, bool fullscreen, bool vsync, int multiSample);
     /// Set screen resolution only
@@ -225,7 +225,7 @@ public:
     /// Return graphics implementation, which holds the actual Direct3D resources
     GraphicsImpl* GetImpl() const { return impl_; }
     /// Return window title
-    const std::string& GetWindowTitle() const { return windowTitle_; }
+    const String& GetWindowTitle() const { return windowTitle_; }
     /// Return rendering mode
     RenderMode GetRenderMode() const { return mode_; }
     /// Return window width
@@ -283,17 +283,17 @@ public:
     /// Return pixel shader
     PixelShader* GetPixelShader() const { return pixelShader_; }
     /// Return vertex shader parameter index by name
-    VSParameter GetVSParameter(const std::string& name);
+    VSParameter GetVSParameter(const String& name);
     /// Return pixel shader parameter index by name
-    PSParameter GetPSParameter(const std::string& name);
+    PSParameter GetPSParameter(const String& name);
     /// Return texture unit index by name
-    TextureUnit GetTextureUnit(const std::string& name);
+    TextureUnit GetTextureUnit(const String& name);
     /// Return vertex shader parameter name by index
-    const std::string& GetVSParameterName(VSParameter parameter);
+    const String& GetVSParameterName(VSParameter parameter);
     /// Return vertex pixel parameter name by index
-    const std::string& GetPSParameterName(PSParameter parameter);
+    const String& GetPSParameterName(PSParameter parameter);
     /// Return texture unit name by index
-    const std::string& GetTextureUnitName(TextureUnit unit);
+    const String& GetTextureUnitName(TextureUnit unit);
     /// Return vertex shader constant register by parameter index
     unsigned GetVSRegister(VSParameter param) { return vsRegisters_[param]; }
     /// Return pixel shader constant register by parameter index
@@ -399,7 +399,7 @@ private:
     /// Implementation
     GraphicsImpl* impl_;
     /// Window title
-    std::string windowTitle_;
+    String windowTitle_;
     /// Rendering mode
     RenderMode mode_;
     /// Window width
@@ -489,9 +489,9 @@ private:
     /// Pixel shader in use
     PixelShader* pixelShader_;
     /// Vertex shader parameter mappings
-    std::map<std::string, VSParameter> vsParameters_;
+    std::map<String, VSParameter> vsParameters_;
     /// Pixel shader parameter mappings
-    std::map<std::string, PSParameter> psParameters_;
+    std::map<String, PSParameter> psParameters_;
     /// Vertex shader constant register mappings
     unsigned vsRegisters_[MAX_VS_PARAMETERS];
     /// Pixel shader constant register mappings
@@ -505,7 +505,7 @@ private:
     /// "View texture" to prevent sampling the destination render target
     Texture* viewTexture_;
     /// Texture unit mappings
-    std::map<std::string, TextureUnit> textureUnits_;
+    std::map<String, TextureUnit> textureUnits_;
     /// Render targets in use
     RenderSurface* renderTarget_[MAX_RENDERTARGETS];
     /// Depth stencil buffer in use

+ 1 - 1
Engine/Graphics/Light.cpp

@@ -44,7 +44,7 @@ static const float DEFAULT_SHADOWQUANTIZE = 0.5f;
 static const float DEFAULT_SHADOWMINVIEW = 3.0f;
 static const float DEFAULT_SHADOWNEARFARRATIO = 0.002f;
 
-static const std::string typeNames[] =
+static const String typeNames[] =
 {
     "directional",
     "spot",

+ 7 - 7
Engine/Graphics/Material.cpp

@@ -38,7 +38,7 @@
 
 #include "DebugNew.h"
 
-static const std::string textureUnitNames[] =
+static const String textureUnitNames[] =
 {
     "diffuse",
     "normal",
@@ -50,7 +50,7 @@ static const std::string textureUnitNames[] =
     "lightspot" // Not defined by materials
 };
 
-static const std::string cullModeNames[] =
+static const String cullModeNames[] =
 {
     "none",
     "ccw",
@@ -142,7 +142,7 @@ bool Material::Load(Deserializer& source)
         TextureUnit unit = TU_DIFFUSE;
         if (textureElem.HasAttribute("unit"))
         {
-            std::string unitName = textureElem.GetStringLower("unit");
+            String unitName = textureElem.GetStringLower("unit");
             unit = (TextureUnit)GetStringListIndex(unitName, textureUnitNames, MAX_MATERIAL_TEXTURE_UNITS,
                 MAX_MATERIAL_TEXTURE_UNITS);
             if (unitName == "diff")
@@ -158,7 +158,7 @@ bool Material::Load(Deserializer& source)
         }
         if (unit != MAX_MATERIAL_TEXTURE_UNITS)
         {
-            std::string name = textureElem.GetString("name");
+            String name = textureElem.GetString("name");
             // Detect cube maps by file extension: they are defined by an XML file
             if (GetExtension(name) == ".xml")
                 SetTexture(unit, cache->GetResource<TextureCube>(name));
@@ -171,7 +171,7 @@ bool Material::Load(Deserializer& source)
     XMLElement parameterElem = rootElem.GetChildElement("parameter");
     while (parameterElem)
     {
-        std::string name = parameterElem.GetString("name");
+        String name = parameterElem.GetString("name");
         Vector4 value = parameterElem.GetVector("value");
         VSParameter vsParam = graphics->GetVSParameter(name);
         if (vsParam != MAX_VS_PARAMETERS)
@@ -355,7 +355,7 @@ void Material::ReleaseShaders()
     }
 }
 
-SharedPtr<Material> Material::Clone(const std::string& cloneName) const
+SharedPtr<Material> Material::Clone(const String& cloneName) const
 {
     SharedPtr<Material> ret(new Material(context_));
     
@@ -398,7 +398,7 @@ Texture* Material::GetTexture(TextureUnit unit) const
     return (unsigned)unit < textures_.size() ? textures_[unit] : (Texture*)0;
 }
 
-const std::string& Material::GetTextureUnitName(TextureUnit unit)
+const String& Material::GetTextureUnitName(TextureUnit unit)
 {
     return textureUnitNames[unit];
 }

+ 2 - 2
Engine/Graphics/Material.h

@@ -92,7 +92,7 @@ public:
     /// Reset all shader pointers
     void ReleaseShaders();
     /// Clone material
-    SharedPtr<Material> Clone(const std::string& cloneName = std::string()) const;
+    SharedPtr<Material> Clone(const String& cloneName = String()) const;
     /// Mark material for auxiliary view rendering
     void MarkForAuxView(unsigned frameNumber);
     
@@ -124,7 +124,7 @@ public:
     bool GetOcclusion() const { return occlusion_; }
     
     /// Return name for texture unit
-    static const std::string& GetTextureUnitName(TextureUnit unit);
+    static const String& GetTextureUnitName(TextureUnit unit);
     
 private:
     /// Re-evaluate occlusion rendering

+ 1 - 1
Engine/Graphics/Model.cpp

@@ -420,7 +420,7 @@ const ModelMorph* Model::GetMorph(unsigned index) const
     return index < morphs_.size() ? &morphs_[index] : 0;
 }
 
-const ModelMorph* Model::GetMorph(const std::string& name) const
+const ModelMorph* Model::GetMorph(const String& name) const
 {
     return GetMorph(StringHash(name));
 }

+ 2 - 2
Engine/Graphics/Model.h

@@ -49,7 +49,7 @@ struct VertexBufferMorph
 struct ModelMorph
 {
     /// Morph name
-    std::string name_;
+    String name_;
     /// Morph name hash
     StringHash nameHash_;
     /// Current morph weight
@@ -116,7 +116,7 @@ public:
     /// Return vertex morph by index
     const ModelMorph* GetMorph(unsigned index) const;
     /// Return vertex morph by name
-    const ModelMorph* GetMorph(const std::string& name) const;
+    const ModelMorph* GetMorph(const String& name) const;
     /// Return vertex morph by name hash
     const ModelMorph* GetMorph(StringHash nameHash) const;
     

+ 1 - 1
Engine/Graphics/ParticleEmitter.cpp

@@ -318,7 +318,7 @@ bool ParticleEmitter::LoadParameters(XMLFile* file)
     
     if (rootElem.HasChildElement("emittertype"))
     {
-        std::string type = rootElem.GetChildElement("emittertype").GetStringLower("value");
+        String type = rootElem.GetChildElement("emittertype").GetStringLower("value");
         if (type == "point")
             emitterType_ = EMITTER_POINT;
         else if (type == "box")

+ 11 - 11
Engine/Graphics/PixelShader.cpp

@@ -118,16 +118,16 @@ void PixelShader::LoadParameters()
     
     ClearParameters();
     
-    std::string shaderPath, shaderName, shaderExt;
+    String shaderPath, shaderName, shaderExt;
     SplitPath(GetName(), shaderPath, shaderName, shaderExt);
     
-    isSM3_ = (shaderExt.find('3') != std::string::npos);
+    isSM3_ = (shaderExt.Find('3') != String::NPOS);
     
     // Take the first part of the shader name (shader group)
-    size_t index = 2;
-    while ((index < shaderName.length()) && (shaderName[index] != '_'))
-        index++;
-    std::string shaderGroup = shaderName.substr(0, index);
+    unsigned index = 2;
+    while ((index < shaderName.Length()) && (shaderName[index] != '_'))
+        ++index;
+    String shaderGroup = shaderName.Substring(0, index);
     
     // Load shader information XML file
     XMLFile* file = cache->GetResource<XMLFile>(shaderPath + shaderGroup + ".xml");
@@ -141,7 +141,7 @@ void PixelShader::LoadParameters()
     
     while (paramElem)
     {
-        std::string name = paramElem.GetString("name");
+        String name = paramElem.GetString("name");
         PSParameter param = graphics_->GetPSParameter(name);
         if (param != MAX_PS_PARAMETERS)
             graphics_->SetPSRegister(param, paramElem.GetInt("index"));
@@ -155,15 +155,15 @@ void PixelShader::LoadParameters()
     XMLElement shaderElem = shadersElem.GetChildElement("shader");
     while (shaderElem)
     {
-        std::string name = shaderElem.GetString("name");
-        std::string type = shaderElem.GetStringLower("type");
+        String name = shaderElem.GetString("name");
+        String type = shaderElem.GetStringLower("type");
         
         if ((name == shaderName) && (type == "ps"))
         {
             XMLElement shaderParamElem = shaderElem.GetChildElement("parameter");
             while (shaderParamElem)
             {
-                std::string name = shaderParamElem.GetString("name");
+                String name = shaderParamElem.GetString("name");
                 PSParameter param = graphics_->GetPSParameter(name);
                 if (param != MAX_PS_PARAMETERS)
                     useParameter_[param] = true;
@@ -174,7 +174,7 @@ void PixelShader::LoadParameters()
             XMLElement textureElem = shaderElem.GetChildElement("textureunit");
             while (textureElem)
             {
-                std::string name = textureElem.GetString("name");
+                String name = textureElem.GetString("name");
                 TextureUnit unit = graphics_->GetTextureUnit(name);
                 if (unit != MAX_TEXTURE_UNITS)
                     useTextureUnit_[unit] = true;

+ 2 - 1
Engine/Graphics/Precompiled.h

@@ -23,8 +23,9 @@
 
 #pragma once
 
+#include "StringBase.h"
+
 #include <algorithm>
 #include <map>
 #include <set>
-#include <string>
 #include <vector>

+ 13 - 13
Engine/Graphics/Renderer.cpp

@@ -172,13 +172,13 @@ static const unsigned short spotLightIndexData[] =
     7, 6, 5
 };
 
-static const std::string hwVariations[] =
+static const String hwVariations[] =
 {
     "",
     "HW"
 };
 
-static const std::string geometryVSVariations[] =
+static const String geometryVSVariations[] =
 {
     "",
     "Skinned",
@@ -186,7 +186,7 @@ static const std::string geometryVSVariations[] =
     "Billboard"
 };
 
-static const std::string lightVSVariations[] =
+static const String lightVSVariations[] =
 {
     "",
     "Spot",
@@ -194,7 +194,7 @@ static const std::string lightVSVariations[] =
     "SpotShadow"
 };
 
-static const std::string deferredLightVSVariations[] =
+static const String deferredLightVSVariations[] =
 {
     "",
     "Dir",
@@ -202,7 +202,7 @@ static const std::string deferredLightVSVariations[] =
     "OrthoDir"
 };
 
-static const std::string lightPSVariations[] = 
+static const String lightPSVariations[] = 
 {
     "Dir",
     "DirSpec",
@@ -440,10 +440,10 @@ const Viewport& Renderer::GetViewport(unsigned index) const
     return index < viewports_.size() ? viewports_[index] : noViewport;
 }
 
-VertexShader* Renderer::GetVertexShader(const std::string& name, bool checkExists) const
+VertexShader* Renderer::GetVertexShader(const String& name, bool checkExists) const
 {
     // Check for extra underscore with no variations and remove
-    std::string fullName = Replace(shaderPath_ + name + vsFormat_, "_.", ".");
+    String fullName = (shaderPath_ + name + vsFormat_).Replace("_.", ".");
     if (checkExists)
     {
         if (!cache_->Exists(fullName))
@@ -452,10 +452,10 @@ VertexShader* Renderer::GetVertexShader(const std::string& name, bool checkExist
     return cache_->GetResource<VertexShader>(fullName);
 }
 
-PixelShader* Renderer::GetPixelShader(const std::string& name, bool checkExists) const
+PixelShader* Renderer::GetPixelShader(const String& name, bool checkExists) const
 {
     // Check for extra underscore with no variations and remove
-    std::string fullName = Replace(shaderPath_ + name + psFormat_, "_.", ".");
+    String fullName = (shaderPath_ + name + psFormat_).Replace("_.", ".");
     if (checkExists)
     {
         if (!cache_->Exists(fullName))
@@ -1057,13 +1057,13 @@ void Renderer::LoadPassShaders(Technique* technique, PassType pass, bool allowSh
     if (i == technique->passes_.end())
         return;
     
-    std::string vertexShaderName = i->second.GetVertexShaderName();
-    std::string pixelShaderName = i->second.GetPixelShaderName();
+    String vertexShaderName = i->second.GetVertexShaderName();
+    String pixelShaderName = i->second.GetPixelShaderName();
     
     // Check if the shader name is already a variation in itself
-    if (vertexShaderName.find('_') == std::string::npos)
+    if (vertexShaderName.Find('_') == String::NPOS)
         vertexShaderName += "_";
-    if (pixelShaderName.find('_') == std::string::npos)
+    if (pixelShaderName.Find('_') == String::NPOS)
         pixelShaderName += "_";
     
     // If ambient pass is not using REPLACE as the blend mode, and shadow maps are reused, do not load shadow variations

+ 6 - 6
Engine/Graphics/Renderer.h

@@ -239,9 +239,9 @@ public:
     /// Return the default spotlight attenuation texture
     Texture2D* GetDefaultLightSpot() const { return defaultLightSpot; }
     /// Return a vertex shader by name
-    VertexShader* GetVertexShader(const std::string& name, bool checkExists = false) const;
+    VertexShader* GetVertexShader(const String& name, bool checkExists = false) const;
     /// Return a pixel shader by name
-    PixelShader* GetPixelShader(const std::string& name, bool checkExists = false) const;
+    PixelShader* GetPixelShader(const String& name, bool checkExists = false) const;
     /// Return the frame update parameters
     const FrameInfo& GetFrameInfo() { return frame_; }
     
@@ -357,13 +357,13 @@ private:
     /// Techniques for which missing shader error has been displayed
     std::set<Technique*> shaderErrorDisplayed_;
     /// Vertex shader format
-    std::string vsFormat_;
+    String vsFormat_;
     /// Pixel shader format
-    std::string psFormat_;
+    String psFormat_;
     /// Base directory for shaders
-    std::string shaderPath_;
+    String shaderPath_;
     /// Light shader base name (deferred and prepass have different light shaders)
-    std::string lightShaderName_;
+    String lightShaderName_;
     /// Number of views
     unsigned numViews_;
     /// Number of shadow cameras

+ 1 - 1
Engine/Graphics/Skeleton.cpp

@@ -136,7 +136,7 @@ Bone* Skeleton::GetBone(unsigned index)
     return index < bones_.size() ? &bones_[index] : (Bone*)0;
 }
 
-Bone* Skeleton::GetBone(const std::string& name)
+Bone* Skeleton::GetBone(const String& name)
 {
     for (std::vector<Bone>::iterator i = bones_.begin(); i != bones_.end(); ++i)
     {

+ 2 - 2
Engine/Graphics/Skeleton.h

@@ -49,7 +49,7 @@ struct Bone
     }
     
     /// Bone name
-    std::string name_;
+    String name_;
     /// Bone name hash
     StringHash nameHash_;
     /// Parent bone index
@@ -105,7 +105,7 @@ public:
     /// Return bone by index
     Bone* GetBone(unsigned index);
     /// Return bone by name
-    Bone* GetBone(const std::string& boneName);
+    Bone* GetBone(const String& boneName);
     /// Return bone by name hash
     Bone* GetBone(StringHash boneNameHash);
     

+ 1 - 1
Engine/Graphics/StaticModel.h

@@ -77,7 +77,7 @@ public:
     
 protected:
     /// Construct with node flags, initial octant pointer and name
-    StaticModel(unsigned flags, Octant* octant, const std::string& name);
+    StaticModel(unsigned flags, Octant* octant, const String& name);
     /// Update the world bounding box
     virtual void OnWorldBoundingBoxUpdate();
     /// Set the bounding box

+ 9 - 9
Engine/Graphics/Technique.cpp

@@ -32,7 +32,7 @@
 #include "VertexShader.h"
 #include "XMLFile.h"
 
-static const std::string passNames[] =
+static const String passNames[] =
 {
     "deferred",
     "prepass",
@@ -44,7 +44,7 @@ static const std::string passNames[] =
     "shadow"
 };
 
-static const std::string blendModeNames[] =
+static const String blendModeNames[] =
 {
     "replace",
     "add",
@@ -55,7 +55,7 @@ static const std::string blendModeNames[] =
     "invdestalpha"
 };
 
-static const std::string CompareModeNames[] =
+static const String CompareModeNames[] =
 {
     "always",
     "equal",
@@ -109,13 +109,13 @@ void Pass::SetDepthWrite(bool enable)
     depthWrite_ = enable;
 }
 
-void Pass::SetVertexShader(const std::string& name)
+void Pass::SetVertexShader(const String& name)
 {
     vertexShaderName_ = name;
     ReleaseShaders();
 }
 
-void Pass::SetPixelShader(const std::string& name)
+void Pass::SetPixelShader(const String& name)
 {
     pixelShaderName_ = name;
     ReleaseShaders();
@@ -163,7 +163,7 @@ bool Technique::Load(Deserializer& source)
         PassType type = MAX_PASSES;
         if (passElem.HasAttribute("name"))
         {
-            std::string name = passElem.GetStringLower("name");
+            String name = passElem.GetStringLower("name");
             type = (PassType)GetStringListIndex(name, passNames, MAX_PASSES, MAX_PASSES);
             if (type == MAX_PASSES)
                 LOGERROR("Unknown pass " + name);
@@ -189,13 +189,13 @@ bool Technique::Load(Deserializer& source)
             
             if (passElem.HasAttribute("blend"))
             {
-                std::string blend = passElem.GetStringLower("blend");
+                String blend = passElem.GetStringLower("blend");
                 newPass.SetBlendMode((BlendMode)GetStringListIndex(blend, blendModeNames, MAX_BLENDMODES, BLEND_REPLACE));
             }
             
             if (passElem.HasAttribute("depthtest"))
             {
-                std::string depthTest = passElem.GetStringLower("depthtest");
+                String depthTest = passElem.GetStringLower("depthtest");
                 if (depthTest == "false")
                     newPass.SetDepthTestMode(CMP_ALWAYS);
                 else
@@ -253,7 +253,7 @@ void Technique::MarkShadersLoaded(unsigned frameNumber)
     shadersLoadedFrameNumber_ = frameNumber;
 }
 
-const std::string& Technique::GetPassName(PassType pass)
+const String& Technique::GetPassName(PassType pass)
 {
     return passNames[pass];
 }

+ 7 - 7
Engine/Graphics/Technique.h

@@ -51,9 +51,9 @@ public:
     /// Set depth write on/off
     void SetDepthWrite(bool enable);
     /// Set vertex shader name
-    void SetVertexShader(const std::string& name);
+    void SetVertexShader(const String& name);
     /// Set pixel shader name
-    void SetPixelShader(const std::string& name);
+    void SetPixelShader(const String& name);
     /// Reset shader pointers
     void ReleaseShaders();
     
@@ -70,9 +70,9 @@ public:
     /// Return depth write mode
     bool GetDepthWrite() const { return depthWrite_; }
     /// Return vertex shader name
-    const std::string& GetVertexShaderName() const { return vertexShaderName_; }
+    const String& GetVertexShaderName() const { return vertexShaderName_; }
     /// Return pixel shader name
-    const std::string& GetPixelShaderName() const { return pixelShaderName_; }
+    const String& GetPixelShaderName() const { return pixelShaderName_; }
     /// Return vertex shaders
     std::vector<SharedPtr<VertexShader> >& GetVertexShaders() { return vertexShaders_; }
     /// Return pixel shaders
@@ -92,9 +92,9 @@ private:
     /// Depth write mode
     bool depthWrite_;
     /// Vertex shader name
-    std::string vertexShaderName_;
+    String vertexShaderName_;
     /// Pixel shader name
-    std::string pixelShaderName_;
+    String pixelShaderName_;
     /// Vertex shaders
     std::vector<SharedPtr<VertexShader> > vertexShaders_;
     /// Pixel shaders
@@ -155,7 +155,7 @@ public:
     unsigned GetShadersLoadedFrameNumber() const { return shadersLoadedFrameNumber_; }
     
     /// Return name for pass
-    static const std::string& GetPassName(PassType pass);
+    static const String& GetPassName(PassType pass);
     
 private:
     /// Require Shader Model 3 flag

+ 9 - 9
Engine/Graphics/Texture.cpp

@@ -34,7 +34,7 @@
 
 #include "DebugNew.h"
 
-static const std::string addressModeNames[] =
+static const String addressModeNames[] =
 {
     "wrap",
     "mirror",
@@ -42,7 +42,7 @@ static const std::string addressModeNames[] =
     "border"
 };
 
-static const std::string filterModeNames[] =
+static const String filterModeNames[] =
 {
     "nearest",
     "bilinear",
@@ -142,9 +142,9 @@ void Texture::LoadParameters()
 {
     ResourceCache* cache = GetSubsystem<ResourceCache>();
     
-    std::string texPath, texName, texExt;
+    String texPath, texName, texExt;
     SplitPath(GetName(), texPath, texName, texExt);
-    std::string xmlName = texPath + texName + ".xml";
+    String xmlName = texPath + texName + ".xml";
     
     if (cache->Exists(xmlName))
     {
@@ -163,15 +163,15 @@ void Texture::LoadParameters(XMLFile* file)
     
     while (paramElem)
     {
-        std::string name = paramElem.GetName();
+        String name = paramElem.GetName();
         
         if (name == "address")
         {
-            std::string coord = paramElem.GetStringLower("coord");
-            if (coord.length() >= 1)
+            String coord = paramElem.GetStringLower("coord");
+            if (coord.Length() >= 1)
             {
                 TextureCoordinate coordIndex = (TextureCoordinate)(coord[0] - 'u');
-                std::string mode = paramElem.GetStringLower("mode");
+                String mode = paramElem.GetStringLower("mode");
                 SetAddressMode(coordIndex, (TextureAddressMode)GetStringListIndex(mode, addressModeNames, MAX_ADDRESSMODES,
                     ADDRESS_WRAP));
             }
@@ -182,7 +182,7 @@ void Texture::LoadParameters(XMLFile* file)
         
         if (name == "filter")
         {
-            std::string mode = paramElem.GetStringLower("mode");
+            String mode = paramElem.GetStringLower("mode");
             SetFilterMode((TextureFilterMode)GetStringListIndex(mode, filterModeNames, MAX_FILTERMODES, FILTER_DEFAULT));
         }
         

+ 4 - 4
Engine/Graphics/TextureCube.cpp

@@ -164,7 +164,7 @@ bool TextureCube::Load(Deserializer& source)
     // If over the texture budget, see if materials can be freed to allow textures to be freed
     CheckTextureBudget(GetTypeStatic());
     
-    std::string texPath, texName, texExt;
+    String texPath, texName, texExt;
     SplitPath(GetName(), texPath, texName, texExt);
     
     SharedPtr<XMLFile> xml(new XMLFile(context_));
@@ -178,12 +178,12 @@ bool TextureCube::Load(Deserializer& source)
     unsigned faces = 0;
     while ((faceElem) && (faces < MAX_CUBEMAP_FACES))
     {
-        std::string name = faceElem.GetString("name");
+        String name = faceElem.GetString("name");
         
-        std::string faceTexPath, faceTexName, faceTexExt;
+        String faceTexPath, faceTexName, faceTexExt;
         SplitPath(name, faceTexPath, faceTexName, faceTexExt);
         // If path is empty, add the XML file path
-        if (faceTexPath.empty())
+        if (faceTexPath.Empty())
             name = texPath + name;
         
         SharedPtr<Image> image(cache->GetResource<Image>(name));

+ 1 - 1
Engine/Graphics/VertexBuffer.cpp

@@ -46,7 +46,7 @@ const unsigned VertexBuffer::elementSize[] =
     4 * sizeof(float) // Instancematrix3
 };
 
-const std::string VertexBuffer::elementName[] = 
+const String VertexBuffer::elementName[] = 
 {
     "Position",
     "Normal",

+ 1 - 1
Engine/Graphics/VertexBuffer.h

@@ -95,7 +95,7 @@ public:
     /// Vertex element sizes
     static const unsigned elementSize[];
     /// Vertex element names
-    static const std::string elementName[];
+    static const String elementName[];
     
 private:
     /// Update offsets of vertex elements

+ 10 - 10
Engine/Graphics/VertexShader.cpp

@@ -119,16 +119,16 @@ void VertexShader::LoadParameters()
     
     ClearParameters();
     
-    std::string shaderPath, shaderName, shaderExt;
+    String shaderPath, shaderName, shaderExt;
     SplitPath(GetName(), shaderPath, shaderName, shaderExt);
     
-    isSM3_ = (shaderExt.find('3') != std::string::npos);
+    isSM3_ = (shaderExt.Find('3') != String::NPOS);
     
     // Take the first part of the shader name (shader group)
-    size_t index = 2;
-    while ((index < shaderName.length()) && (shaderName[index] != '_'))
-        index++;
-    std::string shaderGroup = shaderName.substr(0, index);
+    unsigned index = 2;
+    while ((index < shaderName.Length()) && (shaderName[index] != '_'))
+        ++index;
+    String shaderGroup = shaderName.Substring(0, index);
     
     // Load shader information XML file
     XMLFile* file = cache->GetResource<XMLFile>(shaderPath + shaderGroup + ".xml");
@@ -142,7 +142,7 @@ void VertexShader::LoadParameters()
     
     while (paramElem)
     {
-        std::string name = paramElem.GetString("name");
+        String name = paramElem.GetString("name");
         VSParameter param = graphics_->GetVSParameter(name);
         if (param != MAX_VS_PARAMETERS)
             graphics_->SetVSRegister(param, paramElem.GetInt("index"));
@@ -156,15 +156,15 @@ void VertexShader::LoadParameters()
     XMLElement shaderElem = shadersElem.GetChildElement("shader");
     while (shaderElem)
     {
-        std::string name = shaderElem.GetString("name");
-        std::string type = shaderElem.GetStringLower("type");
+        String name = shaderElem.GetString("name");
+        String type = shaderElem.GetStringLower("type");
         
         if ((name == shaderName) && (type == "vs"))
         {
             XMLElement shaderParamElem = shaderElem.GetChildElement("parameter");
             while (shaderParamElem)
             {
-                std::string name = shaderParamElem.GetString("name");
+                String name = shaderParamElem.GetString("name");
                 VSParameter param = graphics_->GetVSParameter(name);
                 if (param != MAX_VS_PARAMETERS)
                     useParameter_[param] = true;

+ 2 - 2
Engine/Graphics/View.cpp

@@ -51,7 +51,7 @@
 
 #include "StringUtils.h"
 
-static const std::string aaVariation[] = {
+static const String aaVariation[] = {
     "",
     "Ortho"
 };
@@ -1051,7 +1051,7 @@ void View::RenderBatchesDeferred()
         graphics_->SetPixelShaderParameter(PSP_VIEWPROJ, camera_->GetProjection(false) * lastCameraView_);
         
         unsigned index = camera_->IsOrthographic() ? 1 : 0;
-        std::string shaderName = "TemporalAA_" + aaVariation[index];
+        String shaderName = "TemporalAA_" + aaVariation[index];
         
         renderer_->DrawFullScreenQuad(*camera_, renderer_->GetVertexShader(shaderName),
             renderer_->GetPixelShader(shaderName), false);

+ 9 - 9
Engine/IO/Deserializer.cpp

@@ -26,7 +26,7 @@
 
 #include "DebugNew.h"
 
-static const std::string noName;
+static const String noName;
 static const float invQ = 1.0f / 32767.0f;
 
 Deserializer::Deserializer() :
@@ -45,7 +45,7 @@ Deserializer::~Deserializer()
 {
 }
 
-const std::string& Deserializer::GetName() const
+const String& Deserializer::GetName() const
 {
     return noName;
 }
@@ -220,9 +220,9 @@ BoundingBox Deserializer::ReadBoundingBox()
     return ret;
 }
 
-std::string Deserializer::ReadString()
+String Deserializer::ReadString()
 {
-    std::string ret;
+    String ret;
     
     for (;;)
     {
@@ -236,11 +236,11 @@ std::string Deserializer::ReadString()
     return ret;
 }
 
-std::string Deserializer::ReadID()
+String Deserializer::ReadID()
 {
-    std::string ret;
+    String ret;
     
-    ret.resize(4);
+    ret.Resize(4);
     Read(&ret[0], 4);
     return ret;
 }
@@ -402,9 +402,9 @@ unsigned Deserializer::ReadVLE()
     return ret;
 }
 
-std::string Deserializer::ReadLine()
+String Deserializer::ReadLine()
 {
-    std::string ret;
+    String ret;
     
     while (!IsEof())
     {

+ 4 - 4
Engine/IO/Deserializer.h

@@ -43,7 +43,7 @@ public:
     /// Set position from the beginning of the stream
     virtual unsigned Seek(unsigned position) = 0;
     /// Return name of the stream
-    virtual const std::string& GetName() const;
+    virtual const String& GetName() const;
     /// Return a checksum if applicable
     virtual unsigned GetChecksum();
     /// Return current position
@@ -92,9 +92,9 @@ public:
     /// Read a BoundingBox
     BoundingBox ReadBoundingBox();
     /// Read a null-terminated string
-    std::string ReadString();
+    String ReadString();
     /// Read a four-letter ID
-    std::string ReadID();
+    String ReadID();
     /// Read a 32-bit StringHash
     StringHash ReadStringHash();
     /// Read a 16-bit ShortStringHash
@@ -116,7 +116,7 @@ public:
     /// Read a variable-length encoded unsigned integer, which can use 29 bits maximum
     unsigned ReadVLE();
     /// Read a text line
-    std::string ReadLine();
+    String ReadLine();
     
 protected:
     /// Stream position

+ 7 - 7
Engine/IO/File.cpp

@@ -50,7 +50,7 @@ File::File(Context* context) :
 {
 }
 
-File::File(Context* context, const std::string& fileName, FileMode mode) :
+File::File(Context* context, const String& fileName, FileMode mode) :
     Object(context),
     mode_(FILE_READ),
     handle_(0),
@@ -60,7 +60,7 @@ File::File(Context* context, const std::string& fileName, FileMode mode) :
     Open(fileName, mode);
 }
 
-File::File(Context* context, PackageFile* package, const std::string& fileName) :
+File::File(Context* context, PackageFile* package, const String& fileName) :
     Object(context),
     mode_(FILE_READ),
     handle_(0),
@@ -75,7 +75,7 @@ File::~File()
     Close();
 }
 
-bool File::Open(const std::string& fileName, FileMode mode)
+bool File::Open(const String& fileName, FileMode mode)
 {
     Close();
     
@@ -86,7 +86,7 @@ bool File::Open(const std::string& fileName, FileMode mode)
         return false;
     }
     
-    handle_ = fopen(GetNativePath(fileName).c_str(), openMode[mode]);
+    handle_ = fopen(GetNativePath(fileName).CString(), openMode[mode]);
     if (!handle_)
     {
         LOGERROR("Could not open file " + fileName);
@@ -107,7 +107,7 @@ bool File::Open(const std::string& fileName, FileMode mode)
     return true;
 }
 
-bool File::Open(PackageFile* package, const std::string& fileName)
+bool File::Open(PackageFile* package, const String& fileName)
 {
     Close();
     
@@ -118,7 +118,7 @@ bool File::Open(PackageFile* package, const std::string& fileName)
     if (!entry)
         return false;
     
-    handle_ = fopen(GetNativePath(package->GetName()).c_str(), "rb");
+    handle_ = fopen(GetNativePath(package->GetName()).CString(), "rb");
     if (!handle_)
     {
         LOGERROR("Could not open package file " + fileName);
@@ -248,7 +248,7 @@ void File::Close()
     }
 }
 
-void File::SetName(const std::string& name)
+void File::SetName(const String& name)
 {
     fileName_ = name;
 }

+ 7 - 7
Engine/IO/File.h

@@ -46,9 +46,9 @@ public:
     /// Construct
     File(Context* context);
     /// Construct and open
-    File(Context* context, const std::string& fileName, FileMode mode = FILE_READ);
+    File(Context* context, const String& fileName, FileMode mode = FILE_READ);
     /// Construct and open from a package file
-    File(Context* context, PackageFile* package, const std::string& fileName);
+    File(Context* context, PackageFile* package, const String& fileName);
     /// Destruct. Close the file if open
     virtual ~File();
     
@@ -59,18 +59,18 @@ public:
     /// Write bytes to the file
     virtual unsigned Write(const void* data, unsigned size);
     /// Return the file name
-    virtual const std::string& GetName() const { return fileName_; }
+    virtual const String& GetName() const { return fileName_; }
     /// Return a checksum of the file contents, using the SDBM hash algorithm
     virtual unsigned GetChecksum();
     
     /// Open a filesystem file. Return true if successful
-    bool Open(const std::string& fileName, FileMode mode = FILE_READ);
+    bool Open(const String& fileName, FileMode mode = FILE_READ);
     /// Open from within a package file. Return true if successful
-    bool Open(PackageFile* package, const std::string& fileName);
+    bool Open(PackageFile* package, const String& fileName);
     /// Close the file
     void Close();
     /// Change the file name. Used by the resource system
-    void SetName(const std::string& name);
+    void SetName(const String& name);
     
     /// Return the open mode
     FileMode GetMode() const { return mode_; }
@@ -82,7 +82,7 @@ public:
     
 private:
     /// File name
-    std::string fileName_;
+    String fileName_;
     /// Open mode
     FileMode mode_;
     /// File handle

+ 88 - 86
Engine/IO/FileSystem.cpp

@@ -54,14 +54,14 @@ FileSystem::~FileSystem()
 }
 
 
-bool FileSystem::SetCurrentDir(const std::string& pathName)
+bool FileSystem::SetCurrentDir(const String& pathName)
 {
     if (!CheckAccess(pathName))
     {
         LOGERROR("Access denied to " + pathName);
         return false;
     }
-    if (SetCurrentDirectory(GetNativePath(pathName, true).c_str()) == FALSE)
+    if (SetCurrentDirectory(GetNativePath(pathName, true).CString()) == FALSE)
     {
         LOGERROR("Failed to change directory to " + pathName);
         return false;
@@ -69,7 +69,7 @@ bool FileSystem::SetCurrentDir(const std::string& pathName)
     return true;
 }
 
-bool FileSystem::CreateDir(const std::string& pathName)
+bool FileSystem::CreateDir(const String& pathName)
 {
     if (!CheckAccess(pathName))
     {
@@ -77,7 +77,7 @@ bool FileSystem::CreateDir(const std::string& pathName)
         return false;
     }
     
-    bool success = (CreateDirectory(GetNativePath(RemoveTrailingSlash(pathName), true).c_str(), 0) == TRUE) || (GetLastError() == ERROR_ALREADY_EXISTS);
+    bool success = (CreateDirectory(GetNativePath(RemoveTrailingSlash(pathName), true).CString(), 0) == TRUE) || (GetLastError() == ERROR_ALREADY_EXISTS);
     if (success)
         LOGDEBUG("Created directory " + pathName);
     else
@@ -86,10 +86,10 @@ bool FileSystem::CreateDir(const std::string& pathName)
     return success;
 }
 
-int FileSystem::SystemCommand(const std::string& commandLine)
+int FileSystem::SystemCommand(const String& commandLine)
 {
     if (allowedPaths_.empty())
-        return system(commandLine.c_str());
+        return system(commandLine.CString());
     else
     {
         LOGERROR("Executing an external command is not allowed");
@@ -97,19 +97,19 @@ int FileSystem::SystemCommand(const std::string& commandLine)
     }
 }
 
-int FileSystem::SystemRun(const std::string& fileName, const std::vector<std::string>& arguments)
+int FileSystem::SystemRun(const String& fileName, const std::vector<String>& arguments)
 {
     if (allowedPaths_.empty())
     {
-        std::string fixedFileName = GetNativePath(fileName, true);
+        String fixedFileName = GetNativePath(fileName, true);
         
         std::vector<const char*> argPtrs;
-        argPtrs.push_back(fixedFileName.c_str());
+        argPtrs.push_back(fixedFileName.CString());
         for (unsigned i = 0; i < arguments.size(); ++i)
-            argPtrs.push_back(arguments[i].c_str());
+            argPtrs.push_back(arguments[i].CString());
         argPtrs.push_back(0);
         
-        return _spawnv(_P_WAIT, fixedFileName.c_str(), &argPtrs[0]);
+        return _spawnv(_P_WAIT, fixedFileName.CString(), &argPtrs[0]);
     }
     else
     {
@@ -118,7 +118,7 @@ int FileSystem::SystemRun(const std::string& fileName, const std::vector<std::st
     }
 }
 
-bool FileSystem::SystemOpen(const std::string& fileName, const std::string& mode)
+bool FileSystem::SystemOpen(const String& fileName, const String& mode)
 {
     if (allowedPaths_.empty())
     {
@@ -128,7 +128,8 @@ bool FileSystem::SystemOpen(const std::string& fileName, const std::string& mode
             return false;
         }
         
-        bool success = (int)ShellExecute(0, !mode.empty() ? (char*)mode.c_str() : 0, (char*)GetNativePath(fileName, true).c_str(), 0, 0, SW_SHOW) > 32;
+        bool success = (int)ShellExecute(0, !mode.Empty() ? (char*)mode.CString() : 0,
+            (char*)GetNativePath(fileName, true).CString(), 0, 0, SW_SHOW) > 32;
         if (!success)
             LOGERROR("Failed to open " + fileName + " externally");
         return success;
@@ -140,7 +141,7 @@ bool FileSystem::SystemOpen(const std::string& fileName, const std::string& mode
     }
 }
 
-bool FileSystem::Copy(const std::string& srcFileName, const std::string& destFileName)
+bool FileSystem::Copy(const String& srcFileName, const String& destFileName)
 {
     if (!CheckAccess(GetPath(srcFileName)))
     {
@@ -167,7 +168,7 @@ bool FileSystem::Copy(const std::string& srcFileName, const std::string& destFil
     return (bytesRead == fileSize) && (bytesWritten == fileSize);
 }
 
-bool FileSystem::Rename(const std::string& srcFileName, const std::string& destFileName)
+bool FileSystem::Rename(const String& srcFileName, const String& destFileName)
 {
     if (!CheckAccess(GetPath(srcFileName)))
     {
@@ -180,10 +181,10 @@ bool FileSystem::Rename(const std::string& srcFileName, const std::string& destF
         return false;
     }
     
-    return rename(GetNativePath(srcFileName).c_str(), GetNativePath(destFileName).c_str()) == 0;
+    return rename(GetNativePath(srcFileName).CString(), GetNativePath(destFileName).CString()) == 0;
 }
 
-bool FileSystem::Delete(const std::string& fileName)
+bool FileSystem::Delete(const String& fileName)
 {
     if (!CheckAccess(GetPath(fileName)))
     {
@@ -191,33 +192,33 @@ bool FileSystem::Delete(const std::string& fileName)
         return false;
     }
     
-    return remove(GetNativePath(fileName).c_str()) == 0;
+    return remove(GetNativePath(fileName).CString()) == 0;
 }
 
 
-std::string FileSystem::GetCurrentDir()
+String FileSystem::GetCurrentDir()
 {
     char path[MAX_PATH];
     GetCurrentDirectory(MAX_PATH, path);
-    return AddTrailingSlash(std::string(path));
+    return AddTrailingSlash(String(path));
 }
 
-bool FileSystem::CheckAccess(const std::string& pathName)
+bool FileSystem::CheckAccess(const String& pathName)
 {
-    std::string fixedPath = AddTrailingSlash(pathName);
+    String fixedPath = AddTrailingSlash(pathName);
     
     // If no allowed directories defined, succeed always
     if (allowedPaths_.empty())
         return true;
     
     // If there is any attempt to go to a parent directory, disallow
-    if (fixedPath.find("..") != std::string::npos)
+    if (fixedPath.Find("..") != String::NPOS)
         return false;
     
     // Check if the path is a partial match of any of the allowed directories
-    for (std::set<std::string>::const_iterator i = allowedPaths_.begin(); i != allowedPaths_.end(); ++i)
+    for (std::set<String>::const_iterator i = allowedPaths_.begin(); i != allowedPaths_.end(); ++i)
     {
-        if (fixedPath.find(*i) == 0)
+        if (fixedPath.Find(*i) == 0)
             return true;
     }
     
@@ -225,92 +226,92 @@ bool FileSystem::CheckAccess(const std::string& pathName)
     return false;
 }
 
-bool FileSystem::FileExists(const std::string& fileName)
+bool FileSystem::FileExists(const String& fileName)
 {
     if (!CheckAccess(GetPath(fileName)))
         return false;
     
-    std::string fixedName = GetNativePath(RemoveTrailingSlash(fileName), true);
-    DWORD attributes = GetFileAttributes(fixedName.c_str());
+    String fixedName = GetNativePath(RemoveTrailingSlash(fileName), true);
+    DWORD attributes = GetFileAttributes(fixedName.CString());
     if ((attributes == INVALID_FILE_ATTRIBUTES) || (attributes & FILE_ATTRIBUTE_DIRECTORY))
         return false;
     
     return true;
 }
 
-bool FileSystem::DirExists(const std::string& pathName)
+bool FileSystem::DirExists(const String& pathName)
 {
     if (!CheckAccess(pathName))
         return false;
     
-    std::string fixedName = GetNativePath(RemoveTrailingSlash(pathName), true);
-    DWORD attributes = GetFileAttributes(fixedName.c_str());
+    String fixedName = GetNativePath(RemoveTrailingSlash(pathName), true);
+    DWORD attributes = GetFileAttributes(fixedName.CString());
     if ((attributes == INVALID_FILE_ATTRIBUTES) || (!(attributes & FILE_ATTRIBUTE_DIRECTORY)))
         return false;
     
     return true;
 }
 
-void FileSystem::ScanDir(std::vector<std::string>& result, const std::string& pathName, const std::string& filter, unsigned flags, bool recursive)
+void FileSystem::ScanDir(std::vector<String>& result, const String& pathName, const String& filter, unsigned flags, bool recursive)
 {
     result.clear();
     
     if (CheckAccess(pathName))
     {
-        std::string initialPath = AddTrailingSlash(pathName);
+        String initialPath = AddTrailingSlash(pathName);
         ScanDirInternal(result, initialPath, initialPath, filter, flags, recursive);
     }
 }
 
-std::string FileSystem::GetProgramDir()
+String FileSystem::GetProgramDir()
 {
     char exeName[MAX_PATH];
     exeName[0] = 0;
     GetModuleFileName(0, exeName, MAX_PATH);
-    return GetPath(std::string(exeName));
+    return GetPath(String(exeName));
 }
 
-std::string FileSystem::GetUserDocumentsDir()
+String FileSystem::GetUserDocumentsDir()
 {
     char pathName[MAX_PATH];
     pathName[0] = 0;
     SHGetSpecialFolderPath(0, pathName, CSIDL_PERSONAL, 0);
-    return AddTrailingSlash(std::string(pathName));
+    return AddTrailingSlash(String(pathName));
 }
 
-std::string FileSystem::GetSystemFontDir()
+String FileSystem::GetSystemFontDir()
 {
     char pathName[MAX_PATH];
     if (!ExpandEnvironmentStrings("%WinDir%", pathName, MAX_PATH))
-        return std::string();
-    return AddTrailingSlash(std::string(pathName)) + "Fonts";
+        return String();
+    return AddTrailingSlash(String(pathName)) + "Fonts";
 }
 
-void FileSystem::RegisterPath(const std::string& pathName)
+void FileSystem::RegisterPath(const String& pathName)
 {
-    if (pathName.empty())
+    if (pathName.Empty())
         return;
     
     allowedPaths_.insert(AddTrailingSlash(pathName));
 }
 
-void FileSystem::ScanDirInternal(std::vector<std::string>& result, std::string path, const std::string& startPath,
-    const std::string& filter, unsigned flags, bool recursive)
+void FileSystem::ScanDirInternal(std::vector<String>& result, String path, const String& startPath,
+    const String& filter, unsigned flags, bool recursive)
 {
     path = AddTrailingSlash(path);
-    std::string pathAndFilter = GetNativePath(path + filter, true);
-    std::string deltaPath;
-    if (path.length() > startPath.length())
-        deltaPath = path.substr(startPath.length());
+    String pathAndFilter = GetNativePath(path + filter, true);
+    String deltaPath;
+    if (path.Length() > startPath.Length())
+        deltaPath = path.Substring(startPath.Length());
     
     WIN32_FIND_DATA info;
-    HANDLE handle = FindFirstFile(pathAndFilter.c_str(), &info);
+    HANDLE handle = FindFirstFile(pathAndFilter.CString(), &info);
     if (handle != INVALID_HANDLE_VALUE)
     {
         do
         {
-            std::string fileName((const char*)&info.cFileName[0]);
-            if (!fileName.empty())
+            String fileName((const char*)&info.cFileName[0]);
+            if (!fileName.Empty())
             {
                 if ((info.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) && (!(flags & SCAN_HIDDEN)))
                     continue;
@@ -331,97 +332,98 @@ void FileSystem::ScanDirInternal(std::vector<std::string>& result, std::string p
     }
 }
 
-void SplitPath(const std::string& fullPath, std::string& pathName, std::string& fileName, std::string& extension)
+void SplitPath(const String& fullPath, String& pathName, String& fileName, String& extension)
 {
-    std::string fullPathCopy = Replace(fullPath, '\\', '/');
+    String fullPathCopy = fullPath.Replace('\\', '/');
     
-    size_t extPos = fullPathCopy.rfind('.');
-    if (extPos != std::string::npos)
+    unsigned extPos = fullPathCopy.FindLast('.');
+    if (extPos != String::NPOS)
     {
-        extension = ToLower(fullPathCopy.substr(extPos));
-        fullPathCopy = fullPathCopy.substr(0, extPos);
+        extension = fullPathCopy.Substring(extPos).ToLower();
+        fullPathCopy = fullPathCopy.Substring(0, extPos);
     }
     else
-        extension.clear();
+        extension.Clear();
     
-    size_t pathPos = fullPathCopy.rfind('/');
-    if (pathPos != std::string::npos)
+    unsigned pathPos = fullPathCopy.FindLast('/');
+    if (pathPos != String::NPOS)
     {
-        fileName = fullPathCopy.substr(pathPos + 1);
-        pathName = fullPathCopy.substr(0, pathPos + 1);
+        fileName = fullPathCopy.Substring(pathPos + 1);
+        pathName = fullPathCopy.Substring(0, pathPos + 1);
     }
     else
     {
         fileName = fullPathCopy;
-        pathName.clear();
+        pathName.Clear();
     }
 }
 
-std::string GetPath(const std::string& fullPath)
+String GetPath(const String& fullPath)
 {
-    std::string path, file, extension;
+    String path, file, extension;
     SplitPath(fullPath, path, file, extension);
     return path;
 }
 
-std::string GetFileName(const std::string& fullPath)
+String GetFileName(const String& fullPath)
 {
-    std::string path, file, extension;
+    String path, file, extension;
     SplitPath(fullPath, path, file, extension);
     return file;
 }
 
-std::string GetExtension(const std::string& fullPath)
+String GetExtension(const String& fullPath)
 {
-    std::string path, file, extension;
+    String path, file, extension;
     SplitPath(fullPath, path, file, extension);
     return extension;
 }
 
-std::string GetFileNameAndExtension(const std::string& fileName)
+String GetFileNameAndExtension(const String& fileName)
 {
-    std::string path, file, extension;
+    String path, file, extension;
     SplitPath(fileName, path, file, extension);
     return file + extension;
 }
 
-std::string AddTrailingSlash(const std::string& path)
+String AddTrailingSlash(const String& path)
 {
-    std::string ret;
+    String ret;
     
-    if (!path.empty())
+    if (!path.Empty())
     {
         ret = path;
-        char last = path[path.length() - 1];
+        char last = path[path.Length() - 1];
         if ((last != '/') && (last != '\\'))
             ret += '/';
     }
     
-    return Replace(ret, '\\', '/');
+    ret.ReplaceInPlace('\\', '/');
+    return ret;
 }
 
-std::string RemoveTrailingSlash(const std::string& path)
+String RemoveTrailingSlash(const String& path)
 {
-    if (!path.empty())
+    if (!path.Empty())
     {
-        char last = path[path.length() - 1];
+        char last = path[path.Length() - 1];
         if ((last == '/') || (last == '\\'))
-            return path.substr(0, path.length() - 1);
+            return path.Substring(0, path.Length() - 1);
     }
     
     return path;
 }
 
-std::string GetParentPath(const std::string& path)
+String GetParentPath(const String& path)
 {
-    unsigned pos = RemoveTrailingSlash(path).rfind('/');
-    if (pos != std::string::npos)
-        return path.substr(0, pos + 1);
+    unsigned pos = RemoveTrailingSlash(path).FindLast('/');
+    if (pos != String::NPOS)
+        return path.Substring(0, pos + 1);
     else
         return path;
 }
 
-std::string GetNativePath(const std::string& pathName, bool forNativeApi)
+String GetNativePath(const String& pathName, bool forNativeApi)
 {
     // On MSVC, replace slash always with backslash. On MinGW only if going to do Win32 native calls
 #ifdef _MSC_VER
@@ -429,7 +431,7 @@ std::string GetNativePath(const std::string& pathName, bool forNativeApi)
 #endif
     
     if (forNativeApi)
-        return Replace(pathName, '/', '\\');
+        return pathName.Replace('/', '\\');
     else
         return pathName;
 }

+ 29 - 29
Engine/IO/FileSystem.h

@@ -47,65 +47,65 @@ public:
     ~FileSystem();
     
     /// Set the current working directory
-    bool SetCurrentDir(const std::string& pathName);
+    bool SetCurrentDir(const String& pathName);
     /// Create a directory
-    bool CreateDir(const std::string& pathName);
+    bool CreateDir(const String& pathName);
     /// Run a program using the command interpreter, block until it exits and return the exit code. Will fail if any allowed paths are defined
-    int SystemCommand(const std::string& commandLine);
+    int SystemCommand(const String& commandLine);
     /// Run a specific program, block until it exists and return the exit code. Will fail if any allowed paths are defined
-    int SystemRun(const std::string& fileName, const std::vector<std::string>& arguments);
+    int SystemRun(const String& fileName, const std::vector<String>& arguments);
     /// Open a file in an external program, with mode such as "edit" optionally specified. Will fail if any allowed paths are defined
-    bool SystemOpen(const std::string& fileName, const std::string& mode = std::string());
+    bool SystemOpen(const String& fileName, const String& mode = String());
     /// Copy a file. Return true if successful
-    bool Copy(const std::string& srcFileName, const std::string& destFileName);
+    bool Copy(const String& srcFileName, const String& destFileName);
     /// Rename a file. Return true if successful
-    bool Rename(const std::string& srcFileName, const std::string& destFileName);
+    bool Rename(const String& srcFileName, const String& destFileName);
     /// Delete a file. Return true if successful
-    bool Delete(const std::string& fileName);
+    bool Delete(const String& fileName);
     /// Register a path as being allowed to access
-    void RegisterPath(const std::string& pathName);
+    void RegisterPath(const String& pathName);
     
     /// Return the absolute current working directory
-    std::string GetCurrentDir();
+    String GetCurrentDir();
     /// Check if a path is allowed to be accessed. If no paths defined, all are allowed
-    bool CheckAccess(const std::string& pathName);
+    bool CheckAccess(const String& pathName);
     /// Check if a file exists
-    bool FileExists(const std::string& fileName);
+    bool FileExists(const String& fileName);
     /// Check if a directory exists
-    bool DirExists(const std::string& pathName);
+    bool DirExists(const String& pathName);
     /// Scan a directory for specified files
-    void ScanDir(std::vector<std::string>& result, const std::string& pathName, const std::string& filter, unsigned flags, bool recursive);
+    void ScanDir(std::vector<String>& result, const String& pathName, const String& filter, unsigned flags, bool recursive);
     /// Return the program's directory
-    std::string GetProgramDir();
+    String GetProgramDir();
     /// Return the user documents directory
-    std::string GetUserDocumentsDir();
+    String GetUserDocumentsDir();
     /// Return the system fonts directory
-    std::string GetSystemFontDir();
+    String GetSystemFontDir();
     
 private:
     /// Scan directory, called internally
-    void ScanDirInternal(std::vector<std::string>& result, std::string path, const std::string& startPath,
-        const std::string& filter, unsigned flags, bool recursive);
+    void ScanDirInternal(std::vector<String>& result, String path, const String& startPath,
+        const String& filter, unsigned flags, bool recursive);
     
     /// Allowed directories
-    std::set<std::string> allowedPaths_;
+    std::set<String> allowedPaths_;
 };
 
 /// Split a full path to path, filename and extension. The extension will be converted to lowercase
-void SplitPath(const std::string& fullPath, std::string& pathName, std::string& fileName, std::string& extension);
+void SplitPath(const String& fullPath, String& pathName, String& fileName, String& extension);
 /// Return the path from a full path
-std::string GetPath(const std::string& fullPath);
+String GetPath(const String& fullPath);
 /// Return the filename from a full path
-std::string GetFileName(const std::string& fullPath);
+String GetFileName(const String& fullPath);
 /// Return the extension from a full path, converted to lowercase
-std::string GetExtension(const std::string& fullPath);
+String GetExtension(const String& fullPath);
 /// Return the filename and extension from a full path. The extension will be converted to lowercase
-std::string GetFileNameAndExtension(const std::string& fullPath);
+String GetFileNameAndExtension(const String& fullPath);
 /// Fix a path so that it contains a slash in the end, and convert backslashes to slashes
-std::string AddTrailingSlash(const std::string& pathName);
+String AddTrailingSlash(const String& pathName);
 /// Remove the slash or backslash from the end of a path if exists
-std::string RemoveTrailingSlash(const std::string& pathName);
+String RemoveTrailingSlash(const String& pathName);
 /// Return the parent path, or the path itself if not available
-std::string GetParentPath(const std::string& pathName);
+String GetParentPath(const String& pathName);
 /// Convert a path to the format required by the operating system
-std::string GetNativePath(const std::string& pathName, bool forNativeApi = false);
+String GetNativePath(const String& pathName, bool forNativeApi = false);

+ 12 - 12
Engine/IO/Log.cpp

@@ -33,7 +33,7 @@
 
 #include "DebugNew.h"
 
-static const std::string levelPrefixes[] =
+static const String levelPrefixes[] =
 {
     "DEBUG",
     "INFO",
@@ -58,9 +58,9 @@ Log::~Log()
 {
 }
 
-void Log::Open(const std::string& fileName)
+void Log::Open(const String& fileName)
 {
-    if (fileName.empty())
+    if (fileName.Empty())
         return;
     
     logFile_ = new File(context_);
@@ -73,7 +73,7 @@ void Log::Open(const std::string& fileName)
     }
 }
 
-void Log::Write(int level, const std::string& message)
+void Log::Write(int level, const String& message)
 {
     // Prevent recursion
     if (inWrite_)
@@ -90,10 +90,10 @@ void Log::Write(int level, const std::string& message)
     time_t sysTime;
     time(&sysTime);
     const char* dateTime = ctime(&sysTime);
-    std::string dateTimeString = Replace(std::string(dateTime), "\n", "");
-    std::string formattedMessage = "[" + dateTimeString + "] " + levelPrefixes[level] + ": " + message;
+    String dateTimeString = String(dateTime).Replace("\n", "");
+    String formattedMessage = "[" + dateTimeString + "] " + levelPrefixes[level] + ": " + message;
     
-    printf("%s\n", formattedMessage.c_str());
+    printf("%s\n", formattedMessage.CString());
     
     if (logFile_)
         logFile_->WriteLine(formattedMessage);
@@ -107,7 +107,7 @@ void Log::Write(int level, const std::string& message)
     inWrite_ = false;
 }
 
-void Log::WriteRaw(const std::string& message)
+void Log::WriteRaw(const String& message)
 {
     // Prevent recursion
     if (inWrite_)
@@ -117,10 +117,10 @@ void Log::WriteRaw(const std::string& message)
     
     lastMessage_ = message;
     
-    printf("%s", message.c_str());
+    printf("%s", message.CString());
     
     if (logFile_)
-        logFile_->Write(message.c_str(), message.length());
+        logFile_->Write(message.CString(), message.Length());
     
     using namespace LogMessage;
     
@@ -136,14 +136,14 @@ void Log::SetLevel(int level)
     level_ = level;
 }
 
-void WriteToLog(Context* context, int level, const std::string& message)
+void WriteToLog(Context* context, int level, const String& message)
 {
     Log* log = context->GetSubsystem<Log>();
     if (log)
         log->Write(level, message);
 }
 
-void WriteToLogRaw(Context* context, const std::string& message)
+void WriteToLogRaw(Context* context, const String& message)
 {
     Log* log = context->GetSubsystem<Log>();
     if (log)

+ 7 - 7
Engine/IO/Log.h

@@ -46,24 +46,24 @@ public:
     virtual ~Log();
     
     /// Open the log file
-    void Open(const std::string& fileName);
+    void Open(const String& fileName);
     /// Write to the log. If logging level is higher than the level of the message, the message is ignored
-    void Write(int level, const std::string& message);
+    void Write(int level, const String& message);
     /// Write raw output to the log
-    void WriteRaw(const std::string& message);
+    void WriteRaw(const String& message);
     /// Set logging level
     void SetLevel(int level);
     
     /// Return logging level
     int GetLevel() const { return level_; }
     /// Return last log message
-    const std::string& GetLastMessage() const { return lastMessage_; }
+    const String& GetLastMessage() const { return lastMessage_; }
     
 private:
     /// Log file
     SharedPtr<File> logFile_;
     /// Last log message
-    std::string lastMessage_;
+    String lastMessage_;
     /// Logging level
     int level_;
     /// In write flag to prevent recursion
@@ -71,9 +71,9 @@ private:
 };
 
 /// Write to the log (static)
-void WriteToLog(Context* context, int level, const std::string& message);
+void WriteToLog(Context* context, int level, const String& message);
 /// Write raw output to the log (static)
-void WriteToLogRaw(Context* context, const std::string& message);
+void WriteToLogRaw(Context* context, const String& message);
 
 #define LOGDEBUG(message) WriteToLog(context_, LOG_DEBUG, message)
 #define LOGINFO(message) WriteToLog(context_, LOG_INFO, message)

+ 8 - 8
Engine/IO/PackageFile.cpp

@@ -36,7 +36,7 @@ PackageFile::PackageFile(Context* context) :
 {
 }
 
-PackageFile::PackageFile(Context* context, const std::string& fileName) :
+PackageFile::PackageFile(Context* context, const String& fileName) :
     Object(context),
     totalSize_(0),
     checksum_(0)
@@ -48,7 +48,7 @@ PackageFile::~PackageFile()
 {
 }
 
-bool PackageFile::Open(const std::string& fileName)
+bool PackageFile::Open(const String& fileName)
 {
     SharedPtr<File> file(new File(context_, fileName));
     if (!file->IsOpen())
@@ -70,7 +70,7 @@ bool PackageFile::Open(const std::string& fileName)
     
     for (unsigned i = 0; i < numFiles; ++i)
     {
-        std::string entryName = file->ReadString();
+        String entryName = file->ReadString();
         PackageEntry newEntry;
         newEntry.offset_ = file->ReadUInt();
         newEntry.size_ = file->ReadUInt();
@@ -78,20 +78,20 @@ bool PackageFile::Open(const std::string& fileName)
         if (newEntry.offset_ + newEntry.size_ > totalSize_)
             LOGERROR("File entry " + entryName + " outside package file");
         else
-            entries_[ToLower(entryName)] = newEntry;
+            entries_[entryName.ToLower()] = newEntry;
     }
     
     return true;
 }
 
-bool PackageFile::Exists(const std::string& fileName) const
+bool PackageFile::Exists(const String& fileName) const
 {
-    return entries_.find(ToLower(fileName)) != entries_.end();
+    return entries_.find(fileName.ToLower()) != entries_.end();
 }
 
-const PackageEntry* PackageFile::GetEntry(const std::string& fileName) const
+const PackageEntry* PackageFile::GetEntry(const String& fileName) const
 {
-    std::map<std::string, PackageEntry>::const_iterator i = entries_.find(ToLower(fileName));
+    std::map<String, PackageEntry>::const_iterator i = entries_.find(fileName.ToLower());
     if (i == entries_.end())
         return 0;
     

+ 8 - 8
Engine/IO/PackageFile.h

@@ -42,20 +42,20 @@ public:
     /// Construct
     PackageFile(Context* context);
     /// Construct and open
-    PackageFile(Context* context, const std::string& fileName);
+    PackageFile(Context* context, const String& fileName);
     /// Destruct
     virtual ~PackageFile();
     
     /// Open the package file. Return true if successful
-    bool Open(const std::string& fileName);
+    bool Open(const String& fileName);
     /// Check if a file exists within the package file
-    bool Exists(const std::string& fileName) const;
+    bool Exists(const String& fileName) const;
     /// Return the file entry corresponding to the name, or null if not found
-    const PackageEntry* GetEntry(const std::string& fileName) const;
+    const PackageEntry* GetEntry(const String& fileName) const;
     /// Return all file entries
-    const std::map<std::string, PackageEntry>& GetEntries() const { return entries_; }
+    const std::map<String, PackageEntry>& GetEntries() const { return entries_; }
     /// Return the package file name
-    const std::string& GetName() const { return fileName_; }
+    const String& GetName() const { return fileName_; }
     /// Return hash of the package file name
     StringHash GetNameHash() const { return nameHash_; }
     /// Return number of files
@@ -67,9 +67,9 @@ public:
     
 private:
     /// File entries
-    std::map<std::string, PackageEntry> entries_;
+    std::map<String, PackageEntry> entries_;
     /// File name
-    std::string fileName_;
+    String fileName_;
     /// Package file name hash
     StringHash nameHash_;
     /// Package file total size

+ 2 - 1
Engine/IO/Precompiled.h

@@ -23,7 +23,8 @@
 
 #pragma once
 
+#include "StringBase.h"
+
 #include <map>
 #include <set>
-#include <string>
 #include <vector>

+ 8 - 8
Engine/IO/Serializer.cpp

@@ -147,18 +147,18 @@ bool Serializer::WriteBoundingBox(const BoundingBox& value)
     return success;
 }
 
-bool Serializer::WriteString(const std::string& value)
+bool Serializer::WriteString(const String& value)
 {
-    return Write(value.c_str(), value.length() + 1) == value.length() + 1;
+    return Write(value.CString(), value.Length() + 1) == value.Length() + 1;
 }
 
-bool Serializer::WriteID(const std::string& value)
+bool Serializer::WriteID(const String& value)
 {
     bool success = true;
-    unsigned length = Min((int)value.length(), 4);
+    unsigned length = Min((int)value.Length(), 4);
     
-    success &= Write(value.c_str(), length) == length;
-    for (unsigned i = value.length(); i < 4; ++i)
+    success &= Write(value.CString(), length) == length;
+    for (unsigned i = value.Length(); i < 4; ++i)
         success &= WriteByte(' ');
     return success;
 }
@@ -323,11 +323,11 @@ bool Serializer::WriteVLE(unsigned value)
     }
 }
 
-bool Serializer::WriteLine(const std::string& value)
+bool Serializer::WriteLine(const String& value)
 {
     bool success = true;
     
-    success &= Write(value.c_str(), value.length()) == value.length();
+    success &= Write(value.CString(), value.Length()) == value.Length();
     success &= WriteUByte(13);
     success &= WriteUByte(10);
     return success;

+ 3 - 3
Engine/IO/Serializer.h

@@ -92,9 +92,9 @@ public:
     /// Write a BoundingBox
     bool WriteBoundingBox(const BoundingBox& value);
     /// Write a null-terminated string
-    bool WriteString(const std::string& value);
+    bool WriteString(const String& value);
     /// Write a four-letter ID. If the string is not long enough, spaces will be appended
-    bool WriteID(const std::string& value);
+    bool WriteID(const String& value);
     /// Write a 32-bit StringHash
     bool WriteStringHash(const StringHash& value);
     /// Write a 16-bit ShortStringHash
@@ -116,5 +116,5 @@ public:
     /// Write a variable-length encoded unsigned integer, which can use 29 bits maximum
     bool WriteVLE(unsigned value);
     /// Write a text line. Char codes 13 & 10 will be automatically appended.
-    bool WriteLine(const std::string& value);
+    bool WriteLine(const String& value);
 };

+ 0 - 2
Engine/Math/Quaternion.cpp

@@ -24,8 +24,6 @@
 #include "Precompiled.h"
 #include "Quaternion.h"
 
-#include <iostream>
-
 const Quaternion Quaternion::IDENTITY;
 
 Quaternion::Quaternion(float angle, const Vector3& axis)

+ 25 - 25
Engine/Network/Client.cpp

@@ -68,12 +68,12 @@ void Client::SetScene(Scene* scene)
     scene_ = scene;
 }
 
-void Client::SetDownloadDirectory(const std::string& path)
+void Client::SetDownloadDirectory(const String& path)
 {
     downloadDirectory_ = AddTrailingSlash(path);
 }
 
-bool Client::Connect(const std::string& address, unsigned short port, const VariantMap& loginData)
+bool Client::Connect(const String& address, unsigned short port, const VariantMap& loginData)
 {
     if (!scene_)
         return false;
@@ -188,13 +188,13 @@ const Vector3& Client::GetPosition() const
     return serverConnection_->GetPosition();
 }
 
-std::string Client::GetFileTransferStatus() const
+String Client::GetFileTransferStatus() const
 {
-    std::string ret;
+    String ret;
     
     for (std::map<StringHash, FileTransfer>::const_iterator i = fileTransfers_.begin(); i != fileTransfers_.end(); ++i)
     {
-        std::string line = i->second.fileName_ + " " + ToString(i->second.bytesReceived_) + "/" + ToString(i->second.size_) 
+        String line = i->second.fileName_ + " " + ToString(i->second.bytesReceived_) + "/" + ToString(i->second.size_) 
             + " (" + ToString((int)(((float)i->second.bytesReceived_ / (float)i->second.size_) * 100.0f + 0.5f)) + "%)\n";
         ret += line;
     }
@@ -227,7 +227,7 @@ void Client::HandleFileTransferCompleted(StringHash eventType, VariantMap& event
 {
     using namespace FileTransferCompleted;
     
-    std::string fileName = eventData[P_FILENAME].GetString();
+    String fileName = eventData[P_FILENAME].GetString();
     if (pendingDownloads_.find(fileName) != pendingDownloads_.end())
     {
         pendingDownloads_.erase(fileName);
@@ -252,7 +252,7 @@ void Client::HandleFileTransferFailed(StringHash eventType, VariantMap& eventDat
 {
     using namespace FileTransferFailed;
     
-    std::string fileName = eventData[P_FILENAME].GetString();
+    String fileName = eventData[P_FILENAME].GetString();
     if (pendingDownloads_.find(fileName) != pendingDownloads_.end())
         JoinFailed("Failed to transfer file " + fileName);
 }
@@ -328,7 +328,7 @@ void Client::HandleSceneInfo(VectorBuffer& packet)
     serverConnection_->SetScene(scene_);
     
     // Read scene name, number of users and update rate
-    std::string sceneName = packet.ReadString();
+    String sceneName = packet.ReadString();
     sceneInfo_.name_ = sceneName;
     sceneInfo_.numUsers_ = packet.ReadVLE();
     sceneInfo_.netFps_ = packet.ReadInt();
@@ -463,7 +463,7 @@ void Client::HandleTransferData(VectorBuffer& packet)
 void Client::HandleTransferFailed(VectorBuffer& packet)
 {
     StringHash nameHash = packet.ReadStringHash();
-    std::string reason = packet.ReadString();
+    String reason = packet.ReadString();
     
     std::map<StringHash, FileTransfer>::iterator i = fileTransfers_.find(nameHash);
     if (i == fileTransfers_.end())
@@ -472,7 +472,7 @@ void Client::HandleTransferFailed(VectorBuffer& packet)
         return;
     }
     
-    std::string errorMsg = "Transfer of file " + ToString(nameHash) + " failed: " + reason;
+    String errorMsg = "Transfer of file " + ToString(nameHash) + " failed: " + reason;
     LOGINFO(errorMsg);
     
     using namespace FileTransferFailed;
@@ -501,7 +501,7 @@ void Client::HandleJoinReply(VectorBuffer& packet)
     }
     else
     {
-        std::string reason = packet.ReadString();
+        String reason = packet.ReadString();
         
         serverConnection_->LeftScene();
         pendingDownloads_.clear();
@@ -609,13 +609,13 @@ unsigned Client::CheckPackages()
     
     // To avoid resource version conflicts and to keep the amount of open packages reasonable, remove all existing
     // downloaded packages from the resource cache first
-    std::vector<std::string> downloadedPackages;
+    std::vector<String> downloadedPackages;
     std::vector<SharedPtr<PackageFile> > registeredPackages = GetSubsystem<ResourceCache>()->GetPackageFiles();
     GetSubsystem<FileSystem>()->ScanDir(downloadedPackages, downloadDirectory_, "*.pak", SCAN_FILES, false);
     
     for (std::vector<SharedPtr<PackageFile> >::iterator i = registeredPackages.begin(); i != registeredPackages.end();)
     {
-        if ((*i)->GetName().find(downloadDirectory_) != std::string::npos)
+        if ((*i)->GetName().Find(downloadDirectory_) != String::NPOS)
         {
             GetSubsystem<ResourceCache>()->RemovePackageFile(*i);
             i = registeredPackages.erase(i);
@@ -627,15 +627,15 @@ unsigned Client::CheckPackages()
     for (unsigned i = 0; i < sceneInfo_.requiredPackages_.size(); ++i)
     {
         const PackageInfo& required = sceneInfo_.requiredPackages_[i];
-        std::string requiredName = GetFileName(required.name_);
+        String requiredName = GetFileName(required.name_);
         bool found = false;
         
         // Check both already registered packages, and existing downloads
         for (unsigned j = 0; j < registeredPackages.size(); ++j)
         {
             PackageFile* package = registeredPackages[i];
-            std::string name = GetFileName(package->GetName());
-            if ((name.find(requiredName) != std::string::npos) && (package->GetTotalSize() == required.size_) &&
+            String name = GetFileName(package->GetName());
+            if ((name.Find(requiredName) != String::NPOS) && (package->GetTotalSize() == required.size_) &&
                 (package->GetChecksum() == required.checksum_))
             {
                 found = true;
@@ -648,8 +648,8 @@ unsigned Client::CheckPackages()
             for (unsigned j = 0; j < downloadedPackages.size(); ++j)
             {
                 // Downloaded packages are encoded as filename_checksum.pak, so check if the filename contains the required name
-                std::string name = GetFileName(downloadedPackages[i]);
-                if (name.find(requiredName) != std::string::npos)
+                String name = GetFileName(downloadedPackages[i]);
+                if (name.Find(requiredName) != String::NPOS)
                 {
                     SharedPtr<PackageFile> file(new PackageFile(context_));
                     file->Open(downloadDirectory_ + downloadedPackages[i]);
@@ -679,7 +679,7 @@ unsigned Client::CheckPackages()
     return pendingDownloads_.size();
 }
 
-bool Client::RequestFile(const std::string& fileName, unsigned size, unsigned checksum)
+bool Client::RequestFile(const String& fileName, unsigned size, unsigned checksum)
 {
     StringHash nameHash(fileName);
     if (fileTransfers_.find(nameHash) != fileTransfers_.end())
@@ -687,7 +687,7 @@ bool Client::RequestFile(const std::string& fileName, unsigned size, unsigned ch
     
     FileTransfer newTransfer;
     // Append checksum to download name, so that we can have several versions of a package
-    std::string destName = GetFileName(fileName) + "_" + ToStringHex(checksum) + GetExtension(fileName);
+    String destName = GetFileName(fileName) + "_" + ToStringHex(checksum) + GetExtension(fileName);
     newTransfer.file_ = new File(context_, downloadDirectory_ + destName, FILE_WRITE);
     if (!newTransfer.file_->IsOpen())
         return false;
@@ -719,7 +719,7 @@ void Client::SetupScene()
     
     // Setup the scene
     // If no filename, just empty it
-    if (sceneInfo_.fileName_.empty())
+    if (sceneInfo_.fileName_.Empty())
     {
         scene_->SetName(sceneInfo_.name_);
         scene_->Clear();
@@ -753,7 +753,7 @@ void Client::SendJoinScene()
     serverConnection_->SendReliable(packet);
 }
 
-void Client::JoinFailed(const std::string& reason)
+void Client::JoinFailed(const String& reason)
 {
     LOGINFO("Failed to join scene, reason: " + reason);
     
@@ -821,7 +821,7 @@ void Client::ReadNetUpdateBlock(Deserializer& source, unsigned char msgID, std::
     case MSG_CREATEENTITY:
         {
             // Node may already exist if server sends the create many times. But data may have changed
-            std::string name = source.ReadString();
+            String name = source.ReadString();
             if (!node)
                 node = scene_->createNode(id, name);
             
@@ -845,7 +845,7 @@ void Client::ReadNetUpdateBlock(Deserializer& source, unsigned char msgID, std::
             for (unsigned i = 0; i < nucomponents_; ++i)
             {
                 ShortStringHash type = source.ReadShortStringHash();
-                std::string name = source.ReadString();
+                String name = source.ReadString();
                 // We might apply the same update multiple times, so check if the component already exists
                 Component* component = node->GetComponent(type, name);
                 bool newComponent = false;
@@ -900,7 +900,7 @@ void Client::ReadNetUpdateBlock(Deserializer& source, unsigned char msgID, std::
                 for (unsigned i = 0; i < nucomponents_; ++i)
                 {
                     ShortStringHash type = source.ReadShortStringHash();
-                    std::string name = source.ReadString();
+                    String name = source.ReadString();
                     // We might apply the same update multiple times, so check if the component already exists
                     Component* component = node->GetComponent(type, name);
                     bool newComponent = false;

+ 12 - 12
Engine/Network/Client.h

@@ -41,7 +41,7 @@ class Scene;
 struct PackageInfo
 {
     /// File name
-    std::string name_;
+    String name_;
     /// File size
     unsigned size_;
     /// Data checksum
@@ -59,13 +59,13 @@ struct SceneInfo
     }
     
     /// Scene name
-    std::string name_;
+    String name_;
     /// Current number of users in scene
     unsigned numUsers_;
     /// Network updates per second
     int netFps_;
     /// Scene file name
-    std::string fileName_;
+    String fileName_;
     /// Required package files
     std::vector<PackageInfo> requiredPackages_;
 };
@@ -87,7 +87,7 @@ struct FileTransfer
     /// File used to store the download
     SharedPtr<File> file_;
     /// File name
-    std::string fileName_;
+    String fileName_;
     /// File size
     unsigned size_;
     /// Data checksum
@@ -126,9 +126,9 @@ public:
     /// Set scene to use. Will be cleared of any existing content
     void SetScene(Scene* scene);
     /// Set package download directory
-    void SetDownloadDirectory(const std::string& path);
+    void SetDownloadDirectory(const String& path);
     /// Connect to a server
-    bool Connect(const std::string& address, unsigned short port, const VariantMap& loginData = VariantMap());
+    bool Connect(const String& address, unsigned short port, const VariantMap& loginData = VariantMap());
     /// Disconnect from a server
     void Disconnect();
     /// Set client controls to be sent over the network
@@ -163,9 +163,9 @@ public:
     /// Return ongoing file transfers
     const std::map<StringHash, FileTransfer>& GetFileTransfers() { return fileTransfers_; }
     /// Return download directory
-    const std::string& GetDownloadDirectory() const { return downloadDirectory_; }
+    const String& GetDownloadDirectory() const { return downloadDirectory_; }
     /// Return file transfer status as text
-    std::string GetFileTransferStatus() const;
+    String GetFileTransferStatus() const;
     
 private:
     /// Handle network peer disconnect event
@@ -195,13 +195,13 @@ private:
     /// Check whether packages need to be downloaded to join the scene
     unsigned CheckPackages();
     /// Begin a file download
-    bool RequestFile(const std::string& fileName, unsigned size, unsigned checksum);
+    bool RequestFile(const String& fileName, unsigned size, unsigned checksum);
     /// Begin setup of the client scene
     void SetupScene();
     /// Send join scene packet after scene setup is complete
     void SendJoinScene();
     /// Send join failed event
-    void JoinFailed(const std::string& reason);
+    void JoinFailed(const String& reason);
     /// Send a client update packet
     void SendClientUpdate();
     /// Read a server update block
@@ -222,9 +222,9 @@ private:
     /// Ongoing file downloads
     std::map<StringHash, FileTransfer> fileTransfers_;
     /// Directory to use for downloads
-    std::string downloadDirectory_;
+    String downloadDirectory_;
     /// Downloads required to join the scene
-    std::set<std::string> pendingDownloads_;
+    std::set<String> pendingDownloads_;
     /// Login data to send to the server
     VariantMap pendingLoginData_;
 };

+ 1 - 1
Engine/Network/Connection.cpp

@@ -254,7 +254,7 @@ void Connection::ClearRemoteEvents()
     remoteEvents_.clear();
 }
 
-std::string Connection::GetIdentity() const
+String Connection::GetIdentity() const
 {
     if (peer_)
         return peer_->GetAddress() + ":" + ToString(peer_->GetPort());

+ 1 - 1
Engine/Network/Connection.h

@@ -109,7 +109,7 @@ public:
     /// Return scene the client has joined, if any
     Scene* GetScene() const { return scene_; }
     /// Return identity string (address:port)
-    std::string GetIdentity() const;
+    String GetIdentity() const;
     /// Return login data
     const VariantMap& GetLoginData() const { return loginData_; }
     /// Return challenge value

+ 2 - 2
Engine/Network/Network.cpp

@@ -163,7 +163,7 @@ bool Network::StartServer(unsigned short port)
     return true;
 }
 
-Peer* Network::Connect(const std::string& address, unsigned short port)
+Peer* Network::Connect(const String& address, unsigned short port)
 {
     // Create client host if one did not exist already
     if (!clientHost_)
@@ -180,7 +180,7 @@ Peer* Network::Connect(const std::string& address, unsigned short port)
     
     // Attempt to connect
     ENetAddress server;
-    enet_address_set_host(&server, address.c_str());
+    enet_address_set_host(&server, address.CString());
     server.port = port;
     ENetPeer* enetPeer = enet_host_connect(clientHost_, &server, numChannels_, 0);
     if (!enetPeer)

+ 1 - 1
Engine/Network/Network.h

@@ -56,7 +56,7 @@ public:
     /// Start server on a port. Return true if successful
     bool StartServer(unsigned short port);
     /// Connect to a server
-    Peer* Connect(const std::string& address, unsigned short port);
+    Peer* Connect(const String& address, unsigned short port);
     /// Broadcast a packet to all connected client peers
     void Broadcast(const VectorBuffer& packet, unsigned char channel, bool reliable, bool inOrder = true);
     /// Broadcast a packet to all connected client peers

+ 2 - 2
Engine/Network/Peer.cpp

@@ -220,7 +220,7 @@ void Peer::OnConnect()
     {
         char ipBuffer[MAX_IPADDRESS];
         enet_address_get_host_ip(&peer_->address, ipBuffer, MAX_IPADDRESS);
-        address_ = std::string(ipBuffer);
+        address_ = String(ipBuffer);
         port_ = peer_->address.port;
         connectionState_ = CS_CONNECTED;
         
@@ -250,7 +250,7 @@ void Peer::OnDisconnect()
         eventData[P_PEER] = (void*)this;
         SendEvent(E_PEERDISCONNECTED, eventData);
         
-        if (!address_.empty())
+        if (!address_.Empty())
             LOGINFO(address_ + ":" + ToString(port_) + " disconnected");
         else
             LOGINFO("Disconnected");

+ 2 - 2
Engine/Network/Peer.h

@@ -111,7 +111,7 @@ public:
     /// Return number of received packets waiting
     unsigned GetNumPackets() const { return packets_.size(); }
     /// Return address of remote host
-    const std::string& GetAddress()const { return address_; }
+    const String& GetAddress()const { return address_; }
     /// Return port of remote host
     unsigned short GetPort() const { return port_; }
     /// Return simulated packet loss
@@ -138,7 +138,7 @@ private:
     /// Latency-simulated packets waiting to be sent
     std::vector<QueuedPacket> sentPackets_;
     /// Remote host address
-    std::string address_;
+    String address_;
     /// Remote host port
     unsigned short port_;
     /// Simulated packet loss

+ 2 - 1
Engine/Network/Precompiled.h

@@ -23,8 +23,9 @@
 
 #pragma once
 
+#include "StringBase.h"
+
 #include <cstdio>
 #include <cstdlib>
 #include <map>
-#include <string>
 #include <vector>

+ 1 - 1
Engine/Network/Server.cpp

@@ -635,7 +635,7 @@ unsigned Server::GenerateChallenge() const
     return (rand() & 32767) | ((rand() & 32767) << 15) | ((rand() & 32767) << 30);
 }
 
-void Server::Disconnect(Connection* connection, bool forced, const std::string& logMessage)
+void Server::Disconnect(Connection* connection, bool forced, const String& logMessage)
 {
     LOGERROR(logMessage + " " + connection->GetIdentity());
     

+ 1 - 1
Engine/Network/Server.h

@@ -115,7 +115,7 @@ private:
     /// Generate a challenge value for the client
     unsigned GenerateChallenge() const;
     /// Disconnect client either forcibly or benevolently
-    void Disconnect(Connection* connection, bool forced, const std::string& logMessage);
+    void Disconnect(Connection* connection, bool forced, const String& logMessage);
     /// Generate a scene update. If connection has no stored scene revisions, a full update will be written
     void WriteNetUpdate(Connection* connection, Serializer& dest);
     /// Return relevant node IDs for the client

+ 7 - 7
Engine/Physics/CollisionShape.cpp

@@ -43,7 +43,7 @@
 
 #include "DebugNew.h"
 
-static const std::string typeNames[] = 
+static const String typeNames[] = 
 {
     "none",
     "box",
@@ -845,12 +845,12 @@ void CollisionShape::CreateGeometry()
     case SHAPE_CONVEXHULL:
         {
             // Check the geometry cache
-            std::string id = model_->GetName() + "_" + ToString(geometryScale_) + "_" + ToString(lodLevel_);
+            String id = model_->GetName() + "_" + ToString(geometryScale_) + "_" + ToString(lodLevel_);
             if (shapeType_ == SHAPE_CONVEXHULL)
                 id += "_" + ToString(thickness_);
             
-            std::map<std::string, SharedPtr<TriangleMeshData> >& cache = physicsWorld_->GetTriangleMeshCache();
-            std::map<std::string, SharedPtr<TriangleMeshData> >::iterator j = cache.find(id);
+            std::map<String, SharedPtr<TriangleMeshData> >& cache = physicsWorld_->GetTriangleMeshCache();
+            std::map<String, SharedPtr<TriangleMeshData> >::iterator j = cache.find(id);
             if (j != cache.end())
             {
                 geometry_ = dCreateTriMesh(space, j->second->triMesh_, 0, 0, 0);
@@ -870,10 +870,10 @@ void CollisionShape::CreateGeometry()
     case SHAPE_HEIGHTFIELD:
         {
             // Check the geometry cache
-            std::string id = model_->GetName() + "_" + ToString(numPoints_) + "_" + ToString(thickness_) + "_" + ToString(lodLevel_);
+            String id = model_->GetName() + "_" + ToString(numPoints_) + "_" + ToString(thickness_) + "_" + ToString(lodLevel_);
             
-            std::map<std::string, SharedPtr<HeightfieldData> >& cache = physicsWorld_->GetHeightfieldCache();
-            std::map<std::string, SharedPtr<HeightfieldData> >::iterator j = cache.find(id);
+            std::map<String, SharedPtr<HeightfieldData> >& cache = physicsWorld_->GetHeightfieldCache();
+            std::map<String, SharedPtr<HeightfieldData> >::iterator j = cache.find(id);
             if (j != cache.end())
             {
                 geometry_ = dCreateHeightfield(space, j->second->heightfield_, 1);

+ 1 - 1
Engine/Physics/CollisionShape.h

@@ -51,7 +51,7 @@ enum ShapeType
 struct CollisionGeometryData : public RefCounted
 {
     /// Original model name
-    std::string modelName_;
+    String modelName_;
 };
 
 /// Triangle mesh geometry data

+ 1 - 1
Engine/Physics/Joint.cpp

@@ -34,7 +34,7 @@
 
 #include "DebugNew.h"
 
-static const std::string typeNames[] =
+static const String typeNames[] =
 {
     "none",
     "ball",

+ 4 - 4
Engine/Physics/PhysicsWorld.cpp

@@ -460,18 +460,18 @@ void PhysicsWorld::DrawDebugGeometry(bool depthTest)
 void PhysicsWorld::CleanupGeometryCache()
 {
     // Remove cached shapes whose only reference is the cache itself
-    for (std::map<std::string, SharedPtr<TriangleMeshData> >::iterator i = triangleMeshCache_.begin();
+    for (std::map<String, SharedPtr<TriangleMeshData> >::iterator i = triangleMeshCache_.begin();
         i != triangleMeshCache_.end();)
     {
-        std::map<std::string, SharedPtr<TriangleMeshData> >::iterator current = i++;
+        std::map<String, SharedPtr<TriangleMeshData> >::iterator current = i++;
         if (current->second.GetRefCount() == 1)
             triangleMeshCache_.erase(current);
     }
     
-    for (std::map<std::string, SharedPtr<HeightfieldData> >::iterator i = heightfieldCache_.begin();
+    for (std::map<String, SharedPtr<HeightfieldData> >::iterator i = heightfieldCache_.begin();
         i != heightfieldCache_.end();)
     {
-        std::map<std::string, SharedPtr<HeightfieldData> >::iterator current = i++;
+        std::map<String, SharedPtr<HeightfieldData> >::iterator current = i++;
         if (current->second.GetRefCount() == 1)
             heightfieldCache_.erase(current);
     }

+ 4 - 4
Engine/Physics/PhysicsWorld.h

@@ -179,9 +179,9 @@ public:
     /// Clean up the geometry cache
     void CleanupGeometryCache();
     /// Return the triangle mesh cache
-    std::map<std::string, SharedPtr<TriangleMeshData> >& GetTriangleMeshCache() { return triangleMeshCache_; }
+    std::map<String, SharedPtr<TriangleMeshData> >& GetTriangleMeshCache() { return triangleMeshCache_; }
     /// Return the heightfield cache
-    std::map<std::string, SharedPtr<HeightfieldData> >& GetHeightfieldCache() { return heightfieldCache_; }
+    std::map<String, SharedPtr<HeightfieldData> >& GetHeightfieldCache() { return heightfieldCache_; }
     
 protected:
     /// Handle node being assigned
@@ -224,9 +224,9 @@ private:
     /// Collision infos to be sent as events
     std::vector<PhysicsCollisionInfo> collisionInfos_;
     /// Cache for triangle mesh geometries
-    std::map<std::string, SharedPtr<TriangleMeshData> > triangleMeshCache_;
+    std::map<String, SharedPtr<TriangleMeshData> > triangleMeshCache_;
     /// Cache for heightfield geometries
-    std::map<std::string, SharedPtr<HeightfieldData> > heightfieldCache_;
+    std::map<String, SharedPtr<HeightfieldData> > heightfieldCache_;
 };
 
 /// Register Physics library objects

+ 2 - 2
Engine/Physics/Precompiled.h

@@ -23,9 +23,9 @@
 
 #pragma once
 
+#include "StringBase.h"
+
 #include <cstdio>
 #include <cstdlib>
 #include <map>
-#include <stdexcept>
-#include <string>
 #include <vector>

+ 1 - 1
Engine/Physics/RigidBody.cpp

@@ -39,7 +39,7 @@
 
 static const float DEFAULT_MASS = 1.0f;
 
-static const std::string modeNames[] =
+static const String modeNames[] =
 {
     "static",
     "dynamic",

+ 5 - 5
Engine/Resource/Image.cpp

@@ -67,7 +67,7 @@ bool Image::Load(Deserializer& source)
         unsigned char* pixelData = GetImageData(source, width, height, components);
         if (!pixelData)
         {
-            LOGERROR("Could not load image: " + std::string(stbi_failure_reason()));
+            LOGERROR("Could not load image: " + String(stbi_failure_reason()));
             return false;
         }
         SetSize(width, height, components);
@@ -139,7 +139,7 @@ void Image::SetData(const unsigned char* pixelData)
     memcpy(data_.GetPtr(), pixelData, width_ * height_ * components_);
 }
 
-bool Image::SaveBMP(const std::string& fileName)
+bool Image::SaveBMP(const String& fileName)
 {
     FileSystem* fileSystem = GetSubsystem<FileSystem>();
     if ((fileSystem) && (!fileSystem->CheckAccess(GetPath(fileName))))
@@ -155,12 +155,12 @@ bool Image::SaveBMP(const std::string& fileName)
     }
     
     if (data_)
-        return stbi_write_bmp(fileName.c_str(), width_, height_, components_, data_.GetPtr()) != 0;
+        return stbi_write_bmp(fileName.CString(), width_, height_, components_, data_.GetPtr()) != 0;
     else
         return false;
 }
 
-bool Image::SaveTGA(const std::string& fileName)
+bool Image::SaveTGA(const String& fileName)
 {
     FileSystem* fileSystem = GetSubsystem<FileSystem>();
     if ((fileSystem) && (!fileSystem->CheckAccess(GetPath(fileName))))
@@ -176,7 +176,7 @@ bool Image::SaveTGA(const std::string& fileName)
     }
     
     if (data_)
-        return stbi_write_tga(fileName.c_str(), width_, height_, components_, data_.GetPtr()) != 0;
+        return stbi_write_tga(fileName.CString(), width_, height_, components_, data_.GetPtr()) != 0;
     else
         return false;
 }

+ 2 - 2
Engine/Resource/Image.h

@@ -87,9 +87,9 @@ public:
     /// Set data
     void SetData(const unsigned char* pixelData);
     /// Save in BMP format. Return true if successful
-    bool SaveBMP(const std::string& fileName);
+    bool SaveBMP(const String& fileName);
     /// Save in TGA format. Return true if successful
-    bool SaveTGA(const std::string& fileName);
+    bool SaveTGA(const String& fileName);
     
     /// Return width
     int GetWidth() const { return width_; }

+ 2 - 1
Engine/Resource/Precompiled.h

@@ -23,7 +23,8 @@
 
 #pragma once
 
+#include "StringBase.h"
+
 #include <map>
 #include <set>
-#include <string>
 #include <vector>

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است