Bladeren bron

Added documentation about containers.
Removed unnecessary StringUtils.h includes.
Changed GetStringListIndex() to use an empty string as a terminator, similarly to enum attributes.

Lasse Öörni 14 jaren geleden
bovenliggende
commit
f3859c1ed7
61 gewijzigde bestanden met toevoegingen van 98 en 104 verwijderingen
  1. 16 0
      Docs/Reference.dox
  2. 1 0
      Docs/Urho3D.dox
  3. 0 1
      Engine/Audio/Audio.cpp
  4. 1 1
      Engine/Container/Map.h
  5. 6 2
      Engine/Container/StringBase.h
  6. 0 1
      Engine/Core/Context.cpp
  7. 0 1
      Engine/Core/MiniDump.cpp
  8. 0 1
      Engine/Core/Object.cpp
  9. 0 1
      Engine/Core/ProcessUtils.cpp
  10. 2 1
      Engine/Core/StringHash.cpp
  11. 7 4
      Engine/Core/StringUtils.cpp
  12. 2 3
      Engine/Core/StringUtils.h
  13. 0 1
      Engine/Engine/Console.cpp
  14. 0 1
      Engine/Engine/DebugHud.cpp
  15. 0 1
      Engine/Engine/IOAPI.cpp
  16. 1 1
      Engine/Engine/MathAPI.cpp
  17. 0 1
      Engine/Graphics/Graphics.cpp
  18. 0 1
      Engine/Graphics/Light.cpp
  19. 7 6
      Engine/Graphics/Material.cpp
  20. 0 1
      Engine/Graphics/OcclusionBuffer.cpp
  21. 0 1
      Engine/Graphics/PixelShader.cpp
  22. 0 1
      Engine/Graphics/Renderer.cpp
  23. 9 7
      Engine/Graphics/Technique.cpp
  24. 6 5
      Engine/Graphics/Texture.cpp
  25. 0 1
      Engine/Graphics/TextureCube.cpp
  26. 0 1
      Engine/Graphics/VertexShader.cpp
  27. 0 4
      Engine/Graphics/View.cpp
  28. 0 1
      Engine/IO/File.cpp
  29. 0 1
      Engine/IO/FileSystem.cpp
  30. 0 1
      Engine/IO/Log.cpp
  31. 0 1
      Engine/IO/PackageFile.cpp
  32. 0 1
      Engine/Network/Connection.cpp
  33. 0 1
      Engine/Network/Network.cpp
  34. 0 1
      Engine/Network/Peer.cpp
  35. 0 1
      Engine/Network/RemoteEvent.cpp
  36. 0 1
      Engine/Network/Server.cpp
  37. 0 1
      Engine/Physics/CollisionShape.cpp
  38. 0 1
      Engine/Physics/Joint.cpp
  39. 0 1
      Engine/Physics/PhysicsWorld.cpp
  40. 0 1
      Engine/Physics/RigidBody.cpp
  41. 0 1
      Engine/Resource/Image.cpp
  42. 0 1
      Engine/Resource/ResourceCache.cpp
  43. 0 1
      Engine/Resource/XMLFile.cpp
  44. 0 1
      Engine/Scene/Node.cpp
  45. 2 3
      Engine/Scene/Scene.cpp
  46. 0 1
      Engine/Scene/Serializable.cpp
  47. 2 5
      Engine/Script/Addons.cpp
  48. 0 1
      Engine/Script/Script.cpp
  49. 0 1
      Engine/Script/ScriptFile.cpp
  50. 0 1
      Engine/Script/ScriptInstance.cpp
  51. 3 2
      Engine/UI/Cursor.cpp
  52. 1 1
      Engine/UI/Font.cpp
  53. 0 1
      Engine/UI/Font.h
  54. 3 2
      Engine/UI/ListView.cpp
  55. 3 2
      Engine/UI/Text.cpp
  56. 0 1
      Engine/UI/UI.cpp
  57. 12 8
      Engine/UI/UIElement.cpp
  58. 0 1
      Tools/NormalMapTool/NormalMapTool.cpp
  59. 0 1
      Tools/OgreImporter/OgreImporter.cpp
  60. 0 1
      Tools/PackageTool/PackageTool.cpp
  61. 14 6
      Urho3D/Urho3D.cpp

+ 16 - 0
Docs/Reference.dox

@@ -1,5 +1,21 @@
 /**
 
+\page DataTypes Basic data types
+
+Urho3D implements its own string type and template containers instead of using STL. The rationale for this consists of the following:
+
+- Increased performance in some cases, for example when using the PODVector class.
+- Reduced size of each string or vector instance compared to the MSVC STL implementations.
+- Reduced compile time.
+- Straightforward naming and implementation that aids in debugging and profiling.
+- Convenient member functions can be added, for example String::Split() or Vector::Compact().
+- Consistency with the rest of the classes, see \ref CodingConvention "Coding conventions".
+
+The classes in question are String, Vector, PODVector, List, Map and Set. PODVector is only to be used when the elements of the vector need no construction or destruction and can be moved with a block memory copy.
+
+In script, the String class is exposed as it is. The template containers can not be directly exposed to script, but instead a template Array type exists, which behaves like a Vector, but does not expose iterators. In addition the VariantMap is available, which is a Map<ShortStringHash, Variant>.
+
+
 \page ObjectTypes %Object types and factories
 
 Classes that derive from Object contain type-identification, they can be created through object factories, and they can send and receive \ref Events "events". Examples of these are all Component, Resource and UIElement subclasses. To be able to be constructed by a factory, they need to have a constructor that takes a Context pointer as the only parameter.

+ 1 - 0
Docs/Urho3D.dox

@@ -15,6 +15,7 @@ For getting started, see:
 
 For further reference, see:
 
+\ref DataTypes "Basic data types" <br>
 \ref ObjectTypes "Object types and factories" <br>
 \ref Subsystems "Subsystems" <br>
 \ref Events "Events" <br>

+ 0 - 1
Engine/Audio/Audio.cpp

@@ -31,7 +31,6 @@
 #include "Profiler.h"
 #include "Sound.h"
 #include "SoundSource3D.h"
-#include "StringUtils.h"
 
 #define DIRECTSOUND_VERSION 0x0800
 

+ 1 - 1
Engine/Container/Map.h

@@ -23,8 +23,8 @@
 
 #pragma once
 
-#include "TreeBase.h"
 #include "Pair.h"
+#include "TreeBase.h"
 
 // Based on Red Black Trees by Julienne Walker
 // http://eternallyconfuzzled.com/tuts/datastructures/jsw_tut_rbtree.aspx

+ 6 - 2
Engine/Container/StringBase.h

@@ -278,9 +278,13 @@ public:
     }
     
     /// Return char at index
-    char& operator [] (unsigned pos) { return buffer_[pos]; }
+    char& operator [] (unsigned index) { return buffer_[index]; }
     /// Return const char at index
-    const char& operator [] (unsigned pos) const { return buffer_[pos]; }
+    const char& operator [] (unsigned index) const { return buffer_[index]; }
+    /// Return char at index
+    char& At(unsigned index) { return buffer_[index]; }
+    /// Return const char at index
+    const char& At(unsigned index) const { return buffer_[index]; }
     
     /// Replace all occurrences of a character
     void ReplaceInPlace(char replaceThis, char replaceWith);

+ 0 - 1
Engine/Core/Context.cpp

@@ -23,7 +23,6 @@
 
 #include "Precompiled.h"
 #include "Context.h"
-#include "StringUtils.h"
 
 #include "DebugNew.h"
 

+ 0 - 1
Engine/Core/MiniDump.cpp

@@ -26,7 +26,6 @@
 #ifdef ENABLE_MINIDUMPS
 
 #include "ProcessUtils.h"
-#include "StringUtils.h"
 
 #include <cstdio>
 #include <list>

+ 0 - 1
Engine/Core/Object.cpp

@@ -23,7 +23,6 @@
 
 #include "Precompiled.h"
 #include "Context.h"
-#include "StringUtils.h"
 
 #include "DebugNew.h"
 

+ 0 - 1
Engine/Core/ProcessUtils.cpp

@@ -24,7 +24,6 @@
 #include "Precompiled.h"
 #include "Mutex.h"
 #include "ProcessUtils.h"
-#include "StringUtils.h"
 
 #include <cstdio>
 #include <list>

+ 2 - 1
Engine/Core/StringHash.cpp

@@ -22,7 +22,8 @@
 //
 
 #include "Precompiled.h"
-#include "StringUtils.h"
+#include "MathDefs.h"
+#include "StringHash.h"
 
 #include <cstdio>
 

+ 7 - 4
Engine/Core/StringUtils.cpp

@@ -168,25 +168,28 @@ String ToStringHex(unsigned value)
     return String(tempBuffer);
 }
 
-unsigned GetStringListIndex(const String& value, const String* strings, unsigned count, unsigned defaultIndex,
-    bool caseSensitive)
+unsigned GetStringListIndex(const String& value, const String* strings, unsigned defaultIndex, bool caseSensitive)
 {
+    unsigned i = 0;
+    
     if (caseSensitive)
     {
-        for (unsigned i = 0; i < count; ++i)
+        while (!strings[i].Empty())
         {
             if (value == strings[i])
                 return i;
+            ++i;
         }
     }
     else
     {
         String valueLower = value.ToLower();
-        for (unsigned i = 0; i < count; ++i)
+        while (!strings[i].Empty())
         {
             /// \todo Write an insensitive compare function instead of creating new strings
             if (valueLower == strings[i].ToLower())
                 return i;
+            ++i;
         }
     }
     

+ 2 - 3
Engine/Core/StringUtils.h

@@ -58,6 +58,5 @@ String ToString(void* value);
 /// Convert an unsigned integer to string as hexadecimal
 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 String& value, const String* strings, unsigned count, unsigned defaultIndex,
-    bool caseSensitive = false);
+/// Return an index to a string list corresponding to the given string, or a default value if not found. The string list must be empty-terminated
+unsigned GetStringListIndex(const String& value, const String* strings, unsigned defaultIndex, bool caseSensitive = false);

+ 0 - 1
Engine/Engine/Console.cpp

@@ -33,7 +33,6 @@
 #include "Log.h"
 #include "ResourceCache.h"
 #include "Script.h"
-#include "StringUtils.h"
 #include "Text.h"
 #include "UI.h"
 #include "UIEvents.h"

+ 0 - 1
Engine/Engine/DebugHud.cpp

@@ -30,7 +30,6 @@
 #include "Log.h"
 #include "Profiler.h"
 #include "Renderer.h"
-#include "StringUtils.h"
 #include "Text.h"
 #include "UI.h"
 

+ 0 - 1
Engine/Engine/IOAPI.cpp

@@ -27,7 +27,6 @@
 #include "Log.h"
 #include "PackageFile.h"
 #include "ProcessUtils.h"
-#include "StringUtils.h"
 #include "VectorBuffer.h"
 
 void FakeAddRef(void* ptr)

+ 1 - 1
Engine/Engine/MathAPI.cpp

@@ -22,8 +22,8 @@
 //
 
 #include "Precompiled.h"
+#include "Color.h"
 #include "Frustum.h"
-#include "StringUtils.h"
 
 #include <angelscript.h>
 

+ 0 - 1
Engine/Graphics/Graphics.cpp

@@ -41,7 +41,6 @@
 #include "PixelShader.h"
 #include "Profiler.h"
 #include "Skybox.h"
-#include "StringUtils.h"
 #include "Technique.h"
 #include "Texture2D.h"
 #include "TextureCube.h"

+ 0 - 1
Engine/Graphics/Light.cpp

@@ -27,7 +27,6 @@
 #include "DebugRenderer.h"
 #include "Light.h"
 #include "ResourceCache.h"
-#include "StringUtils.h"
 #include "Texture2D.h"
 #include "TextureCube.h"
 #include "XMLElement.h"

+ 7 - 6
Engine/Graphics/Material.cpp

@@ -47,14 +47,16 @@ static const String textureUnitNames[] =
     "environment",
     "emissive",
     "lightramp", // Not defined by materials
-    "lightspot" // Not defined by materials
+    "lightspot", // Not defined by materials
+    ""
 };
 
 static const String cullModeNames[] =
 {
     "none",
     "ccw",
-    "cw"
+    "cw",
+    ""
 };
 
 TechniqueEntry::TechniqueEntry() :
@@ -143,8 +145,7 @@ bool Material::Load(Deserializer& source)
         if (textureElem.HasAttribute("unit"))
         {
             String unitName = textureElem.GetStringLower("unit");
-            unit = (TextureUnit)GetStringListIndex(unitName, textureUnitNames, MAX_MATERIAL_TEXTURE_UNITS,
-                MAX_MATERIAL_TEXTURE_UNITS);
+            unit = (TextureUnit)GetStringListIndex(unitName, textureUnitNames, MAX_MATERIAL_TEXTURE_UNITS);
             if (unitName == "diff")
                 unit = TU_DIFFUSE;
             if (unitName == "norm")
@@ -190,11 +191,11 @@ bool Material::Load(Deserializer& source)
     
     XMLElement cullElem = rootElem.GetChildElement("cull");
     if (cullElem)
-        SetCullMode((CullMode)GetStringListIndex(cullElem.GetString("value"), cullModeNames, MAX_CULLMODES, CULL_CCW));
+        SetCullMode((CullMode)GetStringListIndex(cullElem.GetString("value"), cullModeNames, CULL_CCW));
     
     XMLElement shadowCullElem = rootElem.GetChildElement("shadowcull");
     if (shadowCullElem)
-        SetShadowCullMode((CullMode)GetStringListIndex(shadowCullElem.GetString("value"), cullModeNames, MAX_CULLMODES, CULL_CCW));
+        SetShadowCullMode((CullMode)GetStringListIndex(shadowCullElem.GetString("value"), cullModeNames, CULL_CCW));
     
     // Calculate memory use
     unsigned memoryUse = 0;

+ 0 - 1
Engine/Graphics/OcclusionBuffer.cpp

@@ -26,7 +26,6 @@
 #include "Log.h"
 #include "OcclusionBuffer.h"
 #include "Profiler.h"
-#include "StringUtils.h"
 
 #include <cstring>
 

+ 0 - 1
Engine/Graphics/PixelShader.cpp

@@ -31,7 +31,6 @@
 #include "Profiler.h"
 #include "ResourceCache.h"
 #include "SharedArrayPtr.h"
-#include "StringUtils.h"
 #include "XMLFile.h"
 
 #include <ctype.h>

+ 0 - 1
Engine/Graphics/Renderer.cpp

@@ -41,7 +41,6 @@
 #include "Renderer.h"
 #include "ResourceCache.h"
 #include "Scene.h"
-#include "StringUtils.h"
 #include "Technique.h"
 #include "Texture2D.h"
 #include "TextureCube.h"

+ 9 - 7
Engine/Graphics/Technique.cpp

@@ -41,7 +41,8 @@ static const String passNames[] =
     "litbase",
     "light",
     "extra",
-    "shadow"
+    "shadow",
+    ""
 };
 
 static const String blendModeNames[] =
@@ -52,7 +53,8 @@ static const String blendModeNames[] =
     "alpha",
     "addalpha",
     "premulalpha",
-    "invdestalpha"
+    "invdestalpha",
+    ""
 };
 
 static const String CompareModeNames[] =
@@ -63,7 +65,8 @@ static const String CompareModeNames[] =
     "less",
     "lessequal",
     "greater",
-    "greaterequal"
+    "greaterequal",
+    ""
 };
 
 Pass::Pass()
@@ -164,7 +167,7 @@ bool Technique::Load(Deserializer& source)
         if (passElem.HasAttribute("name"))
         {
             String name = passElem.GetStringLower("name");
-            type = (PassType)GetStringListIndex(name, passNames, MAX_PASSES, MAX_PASSES);
+            type = (PassType)GetStringListIndex(name, passNames, MAX_PASSES);
             if (type == MAX_PASSES)
                 LOGERROR("Unknown pass " + name);
         }
@@ -190,7 +193,7 @@ bool Technique::Load(Deserializer& source)
             if (passElem.HasAttribute("blend"))
             {
                 String blend = passElem.GetStringLower("blend");
-                newPass.SetBlendMode((BlendMode)GetStringListIndex(blend, blendModeNames, MAX_BLENDMODES, BLEND_REPLACE));
+                newPass.SetBlendMode((BlendMode)GetStringListIndex(blend, blendModeNames, BLEND_REPLACE));
             }
             
             if (passElem.HasAttribute("depthtest"))
@@ -199,8 +202,7 @@ bool Technique::Load(Deserializer& source)
                 if (depthTest == "false")
                     newPass.SetDepthTestMode(CMP_ALWAYS);
                 else
-                    newPass.SetDepthTestMode((CompareMode)GetStringListIndex(depthTest, CompareModeNames, MAX_COMPAREMODES,
-                        CMP_LESSEQUAL));
+                    newPass.SetDepthTestMode((CompareMode)GetStringListIndex(depthTest, CompareModeNames, CMP_LESSEQUAL));
             }
             
             if (passElem.HasAttribute("depthwrite"))

+ 6 - 5
Engine/Graphics/Texture.cpp

@@ -39,7 +39,8 @@ static const String addressModeNames[] =
     "wrap",
     "mirror",
     "clamp",
-    "border"
+    "border",
+    ""
 };
 
 static const String filterModeNames[] =
@@ -48,7 +49,8 @@ static const String filterModeNames[] =
     "bilinear",
     "trilinear",
     "anisotropic",
-    "default"
+    "default",
+    ""
 };
 
 Texture::Texture(Context* context) :
@@ -172,8 +174,7 @@ void Texture::LoadParameters(XMLFile* file)
             {
                 TextureCoordinate coordIndex = (TextureCoordinate)(coord[0] - 'u');
                 String mode = paramElem.GetStringLower("mode");
-                SetAddressMode(coordIndex, (TextureAddressMode)GetStringListIndex(mode, addressModeNames, MAX_ADDRESSMODES,
-                    ADDRESS_WRAP));
+                SetAddressMode(coordIndex, (TextureAddressMode)GetStringListIndex(mode, addressModeNames, ADDRESS_WRAP));
             }
         }
         
@@ -183,7 +184,7 @@ void Texture::LoadParameters(XMLFile* file)
         if (name == "filter")
         {
             String mode = paramElem.GetStringLower("mode");
-            SetFilterMode((TextureFilterMode)GetStringListIndex(mode, filterModeNames, MAX_FILTERMODES, FILTER_DEFAULT));
+            SetFilterMode((TextureFilterMode)GetStringListIndex(mode, filterModeNames, FILTER_DEFAULT));
         }
         
         if (name == "mipmap")

+ 0 - 1
Engine/Graphics/TextureCube.cpp

@@ -30,7 +30,6 @@
 #include "Profiler.h"
 #include "Renderer.h"
 #include "ResourceCache.h"
-#include "StringUtils.h"
 #include "TextureCube.h"
 #include "XMLFile.h"
 

+ 0 - 1
Engine/Graphics/VertexShader.cpp

@@ -30,7 +30,6 @@
 #include "Profiler.h"
 #include "ResourceCache.h"
 #include "SharedArrayPtr.h"
-#include "StringUtils.h"
 #include "VertexShader.h"
 #include "XMLFile.h"
 

+ 0 - 4
Engine/Graphics/View.cpp

@@ -45,12 +45,8 @@
 #include "View.h"
 #include "Zone.h"
 
-#include "Sort.h"
-
 #include "DebugNew.h"
 
-#include "StringUtils.h"
-
 static const String aaVariation[] = {
     "",
     "Ortho"

+ 0 - 1
Engine/IO/File.cpp

@@ -26,7 +26,6 @@
 #include "FileSystem.h"
 #include "Log.h"
 #include "PackageFile.h"
-#include "StringUtils.h"
 
 #include <cstdio>
 

+ 0 - 1
Engine/IO/FileSystem.cpp

@@ -27,7 +27,6 @@
 #include "FileSystem.h"
 #include "Log.h"
 #include "SharedArrayPtr.h"
-#include "StringUtils.h"
 
 #include <cstdio>
 #include <direct.h>

+ 0 - 1
Engine/IO/Log.cpp

@@ -26,7 +26,6 @@
 #include "File.h"
 #include "IOEvents.h"
 #include "Log.h"
-#include "StringUtils.h"
 
 #include <cstdio>
 #include <ctime>

+ 0 - 1
Engine/IO/PackageFile.cpp

@@ -25,7 +25,6 @@
 #include "File.h"
 #include "Log.h"
 #include "PackageFile.h"
-#include "StringUtils.h"
 
 OBJECTTYPESTATIC(PackageFile);
 

+ 0 - 1
Engine/Network/Connection.cpp

@@ -27,7 +27,6 @@
 #include "Protocol.h"
 #include "ProtocolEvents.h"
 #include "Scene.h"
-#include "StringUtils.h"
 
 #include "DebugNew.h"
 

+ 0 - 1
Engine/Network/Network.cpp

@@ -31,7 +31,6 @@
 #include "Peer.h"
 #include "ProcessUtils.h"
 #include "Profiler.h"
-#include "StringUtils.h"
 
 #include <enet/enet.h>
 

+ 0 - 1
Engine/Network/Peer.cpp

@@ -25,7 +25,6 @@
 #include "Log.h"
 #include "NetworkEvents.h"
 #include "Peer.h"
-#include "StringUtils.h"
 
 #include <enet/enet.h>
 

+ 0 - 1
Engine/Network/RemoteEvent.cpp

@@ -26,7 +26,6 @@
 #include "Log.h"
 #include "Protocol.h"
 #include "Scene.h"
-#include "StringUtils.h"
 
 #include "Set.h"
 

+ 0 - 1
Engine/Network/Server.cpp

@@ -33,7 +33,6 @@
 #include "ProtocolEvents.h"
 #include "Scene.h"
 #include "Server.h"
-#include "StringUtils.h"
 
 #include "DebugNew.h"
 

+ 0 - 1
Engine/Physics/CollisionShape.cpp

@@ -33,7 +33,6 @@
 #include "ResourceCache.h"
 #include "RigidBody.h"
 #include "Scene.h"
-#include "StringUtils.h"
 #include "XMLFile.h"
 
 #include <ode/ode.h>

+ 0 - 1
Engine/Physics/Joint.cpp

@@ -28,7 +28,6 @@
 #include "PhysicsWorld.h"
 #include "RigidBody.h"
 #include "Scene.h"
-#include "StringUtils.h"
 
 #include <ode/ode.h>
 

+ 0 - 1
Engine/Physics/PhysicsWorld.cpp

@@ -35,7 +35,6 @@
 #include "RigidBody.h"
 #include "Scene.h"
 #include "SceneEvents.h"
-#include "StringUtils.h"
 #include "VectorBuffer.h"
 
 #include <ode/ode.h>

+ 0 - 1
Engine/Physics/RigidBody.cpp

@@ -30,7 +30,6 @@
 #include "ResourceEvents.h"
 #include "RigidBody.h"
 #include "Scene.h"
-#include "StringUtils.h"
 #include "XMLElement.h"
 
 #include <ode/ode.h>

+ 0 - 1
Engine/Resource/Image.cpp

@@ -27,7 +27,6 @@
 #include "FileSystem.h"
 #include "Image.h"
 #include "Log.h"
-#include "StringUtils.h"
 
 #include <cstring>
 #include <ddraw.h>

+ 0 - 1
Engine/Resource/ResourceCache.cpp

@@ -29,7 +29,6 @@
 #include "PackageFile.h"
 #include "ResourceCache.h"
 #include "ResourceEvents.h"
-#include "StringUtils.h"
 #include "XMLFile.h"
 
 #include "DebugNew.h"

+ 0 - 1
Engine/Resource/XMLFile.cpp

@@ -26,7 +26,6 @@
 #include "File.h"
 #include "Log.h"
 #include "SharedArrayPtr.h"
-#include "StringUtils.h"
 #include "XMLFile.h"
 
 #include <tinyxml.h>

+ 0 - 1
Engine/Scene/Node.cpp

@@ -26,7 +26,6 @@
 #include "Context.h"
 #include "Log.h"
 #include "Scene.h"
-#include "StringUtils.h"
 #include "VectorBuffer.h"
 #include "XMLElement.h"
 

+ 2 - 3
Engine/Scene/Scene.cpp

@@ -31,14 +31,13 @@
 #include "Profiler.h"
 #include "Scene.h"
 #include "SceneEvents.h"
-#include "StringUtils.h"
 #include "XMLFile.h"
 
-OBJECTTYPESTATIC(Scene);
-
 static const int ASYNC_LOAD_MIN_FPS = 50;
 static const int ASYNC_LOAD_MAX_MSEC = (int)(1000.0f / ASYNC_LOAD_MIN_FPS);
 
+OBJECTTYPESTATIC(Scene);
+
 Scene::Scene(Context* context) :
     Node(context),
     networkMode_(NM_NONETWORK),

+ 0 - 1
Engine/Scene/Serializable.cpp

@@ -27,7 +27,6 @@
 #include "Log.h"
 #include "Serializable.h"
 #include "Serializer.h"
-#include "StringUtils.h"
 #include "XMLElement.h"
 
 #include "DebugNew.h"

+ 2 - 5
Engine/Script/Addons.cpp

@@ -23,7 +23,7 @@
 
 #include "Precompiled.h"
 #include "Addons.h"
-#include "StringUtils.h"
+#include "StringBase.h"
 
 #include <cstring>
 
@@ -560,7 +560,7 @@ void RegisterArray(asIScriptEngine* engine)
     engine->RegisterObjectMethod("Array<T>", "const T& opIndex(uint) const", asMETHOD(CScriptArray, At), asCALL_THISCALL);
     engine->RegisterObjectMethod("Array<T>", "Array<T> &opAssign(const Array<T>& in)", asMETHOD(CScriptArray, operator=), asCALL_THISCALL);
     engine->RegisterObjectMethod("Array<T>", "void Insert(uint, const T& in)", asMETHOD(CScriptArray, InsertAt), asCALL_THISCALL);
-    engine->RegisterObjectMethod("Array<T>", "void Remove(uint)", asMETHOD(CScriptArray, RemoveAt), asCALL_THISCALL);
+    engine->RegisterObjectMethod("Array<T>", "void Erase(uint)", asMETHOD(CScriptArray, RemoveAt), asCALL_THISCALL);
     engine->RegisterObjectMethod("Array<T>", "void Push(const T& in)", asMETHOD(CScriptArray, InsertLast), asCALL_THISCALL);
     engine->RegisterObjectMethod("Array<T>", "void Pop()", asMETHOD(CScriptArray, RemoveLast), asCALL_THISCALL);
     engine->RegisterObjectMethod("Array<T>", "void Resize(uint)", asMETHODPR(CScriptArray, Resize, (asUINT), void), asCALL_THISCALL);
@@ -569,9 +569,6 @@ void RegisterArray(asIScriptEngine* engine)
     engine->RegisterDefaultArrayType("Array<T>");
 }
 
-
-// Adapted from AngelScript's scriptstdstring add-on
-
 static String StringFactory(asUINT length, const char* s)
 {
     return String(s, length);

+ 0 - 1
Engine/Script/Script.cpp

@@ -30,7 +30,6 @@
 #include "Script.h"
 #include "ScriptFile.h"
 #include "ScriptInstance.h"
-#include "StringUtils.h"
 
 #include <angelscript.h>
 

+ 0 - 1
Engine/Script/ScriptFile.cpp

@@ -31,7 +31,6 @@
 #include "ScriptFile.h"
 #include "ScriptInstance.h"
 #include "SharedArrayPtr.h"
-#include "StringUtils.h"
 
 #include <angelscript.h>
 #include <cstring>

+ 0 - 1
Engine/Script/ScriptInstance.cpp

@@ -34,7 +34,6 @@
 #include "Script.h"
 #include "ScriptFile.h"
 #include "ScriptInstance.h"
-#include "StringUtils.h"
 #include "VectorBuffer.h"
 
 #include <angelscript.h>

+ 3 - 2
Engine/UI/Cursor.cpp

@@ -38,7 +38,8 @@ static const String shapeNames[] =
     "resizehorizontal",
     "resizediagonal_topleft",
     "acceptdrop",
-    "rejectdrop"
+    "rejectdrop",
+    ""
 };
 
 OBJECTTYPESTATIC(Cursor);
@@ -74,7 +75,7 @@ void Cursor::SetStyle(const XMLElement& element)
     XMLElement shapeElem = element.GetChildElement("shape");
     while (shapeElem)
     {
-        CursorShape shape = (CursorShape)GetStringListIndex(shapeElem.GetStringLower("name"), shapeNames, 7, 0);
+        CursorShape shape = (CursorShape)GetStringListIndex(shapeElem.GetStringLower("name"), shapeNames, CS_NORMAL);
         DefineShape(shape, GetSubsystem<ResourceCache>()->GetResource<Texture2D>(shapeElem.GetString("texture")),
             shapeElem.GetIntRect("imagerect"), shapeElem.GetIntVector2("hotspot"));
         shapeElem = shapeElem.GetNextElement("shape");

+ 1 - 1
Engine/UI/Font.cpp

@@ -22,6 +22,7 @@
 //
 
 #include "Precompiled.h"
+#include "AreaAllocator.h"
 #include "Context.h"
 #include "Deserializer.h"
 #include "Font.h"
@@ -29,7 +30,6 @@
 #include "GraphicsImpl.h"
 #include "Log.h"
 #include "Profiler.h"
-#include "StringUtils.h"
 #include "Texture2D.h"
 
 #include "ft2build.h"

+ 0 - 1
Engine/UI/Font.h

@@ -23,7 +23,6 @@
 
 #pragma once
 
-#include "AreaAllocator.h"
 #include "Resource.h"
 #include "SharedArrayPtr.h"
 

+ 3 - 2
Engine/UI/ListView.cpp

@@ -38,7 +38,8 @@ static const String highlightModes[] =
 {
     "never",
     "focus",
-    "always"
+    "always",
+    ""
 };
 
 int GetItemIndent(UIElement* item)
@@ -101,7 +102,7 @@ void ListView::SetStyle(const XMLElement& element)
     if (element.HasChildElement("highlight"))
     {
         String highlight = element.GetChildElement("highlight").GetStringLower("value");
-        SetHighlightMode((HighlightMode)GetStringListIndex(highlight, highlightModes, 3, 1));
+        SetHighlightMode((HighlightMode)GetStringListIndex(highlight, highlightModes, HM_FOCUS));
     }
     if (element.HasChildElement("multiselect"))
         SetMultiselect(element.GetChildElement("multiselect").GetBool("enable"));

+ 3 - 2
Engine/UI/Text.cpp

@@ -39,7 +39,8 @@ static const String horizontalAlignments[] =
 {
     "left",
     "center",
-    "right"
+    "right",
+    ""
 };
 
 OBJECTTYPESTATIC(Text);
@@ -114,7 +115,7 @@ void Text::SetStyle(const XMLElement& element)
         String horiz = element.GetChildElement("textalignment").GetStringLower("value");
         if (!horiz.Empty())
         {
-            textAlignment_ = (HorizontalAlignment)GetStringListIndex(horiz, horizontalAlignments, 3, 0);
+            textAlignment_ = (HorizontalAlignment)GetStringListIndex(horiz, horizontalAlignments, HA_LEFT);
             changed = true;
         }
     }

+ 0 - 1
Engine/UI/UI.cpp

@@ -42,7 +42,6 @@
 #include "ResourceCache.h"
 #include "ScrollBar.h"
 #include "Slider.h"
-#include "StringUtils.h"
 #include "Text.h"
 #include "Texture2D.h"
 #include "Time.h"

+ 12 - 8
Engine/UI/UIElement.cpp

@@ -34,14 +34,16 @@ static const String horizontalAlignments[] =
 {
     "left",
     "center",
-    "right"
+    "right",
+    ""
 };
 
 static const String verticalAlignments[] =
 {
     "top",
     "center",
-    "bottom"
+    "bottom",
+    ""
 };
 
 static const String focusModes[] =
@@ -49,7 +51,8 @@ static const String focusModes[] =
     "notfocusable",
     "resetfocus",
     "focusable",
-    "focusabledefocusable"
+    "focusabledefocusable",
+    ""
 };
 
 static const String dragDropModes[] =
@@ -57,7 +60,8 @@ static const String dragDropModes[] =
     "disabled",
     "source",
     "target",
-    "sourceandtarget"
+    "sourceandtarget",
+    ""
 };
 
 OBJECTTYPESTATIC(UIElement);
@@ -162,9 +166,9 @@ void UIElement::SetStyle(const XMLElement& element)
         if (alignElem.HasAttribute("v"))
             vert = alignElem.GetStringLower("v");
         if (!horiz.Empty())
-            SetHorizontalAlignment((HorizontalAlignment)GetStringListIndex(horiz, horizontalAlignments, 3, 0));
+            SetHorizontalAlignment((HorizontalAlignment)GetStringListIndex(horiz, horizontalAlignments, HA_LEFT));
         if (!vert.Empty())
-            SetVerticalAlignment((VerticalAlignment)GetStringListIndex(vert, verticalAlignments, 3, 0));
+            SetVerticalAlignment((VerticalAlignment)GetStringListIndex(vert, verticalAlignments, VA_TOP));
     }
     if (element.HasChildElement("clipborder"))
         SetClipBorder(element.GetChildElement("clipborder").GetIntRect("value"));
@@ -201,14 +205,14 @@ void UIElement::SetStyle(const XMLElement& element)
     if (element.HasChildElement("focusmode"))
     {
         String focusMode = element.GetChildElement("focusmode").GetStringLower("value");
-        SetFocusMode((FocusMode)GetStringListIndex(focusMode, focusModes, 4, 0));
+        SetFocusMode((FocusMode)GetStringListIndex(focusMode, focusModes, FM_NOTFOCUSABLE));
         if (focusMode == "defocusable")
             SetFocusMode(FM_FOCUSABLE_DEFOCUSABLE);
     }
     if (element.HasChildElement("dragdropmode"))
     {
         String dragDropMode = element.GetChildElement("dragdropmode").GetStringLower("value");
-        SetDragDropMode(GetStringListIndex(dragDropMode, dragDropModes, 4, 0));
+        SetDragDropMode(GetStringListIndex(dragDropMode, dragDropModes, DD_DISABLED));
     }
     if (element.HasChildElement("layout"))
     {

+ 0 - 1
Tools/NormalMapTool/NormalMapTool.cpp

@@ -25,7 +25,6 @@
 #include "File.h"
 #include "Image.h"
 #include "ProcessUtils.h"
-#include "StringUtils.h"
 
 #include <cstdlib>
 #include <stb_image.h>

+ 0 - 1
Tools/OgreImporter/OgreImporter.cpp

@@ -27,7 +27,6 @@
 #include "OgreImporterUtils.h"
 #include "ProcessUtils.h"
 #include "Sort.h"
-#include "StringUtils.h"
 #include "XMLFile.h"
 
 #include <cstring>

+ 0 - 1
Tools/PackageTool/PackageTool.cpp

@@ -26,7 +26,6 @@
 #include "FileSystem.h"
 #include "ProcessUtils.h"
 #include "SharedArrayPtr.h"
-#include "StringUtils.h"
 
 #include <cstdio>
 #include <cstdlib>

+ 14 - 6
Urho3D/Urho3D.cpp

@@ -31,6 +31,9 @@
 #include "ScriptFile.h"
 #include "Time.h"
 
+#include <string>
+#include <vector>
+
 #include <Windows.h>
 
 #include "DebugNew.h"
@@ -81,20 +84,25 @@ void Run(const char* cmdLine)
     }
     
     // Create the execution context and the engine
-    SharedPtr<Context> context(new Context());
-    SharedPtr<Engine> engine(new Engine(context));
+    SharedPtr<Context> context_(new Context());
+    SharedPtr<Engine> engine(new Engine(context_));
     if (!engine->Initialize("Urho3D", "Urho3D.log", arguments))
     {
-        ErrorDialog("Urho3D", context->GetSubsystem<Log>()->GetLastMessage().CString());
+        ErrorDialog("Urho3D", context_->GetSubsystem<Log>()->GetLastMessage().CString());
         return;
     }
     
+    LOGINFO("Size of std::string " + sizeof(std::string));
+    LOGINFO("Size of String " + sizeof(String));
+    LOGINFO("Size of std::vector " + sizeof(std::vector<int>));
+    LOGINFO("Size of Vector " + sizeof (Vector<int>));
+    
     // Set 5 ms timer period to allow accurate FPS limiting up to 200 FPS
-    context->GetSubsystem<Time>()->SetTimerPeriod(5);
+    context_->GetSubsystem<Time>()->SetTimerPeriod(5);
     
     // Execute the Start function from the script file, then run the engine loop until exited
     engine->InitializeScripting();
-    ScriptFile* scriptFile = context->GetSubsystem<ResourceCache>()->GetResource<ScriptFile>(scriptFileName);
+    ScriptFile* scriptFile = context_->GetSubsystem<ResourceCache>()->GetResource<ScriptFile>(scriptFileName);
     if ((scriptFile) && (scriptFile->Execute("void Start()")))
     {
         while (!engine->IsExiting())
@@ -103,6 +111,6 @@ void Run(const char* cmdLine)
     else
     {
         engine->Exit(); // Close the rendering window
-        ErrorDialog("Urho3D", context->GetSubsystem<Log>()->GetLastMessage().CString());
+        ErrorDialog("Urho3D", context_->GetSubsystem<Log>()->GetLastMessage().CString());
     }
 }