sync with private repository.
This commit is contained in:
@ -34,3 +34,7 @@ ENDIF(NVCORE_SHARED)
|
||||
|
||||
TARGET_LINK_LIBRARIES(nvcore ${LIBS})
|
||||
|
||||
INSTALL(TARGETS nvcore
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib/static)
|
||||
|
@ -13,6 +13,8 @@
|
||||
#define NV_ABORT_IGNORE 2
|
||||
#define NV_ABORT_EXIT 3
|
||||
|
||||
#undef assert // avoid conflicts with assert method.
|
||||
|
||||
#define nvNoAssert(exp) \
|
||||
do { \
|
||||
(void)sizeof(exp); \
|
||||
|
@ -13,6 +13,7 @@ namespace nv
|
||||
// Portable version of fopen.
|
||||
inline FILE * fileOpen(const char * fileName, const char * mode)
|
||||
{
|
||||
nvCheck(fileName != NULL);
|
||||
#if NV_CC_MSVC && _MSC_VER >= 1400
|
||||
FILE * fp;
|
||||
if (fopen_s(&fp, fileName, mode) == 0) {
|
||||
@ -48,6 +49,7 @@ public:
|
||||
virtual void seek( int pos )
|
||||
{
|
||||
nvDebugCheck(m_fp != NULL);
|
||||
nvDebugCheck(pos >= 0 && pos < size());
|
||||
fseek(m_fp, pos, SEEK_SET);
|
||||
}
|
||||
|
||||
@ -59,6 +61,7 @@ public:
|
||||
|
||||
virtual int size() const
|
||||
{
|
||||
nvDebugCheck(m_fp != NULL);
|
||||
int pos = ftell(m_fp);
|
||||
fseek(m_fp, 0, SEEK_END);
|
||||
int end = ftell(m_fp);
|
||||
|
@ -196,6 +196,12 @@ StringBuilder::StringBuilder( const StringBuilder & s ) : m_size(0), m_str(NULL)
|
||||
copy(s);
|
||||
}
|
||||
|
||||
/** Copy string. */
|
||||
StringBuilder::StringBuilder( const char * s )
|
||||
{
|
||||
copy(s);
|
||||
}
|
||||
|
||||
/** Allocate and copy string. */
|
||||
StringBuilder::StringBuilder( int size_hint, const StringBuilder & s) : m_size(size_hint), m_str(NULL)
|
||||
{
|
||||
|
@ -44,6 +44,7 @@ namespace nv
|
||||
|
||||
NVCORE_API StringBuilder();
|
||||
NVCORE_API explicit StringBuilder( int size_hint );
|
||||
NVCORE_API StringBuilder( const char * str );
|
||||
NVCORE_API StringBuilder( const StringBuilder & );
|
||||
NVCORE_API StringBuilder( int size_hint, const StringBuilder & );
|
||||
NVCORE_API StringBuilder( const char * format, ... ) __attribute__((format (printf, 2, 3)));
|
||||
@ -69,7 +70,7 @@ namespace nv
|
||||
NVCORE_API StringBuilder & toUpper();
|
||||
|
||||
NVCORE_API void reset();
|
||||
NVCORE_API bool empty() const { return m_size == 0; }
|
||||
NVCORE_API bool isNull() const { return m_size == 0; }
|
||||
|
||||
// const char * accessors
|
||||
operator const char * () const { return m_str; }
|
||||
@ -81,22 +82,27 @@ namespace nv
|
||||
StringBuilder & operator=( const StringBuilder & s ) {
|
||||
return copy(s);
|
||||
}
|
||||
|
||||
|
||||
/// Implement value semantics.
|
||||
StringBuilder & operator=( const char * s ) {
|
||||
return copy(s);
|
||||
}
|
||||
|
||||
/// Equal operator.
|
||||
bool operator==( const StringBuilder & s ) const {
|
||||
nvCheck(m_str != NULL);
|
||||
nvCheck(s.m_str != NULL);
|
||||
return strcmp(s.m_str, m_str) != 0;
|
||||
if (s.isNull()) return isNull();
|
||||
else if (isNull()) return false;
|
||||
else return strcmp(s.m_str, m_str) != 0;
|
||||
}
|
||||
|
||||
/// Return the exact length.
|
||||
uint length() const { nvCheck(m_str != NULL); return uint(strlen(m_str)); }
|
||||
uint length() const { return isNull() ? 0 : uint(strlen(m_str)); }
|
||||
|
||||
/// Return the size of the string container.
|
||||
uint capacity() const { nvCheck(m_str != NULL); return m_size; }
|
||||
uint capacity() const { return m_size; }
|
||||
|
||||
/// Return the hash of the string.
|
||||
uint hash() const { nvCheck(m_str != NULL); return strHash(m_str); }
|
||||
uint hash() const { return isNull() ? 0 : strHash(m_str); }
|
||||
|
||||
/// Swap strings.
|
||||
friend void swap(StringBuilder & a, StringBuilder & b) {
|
||||
@ -104,8 +110,6 @@ namespace nv
|
||||
nv::swap(a.m_str, b.m_str);
|
||||
}
|
||||
|
||||
static char separator();
|
||||
|
||||
protected:
|
||||
|
||||
/// Size of the string container.
|
||||
|
Reference in New Issue
Block a user