Merge remote-tracking branch 'refs/remotes/origin/development' into pr/1153

This commit is contained in:
Anis A. Hireche 2016-02-26 14:39:38 +01:00
commit 10cb6ab9c4
893 changed files with 44063 additions and 6437 deletions

View file

@ -503,6 +503,7 @@ inline ColorI& ColorI::operator*=(const S32 in_mul)
inline ColorI& ColorI::operator/=(const S32 in_mul)
{
AssertFatal(in_mul != 0.0f, "Error, div by zero...");
red = red / in_mul;
green = green / in_mul;
blue = blue / in_mul;

View file

@ -0,0 +1,86 @@
//-----------------------------------------------------------------------------
// Copyright (c) 2013 GarageGames, LLC
//
// 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.
//-----------------------------------------------------------------------------
#ifndef _FACTORY_CACHE_H_
#define _FACTORY_CACHE_H_
#ifndef _TVECTOR_H_
#include "core/util/tVector.h"
#endif
//-----------------------------------------------------------------------------
class IFactoryObjectReset
{
public:
virtual void resetState( void ) = 0;
};
//-----------------------------------------------------------------------------
template<class T>
class FactoryCache : private Vector<T*>
{
public:
FactoryCache()
{
}
virtual ~FactoryCache()
{
purgeCache();
}
T* createObject( void )
{
// Create a new object if cache is empty.
if ( this->size() == 0 )
return new T();
// Return a cached object.
T* pObject = this->back();
this->pop_back();
return pObject;
}
void cacheObject( T* pObject )
{
// Cache object.
this->push_back( pObject );
// Reset object state if available.
IFactoryObjectReset* pResetStateObject = dynamic_cast<IFactoryObjectReset*>( pObject );
if ( pResetStateObject != NULL )
pResetStateObject->resetState();
}
void purgeCache( void )
{
while( this->size() > 0 )
{
delete this->back();
this->pop_back();
}
}
};
#endif // _FACTORY_CACHE_H_

View file

@ -46,14 +46,14 @@ bool Module::_constrainedToComeBefore( Module* module, Mode mode )
Module* depModule = dependency->mModule;
if( !depModule )
{
depModule = ModuleManager::findModule( dependency->mModuleName );
depModule = EngineModuleManager::findModule( dependency->mModuleName );
if( !depModule )
{
// Module does not exist. Only emit a warning here so that modules
// can be omitted from a link without requiring the module definitions
// to be adapted.
Platform::outputDebugString( "[ModuleManager] Module %s of '%s' depends on module '%s' which does not exist",
Platform::outputDebugString( "[EngineModuleManager] Module %s of '%s' depends on module '%s' which does not exist",
mode == Module::ModeInitialize ? "init" : "shutdown",
module->getName(), dependency->mModuleName );
continue;
@ -86,14 +86,14 @@ bool Module::_constrainedToComeAfter( Module* module, Mode mode )
Module* depModule = dependency->mModule;
if( !depModule )
{
depModule = ModuleManager::findModule( dependency->mModuleName );
depModule = EngineModuleManager::findModule( dependency->mModuleName );
if( !depModule )
{
// Module does not exist. Only emit a warning here so that modules
// can be omitted from a link without requiring the module definitions
// to be adapted.
Platform::outputDebugString( "[ModuleManager] Module %s of '%s' depends on module '%s' which does not exist",
Platform::outputDebugString( "[EngineModuleManager] Module %s of '%s' depends on module '%s' which does not exist",
mode == Module::ModeInitialize ? "init" : "shutdown",
module->getName(), dependency->mModuleName );
continue;
@ -115,7 +115,7 @@ bool Module::_constrainedToComeAfter( Module* module, Mode mode )
//-----------------------------------------------------------------------------
String ModuleManager::_moduleListToString( Vector< Module* >& moduleList )
String EngineModuleManager::_moduleListToString( Vector< Module* >& moduleList )
{
StringBuilder str;
@ -136,14 +136,14 @@ String ModuleManager::_moduleListToString( Vector< Module* >& moduleList )
//-----------------------------------------------------------------------------
void ModuleManager::_printModuleList( Vector< Module* >& moduleList )
void EngineModuleManager::_printModuleList( Vector< Module* >& moduleList )
{
Platform::outputDebugString( _moduleListToString( moduleList ) );
}
//-----------------------------------------------------------------------------
void ModuleManager::_insertIntoModuleList( Module::Mode mode, Vector< Module* >& moduleList, Module* module )
void EngineModuleManager::_insertIntoModuleList( Module::Mode mode, Vector< Module* >& moduleList, Module* module )
{
// If this module is being overridden, switch over to
// the module overriding it.
@ -168,7 +168,7 @@ void ModuleManager::_insertIntoModuleList( Module::Mode mode, Vector< Module* >&
if( !module->_getDependencies( mode ) )
{
#if defined( DEBUG_SPEW ) && DEBUG_SPEW_LEVEL > 1
Platform::outputDebugString( "[ModuleManager] Appending '%s' to '%s'",
Platform::outputDebugString( "[EngineModuleManager] Appending '%s' to '%s'",
module->getName(), _moduleListToString( moduleList ).c_str() );
#endif
@ -179,7 +179,7 @@ void ModuleManager::_insertIntoModuleList( Module::Mode mode, Vector< Module* >&
// First make sure that all 'after' dependencies are in the list.
#if defined( DEBUG_SPEW ) && DEBUG_SPEW_LEVEL > 1
Platform::outputDebugString( "[ModuleManager] Resolving %s dependencies of '%s'",
Platform::outputDebugString( "[EngineModuleManager] Resolving %s dependencies of '%s'",
mode == Module::ModeInitialize ? "init" : "shutdown",
module->getName() );
#endif
@ -199,7 +199,7 @@ void ModuleManager::_insertIntoModuleList( Module::Mode mode, Vector< Module* >&
}
AssertFatal( _getIndexOfModuleInList( moduleList, module ) == -1,
avar( "ModuleManager::_insertModuleIntoList - Cycle in 'after' %s dependency chain of '%s'",
avar( "EngineModuleManager::_insertModuleIntoList - Cycle in 'after' %s dependency chain of '%s'",
mode == Module::ModeInitialize ? "init" : "shutdown",
module->getName() ) );
@ -212,7 +212,7 @@ void ModuleManager::_insertIntoModuleList( Module::Mode mode, Vector< Module* >&
const bool currentAfterThis = moduleList[ i ]->_constrainedToComeAfter( module, mode );
AssertFatal( !( thisBeforeCurrent && currentAfterThis ),
avar( "ModuleManager::_insertModuleIntoList - Ambiguous %s placement of module '%s' relative to '%s'",
avar( "EngineModuleManager::_insertModuleIntoList - Ambiguous %s placement of module '%s' relative to '%s'",
mode == Module::ModeInitialize ? "init" : "shutdown",
module->getName(), moduleList[ i ]->getName() ) );
@ -232,7 +232,7 @@ void ModuleManager::_insertIntoModuleList( Module::Mode mode, Vector< Module* >&
if( thisBeforeCurrent && !moduleList[ i ]->_getDependencies( mode ) && i != numModules - 1 )
{
#if defined( DEBUG_SPEW ) && DEBUG_SPEW_LEVEL > 1
Platform::outputDebugString( "[ModuleManager] Pushing '%s' to back end of chain for resolving '%s'",
Platform::outputDebugString( "[EngineModuleManager] Pushing '%s' to back end of chain for resolving '%s'",
moduleList[ i ]->getName(), module->getName() );
#endif
@ -251,7 +251,7 @@ void ModuleManager::_insertIntoModuleList( Module::Mode mode, Vector< Module* >&
for( U32 n = i + 1; n < numModules; ++ n )
AssertFatal( !( moduleList[ n ]->_constrainedToComeBefore( module, mode )
|| module->_constrainedToComeAfter( moduleList[ n ], mode ) ),
avar( "ModuleManager::_insertModuleIntoList - Ambiguous %s constraint on module '%s' to come before '%s' yet after '%s'",
avar( "EngineModuleManager::_insertModuleIntoList - Ambiguous %s constraint on module '%s' to come before '%s' yet after '%s'",
mode == Module::ModeInitialize ? "init" : "shutdown",
module->getName(),
moduleList[ i ]->getName(),
@ -260,7 +260,7 @@ void ModuleManager::_insertIntoModuleList( Module::Mode mode, Vector< Module* >&
// Add the module at this position.
#if defined( DEBUG_SPEW ) && DEBUG_SPEW_LEVEL > 1
Platform::outputDebugString( "[ModuleManager] Inserting '%s' at index %i into '%s'",
Platform::outputDebugString( "[EngineModuleManager] Inserting '%s' at index %i into '%s'",
module->getName(), i, _moduleListToString( moduleList ).c_str() );
#endif
@ -271,7 +271,7 @@ void ModuleManager::_insertIntoModuleList( Module::Mode mode, Vector< Module* >&
// No constraint-based position. Just append.
#if defined( DEBUG_SPEW ) && DEBUG_SPEW_LEVEL > 1
Platform::outputDebugString( "[ModuleManager] Appending '%s' to '%s'",
Platform::outputDebugString( "[EngineModuleManager] Appending '%s' to '%s'",
module->getName(), _moduleListToString( moduleList ).c_str() );
#endif
@ -280,7 +280,7 @@ void ModuleManager::_insertIntoModuleList( Module::Mode mode, Vector< Module* >&
//-----------------------------------------------------------------------------
Module* ModuleManager::_findOverrideFor( Module* module )
Module* EngineModuleManager::_findOverrideFor( Module* module )
{
const char* name = module->getName();
@ -294,7 +294,7 @@ Module* ModuleManager::_findOverrideFor( Module* module )
//-----------------------------------------------------------------------------
S32 ModuleManager::_getIndexOfModuleInList( Vector< Module* >& moduleList, Module* module )
S32 EngineModuleManager::_getIndexOfModuleInList( Vector< Module* >& moduleList, Module* module )
{
const U32 numModules = moduleList.size();
for( U32 i = 0; i < numModules; ++ i )
@ -306,7 +306,7 @@ S32 ModuleManager::_getIndexOfModuleInList( Vector< Module* >& moduleList, Modul
//-----------------------------------------------------------------------------
S32 ModuleManager::_getIndexOfModuleInList( Vector< Module* >& moduleList, const char* moduleName )
S32 EngineModuleManager::_getIndexOfModuleInList( Vector< Module* >& moduleList, const char* moduleName )
{
const U32 numModules = moduleList.size();
for( U32 i = 0; i < numModules; ++ i )
@ -318,7 +318,7 @@ S32 ModuleManager::_getIndexOfModuleInList( Vector< Module* >& moduleList, const
//-----------------------------------------------------------------------------
void ModuleManager::_createModuleList( Module::Mode mode, Vector< Module* >& moduleList )
void EngineModuleManager::_createModuleList( Module::Mode mode, Vector< Module* >& moduleList )
{
for( Module* module = Module::smFirst; module != NULL; module = module->mNext )
_insertIntoModuleList( mode, moduleList, module );
@ -326,7 +326,7 @@ void ModuleManager::_createModuleList( Module::Mode mode, Vector< Module* >& mod
//-----------------------------------------------------------------------------
void ModuleManager::initializeSystem()
void EngineModuleManager::initializeSystem()
{
Vector< Module* > modules;
@ -339,7 +339,7 @@ void ModuleManager::initializeSystem()
if( !module->mIsInitialized )
{
#ifdef DEBUG_SPEW
Platform::outputDebugString( "[ModuleManager] Initializing %s",
Platform::outputDebugString( "[EngineModuleManager] Initializing %s",
module->getName() );
#endif
@ -351,7 +351,7 @@ void ModuleManager::initializeSystem()
//-----------------------------------------------------------------------------
void ModuleManager::shutdownSystem()
void EngineModuleManager::shutdownSystem()
{
Vector< Module* > modules;
@ -363,7 +363,7 @@ void ModuleManager::shutdownSystem()
if( modules[ i ]->mIsInitialized )
{
#ifdef DEBUG_SPEW
Platform::outputDebugString( "[ModuleManager] Shutting down %s",
Platform::outputDebugString( "[EngineModuleManager] Shutting down %s",
modules[ i ]->getName() );
#endif
@ -375,7 +375,7 @@ void ModuleManager::shutdownSystem()
//-----------------------------------------------------------------------------
Module* ModuleManager::findModule( const char* name )
Module* EngineModuleManager::findModule( const char* name )
{
for( Module* module = Module::smFirst; module != NULL; module = module->mNext )
if( dStricmp( module->getName(), name ) == 0 )

View file

@ -42,7 +42,7 @@ class Module
public:
typedef void Parent;
friend struct ModuleManager;
friend struct EngineModuleManager;
protected:
@ -79,9 +79,9 @@ class Module
Dependency( Mode mode, DependencyType type, Module* parentModule, const char* moduleName )
: mType( type ),
mNext( mode == ModeInitialize ? parentModule->mInitDependencies : parentModule->mShutdownDependencies ),
mModuleName( moduleName ),
mModule( NULL )
mModule( NULL ),
mNext( mode == ModeInitialize ? parentModule->mInitDependencies : parentModule->mShutdownDependencies )
{
if( mode == ModeInitialize )
parentModule->mInitDependencies = this;
@ -141,11 +141,12 @@ class Module
}
Module()
: mNext( smFirst ),
: mIsInitialized( false ),
mNext( smFirst ),
mInitDependencies( NULL ),
mShutdownDependencies( NULL ),
mOverrides( NULL ),
mIsInitialized( false )
mOverrides( NULL )
{
smFirst = this;
}
@ -332,7 +333,7 @@ class Module
void _AfterModuleInit::initialize()
struct ModuleManager
struct EngineModuleManager
{
/// Initialize all modules registered with the system.
static void initializeSystem();

View file

@ -336,7 +336,7 @@ S32 BitStream::readInt(S32 bitCount)
void BitStream::writeInt(S32 val, S32 bitCount)
{
AssertWarn((bitCount == 32) || ((val >> bitCount) == 0), "BitStream::writeInt: value out of range");
AssertFatal((bitCount == 32) || ((val >> bitCount) == 0), avar("BitStream::writeInt: value out of range: %i/%i (%i bits)", val, 1 << bitCount, bitCount));
val = convertHostToLEndian(val);
writeBits(bitCount, &val);

View file

@ -39,15 +39,12 @@ FileStream *FileStream::createAndOpen(const String &inFileName, Torque::FS::File
{
FileStream *newStream = new FileStream;
if ( newStream )
{
bool success = newStream->open( inFileName, inMode );
bool success = newStream->open( inFileName, inMode );
if ( !success )
{
delete newStream;
newStream = NULL;
}
if ( !success )
{
delete newStream;
newStream = NULL;
}
return newStream;

View file

@ -123,6 +123,19 @@ void Stream::writeString(const char *string, S32 maxLen)
write(len, string);
}
bool Stream::writeFormattedBuffer(const char *format, ...)
{
char buffer[4096];
va_list args;
va_start(args, format);
const S32 length = dVsprintf(buffer, sizeof(buffer), format, args);
// Sanity!
AssertFatal(length <= sizeof(buffer), "writeFormattedBuffer - String format exceeded buffer size. This will cause corruption.");
return write(length, buffer);
}
void Stream::readString(char buf[256])
{
U8 len;

View file

@ -29,7 +29,9 @@
#ifndef _ENDIAN_H_
#include "core/util/endian.h"
#endif
#ifndef _STRINGFUNCTIONS_H_
#include "core/strings/stringFunctions.h"
#endif
/// @defgroup stream_overload Primitive Type Stream Operation Overloads
/// These macros declare the read and write functions for all primitive types.
@ -130,12 +132,21 @@ public:
/// writeString is safer.
void writeLongString(U32 maxStringLen, const char *string);
inline bool Put(char character) { return write(character); }
/// Write raw text to the stream
void writeText(const char *text);
/// Writes a string to the stream.
virtual void writeString(const char *stringBuf, S32 maxLen=255);
/// Writes a formatted buffer to the stream.
/// NOTE: A maximum string length of 4K is allowed.
bool writeFormattedBuffer(const char *format, ...);
/// Writes a NULL terminated string buffer.
bool writeStringBuffer(const char* buffer) { return write(dStrlen(buffer), buffer); }
// read/write real strings
void write(const String & str) { _write(str); }
void read(String * str) { _read(str); }

View file

@ -389,6 +389,7 @@ void dPrintf(const char *format, ...)
va_list args;
va_start(args, format);
vprintf(format, args);
va_end(args);
}
S32 dVprintf(const char *format, va_list arglist)
@ -402,6 +403,7 @@ S32 dSprintf(char *buffer, U32 bufferSize, const char *format, ...)
va_start(args, format);
S32 len = vsnprintf(buffer, bufferSize, format, args);
va_end(args);
AssertWarn( len < bufferSize, "Buffer too small in call to dSprintf!" );
@ -470,7 +472,9 @@ S32 dSscanf(const char *buffer, const char *format, ...)
#else
va_list args;
va_start(args, format);
return vsscanf(buffer, format, args);
S32 res = vsscanf(buffer, format, args);
va_end(args);
return res;
#endif
}

View file

@ -36,10 +36,12 @@
// These standard functions are not defined on Win32 and other Microsoft platforms...
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#endif
#if (_MSC_VER < 1800) && (defined(TORQUE_OS_WIN) || defined(TORQUE_OS_XBOX) || defined(TORQUE_OS_XENON))
#if _MSC_VER < 1800
#define strtof (float)strtod
#endif
#endif // _MSC_VER < 1800
#endif // defined(TORQUE_OS_WIN) || defined(TORQUE_OS_XBOX) || defined(TORQUE_OS_XENON)
//------------------------------------------------------------------------------

View file

@ -103,13 +103,17 @@ struct UTF16Cache
dMemcpy(mString, other.mString, mLength * sizeof(UTF16));
}
void operator =(const UTF16Cache &other)
UTF16Cache & operator =(const UTF16Cache &other)
{
delete [] mString;
if (&other != this)
{
delete [] mString;
mLength = other.mLength;
mString = new UTF16[mLength];
dMemcpy(mString, other.mString, mLength * sizeof(UTF16));
mLength = other.mLength;
mString = new UTF16[mLength];
dMemcpy(mString, other.mString, mLength * sizeof(UTF16));
}
return *this;
}
~UTF16Cache()

View file

@ -47,10 +47,9 @@
#ifndef FASTDELEGATE_H
#define FASTDELEGATE_H
#if _MSC_VER > 1000
#if defined(_MSC_VER) && (_MSC_VER > 1000)
#pragma once
#endif // _MSC_VER > 1000
#endif // defined(_MSC_VER) && (_MSC_VER > 1000)
////////////////////////////////////////////////////////////////////////////////
// Configuration options

View file

@ -58,7 +58,7 @@ class RawDataT
}
RawDataT( T* data, U32 size, bool ownMemory = false )
: data( data ), size( size ), ownMemory( ownMemory ) {}
: ownMemory( ownMemory ), data( data ), size( size ) {}
RawDataT(const ThisType& rd)
{

View file

@ -567,7 +567,6 @@ String::String(const StringChar *str, SizeType len)
PROFILE_SCOPE(String_char_len_constructor);
if (str && *str && len!=0)
{
AssertFatal(len<=dStrlen(str), "String::String: string too short");
_string = new ( len ) StringData( str );
}
else
@ -657,6 +656,11 @@ bool String::isEmpty() const
return ( _string == StringData::Empty() );
}
bool String::isEmpty(const char* str)
{
return str == 0 || str[0] == '\0';
}
bool String::isShared() const
{
return _string->isShared();

View file

@ -62,7 +62,7 @@ public:
String();
String(const String &str);
String(const StringChar *str);
String(const StringChar *str, SizeType size);
String(const StringChar *str, SizeType size); ///< Copy from raw data
String(const UTF16 *str);
~String();
@ -74,6 +74,7 @@ public:
SizeType size() const; ///< Returns the length of the string in bytes including the NULL terminator.
SizeType numChars() const; ///< Returns the length of the string in characters.
bool isEmpty() const; ///< Is this an empty string [""]?
static bool isEmpty(const char*); // is the input empty?
bool isNotEmpty() const { return !isEmpty(); } ///< Is this not an empty string [""]?
/// Erases all characters in a string.
@ -292,11 +293,10 @@ private:
// causes an ambiguous cast compile error. Making it private is simply
// more insurance that it isn't used on different compilers.
// NOTE: disable on GCC since it causes hyper casting to U32 on gcc.
#ifndef TORQUE_COMPILER_GCC
#if !defined(TORQUE_COMPILER_GCC) && !defined(__clang__)
operator const bool() const { return false; }
#endif
static void copy(StringChar *dst, const StringChar *src, U32 size);
StringData *_string;

View file

@ -863,5 +863,167 @@ inline Value& Map<Key,Value,Sequence>::operator[](const Key& key)
return mMap.findOrInsert(key)->value;
}
//-----------------------------------------------------------------------------
// iterator class
/// A HashMap template class.
/// The map class maps between a key and an associated value. Keys
/// are unique.
/// The hash table class is used as the default implementation so the
/// the key must be hashable, see util/hash.h for details.
/// @ingroup UtilContainers
template<typename Key, typename Value, class Sequence = HashTable<Key, Value> >
class HashMap : private Sequence
{
typedef HashTable<Key, Value> Parent;
private:
Sequence mHashMap;
public:
// types
typedef typename Parent::Pair Pair;
typedef Pair ValueType;
typedef Pair& Reference;
typedef const Pair& ConstReference;
typedef typename Parent::Iterator iterator;
typedef typename Parent::ConstIterator const_iterator;
typedef S32 DifferenceType;
typedef U32 SizeType;
// initialization
HashMap() {}
~HashMap() {}
HashMap(const HashMap& p);
// management
U32 size() const; ///< Return the number of elements
void clear(); ///< Empty the HashMap
bool isEmpty() const; ///< Returns true if the map is empty
// insert & erase elements
iterator insert(const Key& key, const Value&); // Documented below...
void erase(iterator); ///< Erase the given entry
void erase(const Key& key); ///< Erase the key from the map
// HashMap lookup
iterator find(const Key&); ///< Find entry for the given key
const_iterator find(const Key&) const; ///< Find entry for the given key
bool contains(const Key&a)
{
return mHashMap.count(a) > 0;
}
// forward iterator access
iterator begin(); ///< iterator to first element
const_iterator begin() const; ///< iterator to first element
iterator end(); ///< IIterator to last element + 1
const_iterator end() const; ///< iterator to last element + 1
// operators
Value& operator[](const Key&); ///< Index using the given key. If the key is not currently in the map it is added.
};
template<typename Key, typename Value, class Sequence> HashMap<Key, Value, Sequence>::HashMap(const HashMap& p)
{
*this = p;
}
//-----------------------------------------------------------------------------
// management
template<typename Key, typename Value, class Sequence>
inline U32 HashMap<Key, Value, Sequence>::size() const
{
return mHashMap.size();
}
template<typename Key, typename Value, class Sequence>
inline void HashMap<Key, Value, Sequence>::clear()
{
mHashMap.clear();
}
template<typename Key, typename Value, class Sequence>
inline bool HashMap<Key, Value, Sequence>::isEmpty() const
{
return mHashMap.isEmpty();
}
//-----------------------------------------------------------------------------
// add & remove elements
/// Insert the key value pair but don't allow duplicates.
/// The map class does not allow duplicates keys. If the key already exists in
/// the map the function will fail and return end().
template<typename Key, typename Value, class Sequence>
typename HashMap<Key, Value, Sequence>::iterator HashMap<Key, Value, Sequence>::insert(const Key& key, const Value& x)
{
return mHashMap.insertUnique(key, x);
}
template<typename Key, typename Value, class Sequence>
void HashMap<Key, Value, Sequence>::erase(const Key& key)
{
mHashMap.erase(key);
}
template<typename Key, typename Value, class Sequence>
void HashMap<Key, Value, Sequence>::erase(iterator node)
{
mHashMap.erase(node);
}
//-----------------------------------------------------------------------------
// Searching
template<typename Key, typename Value, class Sequence>
typename HashMap<Key, Value, Sequence>::iterator HashMap<Key, Value, Sequence>::find(const Key& key)
{
return mHashMap.find(key);
}
//-----------------------------------------------------------------------------
// iterator access
template<typename Key, typename Value, class Sequence>
inline typename HashMap<Key, Value, Sequence>::iterator HashMap<Key, Value, Sequence>::begin()
{
return mHashMap.begin();
}
template<typename Key, typename Value, class Sequence>
inline typename HashMap<Key, Value, Sequence>::const_iterator HashMap<Key, Value, Sequence>::begin() const
{
return mHashMap.begin();
}
template<typename Key, typename Value, class Sequence>
inline typename HashMap<Key, Value, Sequence>::iterator HashMap<Key, Value, Sequence>::end()
{
return mHashMap.end();
}
template<typename Key, typename Value, class Sequence>
inline typename HashMap<Key, Value, Sequence>::const_iterator HashMap<Key, Value, Sequence>::end() const
{
return mHashMap.end();
}
//-----------------------------------------------------------------------------
// operators
template<typename Key, typename Value, class Sequence>
inline Value& HashMap<Key, Value, Sequence>::operator[](const Key& key)
{
return mHashMap.findOrInsert(key)->value;
}
#endif

View file

@ -45,7 +45,7 @@ class UnmanagedVector
UnmanagedVector()
: mCount( 0 ), mArray( NULL ) {}
UnmanagedVector( T* array, U32 count )
: mArray( array ), mCount( count ) {}
: mCount( count ), mArray( array ) {}
U32 size() const { return mCount; }
bool empty() const { return ( mCount == 0 ); }

View file

@ -684,13 +684,13 @@ template<class T> inline void Vector<T>::pop_back()
template<class T> inline T& Vector<T>::operator[](U32 index)
{
AssertFatal(index < mElementCount, "Vector<T>::operator[] - out of bounds array access!");
AssertFatal(index < mElementCount, avar("Vector<T>::operator[%i/%i] - out of bounds array access!", index, mElementCount));
return mArray[index];
}
template<class T> inline const T& Vector<T>::operator[](U32 index) const
{
AssertFatal(index < mElementCount, "Vector<T>::operator[] - out of bounds array access!");
AssertFatal(index < mElementCount, avar("Vector<T>::operator[%i/%i] - out of bounds array access!", index, mElementCount));
return mArray[index];
}

View file

@ -39,7 +39,7 @@ protected:
const UTF16* mUTF16;
U32 mLength;
StrTest() : mData( 0 ), mUTF16( 0 ) {}
StrTest() : mData( 0 ), mUTF16( 0 ), mLength( 0 ) {}
StrTest( const char* str )
: mData( str ), mLength( str ? dStrlen( str ) : 0 ), mUTF16( NULL )
{