Merge changes from the witness.
This commit is contained in:
@ -275,12 +275,14 @@ namespace nv
|
||||
}
|
||||
|
||||
/// Remove the first instance of the given element.
|
||||
void remove(const T & element)
|
||||
bool remove(const T & element)
|
||||
{
|
||||
for (uint i = 0; i < m_size; i++) {
|
||||
removeAt(i);
|
||||
break;
|
||||
uint index;
|
||||
if (find(element, &index)) {
|
||||
removeAt(index);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Insert the given element at the given index shifting all the elements up.
|
||||
@ -342,7 +344,7 @@ namespace nv
|
||||
}
|
||||
|
||||
if( m_size == 0 ) {
|
||||
//Allocate(0); // Don't shrink automatically.
|
||||
//allocate(0); // Don't shrink automatically.
|
||||
}
|
||||
else if( m_size <= m_buffer_size/* && m_size > m_buffer_size >> 1*/) {
|
||||
// don't compact yet.
|
||||
@ -382,7 +384,7 @@ namespace nv
|
||||
}
|
||||
|
||||
if( m_size == 0 ) {
|
||||
//Allocate(0); // Don't shrink automatically.
|
||||
//allocate(0); // Don't shrink automatically.
|
||||
}
|
||||
else if( m_size <= m_buffer_size && m_size > m_buffer_size >> 1 ) {
|
||||
// don't compact yet.
|
||||
|
@ -48,9 +48,6 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#include <stdexcept> // std::runtime_error
|
||||
#undef assert // defined on mingw
|
||||
|
||||
using namespace nv;
|
||||
|
||||
namespace
|
||||
@ -356,7 +353,7 @@ namespace
|
||||
|
||||
if( ret == NV_ABORT_EXIT ) {
|
||||
// Exit cleanly.
|
||||
throw std::runtime_error("Assertion failed");
|
||||
throw "Assertion failed";
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
@ -24,7 +24,6 @@
|
||||
#if _MSC_VER < 1500
|
||||
# define vsnprintf _vsnprintf
|
||||
#endif
|
||||
#define vsscanf _vsscanf
|
||||
#define chdir _chdir
|
||||
#define getcwd _getcwd
|
||||
|
||||
|
@ -5,12 +5,13 @@
|
||||
|
||||
#include "nvcore.h"
|
||||
#include "Debug.h"
|
||||
#include "RefCounted.h" // WeakProxy
|
||||
|
||||
|
||||
|
||||
namespace nv
|
||||
{
|
||||
class WeakProxy;
|
||||
|
||||
/** Simple auto pointer template class.
|
||||
*
|
||||
* This is very similar to the standard auto_ptr class, but with some
|
||||
@ -273,7 +274,7 @@ namespace nv
|
||||
|
||||
void operator=(T * p)
|
||||
{
|
||||
if (p != NULL) {
|
||||
if (p) {
|
||||
m_proxy = p->getWeakProxy();
|
||||
nvDebugCheck(m_proxy != NULL);
|
||||
nvDebugCheck(m_proxy->ptr() == p);
|
||||
|
@ -9,12 +9,6 @@
|
||||
#include <stdarg.h> // vsnprintf
|
||||
#endif
|
||||
|
||||
#if NV_OS_WIN32
|
||||
#define NV_PATH_SEPARATOR '\\'
|
||||
#else
|
||||
#define NV_PATH_SEPARATOR '/'
|
||||
#endif
|
||||
|
||||
using namespace nv;
|
||||
|
||||
namespace
|
||||
@ -230,7 +224,7 @@ StringBuilder & StringBuilder::format( const char * fmt, ... )
|
||||
va_list arg;
|
||||
va_start( arg, fmt );
|
||||
|
||||
format( fmt, arg );
|
||||
formatList( fmt, arg );
|
||||
|
||||
va_end( arg );
|
||||
|
||||
@ -239,7 +233,7 @@ StringBuilder & StringBuilder::format( const char * fmt, ... )
|
||||
|
||||
|
||||
/** Format a string safely. */
|
||||
StringBuilder & StringBuilder::format( const char * fmt, va_list arg )
|
||||
StringBuilder & StringBuilder::formatList( const char * fmt, va_list arg )
|
||||
{
|
||||
nvDebugCheck(fmt != NULL);
|
||||
|
||||
@ -315,14 +309,14 @@ StringBuilder & StringBuilder::append( const char * s )
|
||||
|
||||
|
||||
/** Append a formatted string. */
|
||||
StringBuilder & StringBuilder::appendFormat( const char * format, ... )
|
||||
StringBuilder & StringBuilder::appendFormat( const char * fmt, ... )
|
||||
{
|
||||
nvDebugCheck( format != NULL );
|
||||
nvDebugCheck( fmt != NULL );
|
||||
|
||||
va_list arg;
|
||||
va_start( arg, format );
|
||||
va_start( arg, fmt );
|
||||
|
||||
appendFormat( format, arg );
|
||||
appendFormatList( fmt, arg );
|
||||
|
||||
va_end( arg );
|
||||
|
||||
@ -331,16 +325,21 @@ StringBuilder & StringBuilder::appendFormat( const char * format, ... )
|
||||
|
||||
|
||||
/** Append a formatted string. */
|
||||
StringBuilder & StringBuilder::appendFormat( const char * format, va_list arg )
|
||||
StringBuilder & StringBuilder::appendFormatList( const char * fmt, va_list arg )
|
||||
{
|
||||
nvDebugCheck( format != NULL );
|
||||
nvDebugCheck( fmt != NULL );
|
||||
|
||||
va_list tmp;
|
||||
va_copy(tmp, arg);
|
||||
|
||||
StringBuilder tmp_str;
|
||||
tmp_str.format( format, tmp );
|
||||
append( tmp_str );
|
||||
if (m_size == 0) {
|
||||
formatList(fmt, arg);
|
||||
}
|
||||
else {
|
||||
StringBuilder tmp_str;
|
||||
tmp_str.formatList( fmt, tmp );
|
||||
append( tmp_str );
|
||||
}
|
||||
|
||||
va_end(tmp);
|
||||
|
||||
@ -459,17 +458,13 @@ const char * Path::extension() const
|
||||
|
||||
|
||||
/// Toggles path separators (ie. \\ into /).
|
||||
void Path::translatePath()
|
||||
void Path::translatePath(char pathSeparator /*= NV_PATH_SEPARATOR*/)
|
||||
{
|
||||
nvCheck( m_str != NULL );
|
||||
|
||||
for(int i = 0; ; i++) {
|
||||
if( m_str[i] == '\0' ) break;
|
||||
#if NV_PATH_SEPARATOR == '/'
|
||||
if( m_str[i] == '\\' ) m_str[i] = NV_PATH_SEPARATOR;
|
||||
#else
|
||||
if( m_str[i] == '/' ) m_str[i] = NV_PATH_SEPARATOR;
|
||||
#endif
|
||||
for (int i = 0; ; i++) {
|
||||
if (m_str[i] == '\0') break;
|
||||
if (m_str[i] == '\\' || m_str[i] == '/') m_str[i] = pathSeparator;
|
||||
}
|
||||
}
|
||||
|
||||
@ -501,13 +496,13 @@ void Path::stripExtension()
|
||||
nvCheck( m_str != NULL );
|
||||
|
||||
int length = (int)strlen(m_str) - 1;
|
||||
while( length > 0 && m_str[length] != '.' ) {
|
||||
while (length > 0 && m_str[length] != '.') {
|
||||
length--;
|
||||
if( m_str[length] == NV_PATH_SEPARATOR ) {
|
||||
return; // no extension
|
||||
}
|
||||
}
|
||||
if( length ) {
|
||||
if (length > 0) {
|
||||
m_str[length] = 0;
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,11 @@
|
||||
|
||||
#include <string.h> // strlen, strcmp, etc.
|
||||
|
||||
#if NV_OS_WIN32
|
||||
#define NV_PATH_SEPARATOR '\\'
|
||||
#else
|
||||
#define NV_PATH_SEPARATOR '/'
|
||||
#endif
|
||||
|
||||
namespace nv
|
||||
{
|
||||
@ -32,6 +37,7 @@ namespace nv
|
||||
};
|
||||
|
||||
|
||||
|
||||
NVCORE_API int strCaseCmp(const char * s1, const char * s2) NV_PURE;
|
||||
NVCORE_API int strCmp(const char * s1, const char * s2) NV_PURE;
|
||||
|
||||
@ -60,11 +66,11 @@ namespace nv
|
||||
~StringBuilder();
|
||||
|
||||
StringBuilder & format( const char * format, ... ) __attribute__((format (printf, 2, 3)));
|
||||
StringBuilder & format( const char * format, va_list arg );
|
||||
StringBuilder & formatList( const char * format, va_list arg );
|
||||
|
||||
StringBuilder & append( const char * str );
|
||||
StringBuilder & appendFormat( const char * format, ... ) __attribute__((format (printf, 2, 3)));
|
||||
StringBuilder & appendFormat( const char * format, va_list arg );
|
||||
StringBuilder & appendFormatList( const char * format, va_list arg );
|
||||
|
||||
StringBuilder & number( int i, int base = 10 );
|
||||
StringBuilder & number( uint i, int base = 10 );
|
||||
@ -142,7 +148,7 @@ namespace nv
|
||||
const char * fileName() const;
|
||||
const char * extension() const;
|
||||
|
||||
void translatePath();
|
||||
void translatePath(char pathSeparator = NV_PATH_SEPARATOR);
|
||||
|
||||
void stripFileName();
|
||||
void stripExtension();
|
||||
@ -361,6 +367,10 @@ namespace nv
|
||||
|
||||
};
|
||||
|
||||
template <> struct Hash<String> {
|
||||
uint operator()(const String & str) const { return str.hash(); }
|
||||
};
|
||||
|
||||
} // nv namespace
|
||||
|
||||
#endif // NV_CORE_STRING_H
|
||||
|
@ -37,27 +37,27 @@
|
||||
#define NV_OS_STRING POSH_OS_STRING
|
||||
|
||||
#if defined POSH_OS_LINUX
|
||||
# define NV_OS_LINUX 1
|
||||
# define NV_OS_UNIX 1
|
||||
# define NV_OS_LINUX 1
|
||||
# define NV_OS_UNIX 1
|
||||
#elif defined POSH_OS_FREEBSD
|
||||
# define NV_OS_FREEBSD 1
|
||||
# define NV_OS_UNIX 1
|
||||
# define NV_OS_FREEBSD 1
|
||||
# define NV_OS_UNIX 1
|
||||
#elif defined POSH_OS_CYGWIN32
|
||||
# define NV_OS_CYGWIN 1
|
||||
# define NV_OS_CYGWIN 1
|
||||
#elif defined POSH_OS_MINGW
|
||||
# define NV_OS_MINGW 1
|
||||
# define NV_OS_WIN32 1
|
||||
# define NV_OS_MINGW 1
|
||||
# define NV_OS_WIN32 1
|
||||
#elif defined POSH_OS_OSX
|
||||
# define NV_OS_DARWIN 1
|
||||
# define NV_OS_UNIX 1
|
||||
# define NV_OS_DARWIN 1
|
||||
# define NV_OS_UNIX 1
|
||||
#elif defined POSH_OS_UNIX
|
||||
# define NV_OS_UNIX 1
|
||||
# define NV_OS_UNIX 1
|
||||
#elif defined POSH_OS_WIN32
|
||||
# define NV_OS_WIN32 1
|
||||
# define NV_OS_WIN32 1
|
||||
#elif defined POSH_OS_WIN64
|
||||
# define NV_OS_WIN64 1
|
||||
# define NV_OS_WIN64 1
|
||||
#else
|
||||
# error "Unsupported OS"
|
||||
# error "Unsupported OS"
|
||||
#endif
|
||||
|
||||
// CPUs:
|
||||
@ -151,8 +151,8 @@
|
||||
/// @hideinitializer
|
||||
#define NV_UNUSED(a) ((a)=(a))
|
||||
|
||||
/// Null index. @@ Move this somewhere else... This could have collisions with other definitions!
|
||||
#define NIL uint(~0)
|
||||
/// Null index. @@ Move this somewhere else... it's only used by nvmesh.
|
||||
const unsigned int NIL = unsigned int(~0);
|
||||
|
||||
/// Null pointer.
|
||||
#ifndef NULL
|
||||
|
Reference in New Issue
Block a user