Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Lambermont <hans@lambermont.dyndns.org>2002-10-12 15:37:38 +0400
committerHans Lambermont <hans@lambermont.dyndns.org>2002-10-12 15:37:38 +0400
commit12315f4d0e0ae993805f141f64cb8c73c5297311 (patch)
tree59b45827cd8293cfb727758989c7a74b40183974 /intern/string
Initial revisionv2.25
Diffstat (limited to 'intern/string')
-rw-r--r--intern/string/Makefile52
-rw-r--r--intern/string/STR_HashedString.h154
-rw-r--r--intern/string/STR_String.h202
-rw-r--r--intern/string/intern/Makefile42
-rw-r--r--intern/string/intern/STR_String.cpp743
-rw-r--r--intern/string/make/msvc_6_0/string.dsp122
-rw-r--r--intern/string/make/msvc_6_0/string.dsw29
7 files changed, 1344 insertions, 0 deletions
diff --git a/intern/string/Makefile b/intern/string/Makefile
new file mode 100644
index 00000000000..b2ae80e2179
--- /dev/null
+++ b/intern/string/Makefile
@@ -0,0 +1,52 @@
+#
+# $Id$
+#
+# ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version. The Blender
+# Foundation also sells licenses for use in proprietary software under
+# the Blender License. See http://www.blender.org/BL/ for information
+# about this.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): none yet.
+#
+# ***** END GPL/BL DUAL LICENSE BLOCK *****
+# string main makefile.
+#
+
+include nan_definitions.mk
+
+LIBNAME = string
+SOURCEDIR = intern/$(LIBNAME)
+DIR = $(OCGDIR)/$(SOURCEDIR)
+DIRS = intern
+# not yet TESTDIRS = test
+
+include nan_subdirs.mk
+
+install: all debug
+ @[ -d $(NAN_STRING) ] || mkdir $(NAN_STRING)
+ @[ -d $(NAN_STRING)/include ] || mkdir $(NAN_STRING)/include
+ @[ -d $(NAN_STRING)/lib ] || mkdir $(NAN_STRING)/lib
+ @[ -d $(NAN_STRING)/lib/debug ] || mkdir $(NAN_STRING)/lib/debug
+ cp -f $(DIR)/libstring.a $(NAN_STRING)/lib/
+ cp -f $(DIR)/debug/libstring.a $(NAN_STRING)/lib/debug/
+ cp -f *.h $(NAN_STRING)/include/
+
diff --git a/intern/string/STR_HashedString.h b/intern/string/STR_HashedString.h
new file mode 100644
index 00000000000..bf18a4e4da6
--- /dev/null
+++ b/intern/string/STR_HashedString.h
@@ -0,0 +1,154 @@
+/**
+ * $Id$
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+
+/**
+
+ * $Id$
+ * Copyright (C) 2001 NaN Technologies B.V.
+ * This file was formerly known as: GEN_StdString.cpp.
+ * @date November, 14, 2001
+ */
+
+#ifndef __STR_HASHSTRING
+#define __STR_HASHSTRING
+
+#include "STR_String.h"
+
+
+// Hash Mix utility function, by Bob Jenkins - Mix 3 32-bit values reversibly
+//
+// - If gHashMix() is run forward or backward, at least 32 bits in a,b,c have at
+// least 1/4 probability of changing.
+//
+// - If gHashMix() is run forward, every bit of c will change between 1/3 and
+// 2/3 of the time.
+//
+static inline void STR_gHashMix(dword& a, dword& b, dword& c)
+{
+ a -= b; a -= c; a ^= (c>>13);
+ b -= c; b -= a; b ^= (a<<8);
+ c -= a; c -= b; c ^= (b>>13);
+ a -= b; a -= c; a ^= (c>>12);
+ b -= c; b -= a; b ^= (a<<16);
+ c -= a; c -= b; c ^= (b>>5);
+ a -= b; a -= c; a ^= (c>>3);
+ b -= c; b -= a; b ^= (a<<10);
+ c -= a; c -= b; c ^= (b>>15);
+}
+
+//
+// Fast Hashable<int32> functionality
+// http://www.concentric.net/~Ttwang/tech/inthash.htm
+//
+static inline dword STR_gHash(dword inDWord)
+{
+ dword key = inDWord;
+ key += ~(key << 16);
+ key ^= (key >> 5);
+ key += (key << 3);
+ key ^= (key >> 13);
+ key += ~(key << 9);
+ key ^= (key >> 17);
+ return key;
+}
+
+enum { GOLDEN_RATIO = 0x9e3779b9 }; // arbitrary value to initialize hash funtion, well not so arbitrary
+ // as this value is taken from the pigs library (Orange Games/Lost Boys)
+
+
+
+static dword STR_gHash(const void* in, int len, dword init_val)
+{
+ unsigned int length = len;
+ dword a = (dword)GOLDEN_RATIO;
+ dword b = (dword)GOLDEN_RATIO;
+ dword c = init_val; // the previous hash value
+ byte *p_in = (byte *)in;
+
+ // Do the largest part of the key
+ while (length >= 12)
+ {
+ a += (p_in[0] + ((dword)p_in[1]<<8) + ((dword)p_in[2] <<16) + ((dword)p_in[3] <<24));
+ b += (p_in[4] + ((dword)p_in[5]<<8) + ((dword)p_in[6] <<16) + ((dword)p_in[7] <<24));
+ c += (p_in[8] + ((dword)p_in[9]<<8) + ((dword)p_in[10]<<16) + ((dword)p_in[11]<<24));
+ STR_gHashMix(a, b, c);
+ p_in += 12; length -= 12;
+ }
+
+ // Handle the last 11 bytes
+ c += len;
+ switch(length) {
+ case 11: c+=((dword)p_in[10]<<24);
+ case 10: c+=((dword)p_in[9]<<16);
+ case 9 : c+=((dword)p_in[8]<<8); // the first byte of c is reserved for the length
+ case 8 : b+=((dword)p_in[7]<<24);
+ case 7 : b+=((dword)p_in[6]<<16);
+ case 6 : b+=((dword)p_in[5]<<8);
+ case 5 : b+=p_in[4];
+ case 4 : a+=((dword)p_in[3]<<24);
+ case 3 : a+=((dword)p_in[2]<<16);
+ case 2 : a+=((dword)p_in[1]<<8);
+ case 1 : a+=p_in[0];
+ }
+ STR_gHashMix(a, b, c);
+
+ return c;
+}
+
+
+
+
+class STR_HashedString : public STR_String
+{
+public:
+ STR_HashedString() : STR_String(),m_Hashed(false) {}
+ STR_HashedString(const char* str) : STR_String(str),m_Hashed(false) {}
+ STR_HashedString(const STR_String& str) : STR_String(str),m_Hashed(false) {}
+
+ inline dword hash(dword init=0) const
+ {
+ if (!m_Hashed)
+ {
+ const char* str = *this;
+ int length = this->Length();
+ m_CachedHash = STR_gHash(str,length,init);
+ m_Hashed=true;
+ }
+ return m_CachedHash;
+ }
+
+private:
+ mutable bool m_Hashed;
+ mutable dword m_CachedHash;
+};
+
+#endif //__STR_HASHSTRING
+
diff --git a/intern/string/STR_String.h b/intern/string/STR_String.h
new file mode 100644
index 00000000000..78bef5f6728
--- /dev/null
+++ b/intern/string/STR_String.h
@@ -0,0 +1,202 @@
+/**
+ * $Id$
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+
+/**
+
+ * $Id$
+ * Copyright (C) 2001 NaN Technologies B.V.
+ * This file was formerly known as: GEN_StdString.h.
+ * @date April, 25, 2001
+ */
+
+#ifndef _STR_String_H_
+#define _STR_String_H_
+
+#ifndef STR_NO_ASSERTD
+#undef assertd
+#define assertd(exp) ((void)NULL)
+#endif
+
+#include <vector>
+#include <limits.h>
+using namespace std;
+
+
+class STR_String;
+
+typedef unsigned long dword;
+typedef const STR_String& rcSTR_String;
+typedef unsigned char byte;
+
+/**
+ * Smart String Value class. Is used by parser when an expression tree is build containing string.
+*/
+
+class STR_String
+{
+public:
+ // Initialization
+ STR_String();
+ STR_String(char c);
+ STR_String(char c, int len);
+ STR_String(const char *str);
+ STR_String(const char *str, int len);
+ STR_String(const STR_String &str);
+ STR_String(const STR_String & str, int len);
+ STR_String(const char *src1, int src1_len, const char *src2, int src2_len);
+ explicit STR_String(int val);
+ explicit STR_String(dword val);
+ explicit STR_String(float val);
+ explicit STR_String(double val);
+ inline ~STR_String() { delete[] pData; }
+
+ // Operations
+ STR_String& Format(const char *fmt, ...); // Set formatted text to string
+ STR_String& FormatAdd(const char *fmt, ...); // Add formatted text to string
+ inline void Clear() { Len = pData[0] = 0; }
+ inline const STR_String & Reverse()
+ {
+ for (int i1=0, i2=Len-1; i1<i2; i1++, i2--)
+ swap(pData[i1], pData[i2]); return *this;
+ }
+
+ // Properties
+ bool IsUpper() const;
+ bool IsLower() const;
+ inline bool IsEmpty() const { return Len==0; }
+ inline int Length() const { return Len; }
+
+ // Data access
+ inline STR_String& SetLength(int len) { AllocBuffer(len, true); Len=len; pData[len]=0; return *this; }
+ inline char GetAt(int pos) const { assertd(pos<Len); return pData[pos]; }
+ inline void SetAt(int pos, char c) { assertd(pos<Len); pData[pos]=c; }
+ inline void SetAt(int pos, rcSTR_String str);
+ inline void SetAt(int pos, int num, rcSTR_String str);
+ void Replace(int pos, rcSTR_String str);
+ void Replace(int pos, int num, rcSTR_String str);
+
+ // Substrings
+ inline STR_String Left(int num) const { num = (num < Len ? num:Len ); return STR_String(pData, num); }
+ inline STR_String Right(int num) const { num = (num < Len ? num:Len ); return STR_String(pData+Len-num, num); }
+ inline STR_String Mid(int pos, int num = INT_MAX) const { pos = (pos < Len ? pos:Len ); num = (num < (Len - pos) ? num : (Len - pos)); return STR_String(pData+pos, num); }
+
+ // Comparison
+ int Compare(rcSTR_String rhs) const;
+ int CompareNoCase(rcSTR_String rhs) const;
+ inline bool IsEqual(rcSTR_String rhs) const { return (Compare(rhs)==0); }
+ inline bool IsEqualNoCase(rcSTR_String rhs) const { return (CompareNoCase(rhs)==0); }
+
+ // Search/replace
+ int Find(char c, int pos = 0) const;
+ int Find(const char *str, int pos = 0) const;
+ int Find(rcSTR_String str, int pos = 0) const;
+ int RFind(char c) const;
+ int FindOneOf(const char *set, int pos = 0) const;
+ int RFindOneOf(const char *set, int pos = 0) const;
+
+ vector<STR_String> Explode(char c) const;
+
+ // Formatting
+ STR_String& Upper();
+ STR_String& Lower();
+ STR_String& Capitalize();
+ STR_String& TrimLeft();
+ STR_String& TrimLeft(char *set);
+ STR_String& TrimRight();
+ STR_String& TrimRight(char *set);
+ STR_String& Trim();
+ STR_String& Trim(char *set);
+ STR_String& TrimQuotes();
+
+ // Conversions
+// inline operator char*() { return pData; }
+ inline operator const char *() const { return pData; }
+ inline char *Ptr() { return pData; }
+ inline const char *ReadPtr() const { return pData; }
+ inline float ToFloat() const { return (float) atof(pData); }
+ inline int ToInt() const { return atoi(pData); }
+
+ // Operators
+ inline rcSTR_String operator=(const byte *rhs) { return Copy((const char *)rhs, strlen((const char *)rhs)); }
+ inline rcSTR_String operator=(rcSTR_String rhs) { return Copy(rhs.ReadPtr(), rhs.Length()); }
+ inline rcSTR_String operator=(char rhs) { return Copy(&rhs, 1); }
+ inline rcSTR_String operator=(const char *rhs) { return Copy(rhs, strlen(rhs)); }
+
+ inline rcSTR_String operator+=(const char *rhs) { return Concat(rhs, strlen(rhs)); }
+ inline rcSTR_String operator+=(rcSTR_String rhs) { return Concat(rhs.ReadPtr(), rhs.Length()); }
+ inline rcSTR_String operator+=(char rhs) { return Concat(&rhs, 1); }
+
+
+ inline friend bool operator<(rcSTR_String lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)<0); }
+ inline friend bool operator<(rcSTR_String lhs, const char *rhs) { return (strcmp(lhs, rhs)<0); };
+ inline friend bool operator<(const char *lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)<0); }
+ inline friend bool operator>(rcSTR_String lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)>0); }
+ inline friend bool operator>(rcSTR_String lhs, const char *rhs) { return (strcmp(lhs, rhs)>0); }
+ inline friend bool operator>(const char *lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)>0); }
+ inline friend bool operator<=(rcSTR_String lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)<=0); }
+ inline friend bool operator<=(rcSTR_String lhs, const char *rhs) { return (strcmp(lhs, rhs)<=0); }
+ inline friend bool operator<=(const char *lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)<=0); }
+ inline friend bool operator>=(rcSTR_String lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)>=0); }
+ inline friend bool operator>=(rcSTR_String lhs, const char *rhs) { return (strcmp(lhs, rhs)>=0); }
+ inline friend bool operator>=(const char *lhs, rcSTR_String rhs) { return (strcmp(lhs, rhs)>=0); }
+ inline friend bool operator==(rcSTR_String lhs, rcSTR_String rhs) { return ((lhs.Length() == rhs.Length()) && (memcmp(lhs, rhs, lhs.Length())==0)); }
+ inline friend bool operator==(rcSTR_String lhs, const char *rhs) { return (memcmp(lhs, rhs, lhs.Length()+1)==0); }
+ inline friend bool operator==(const char *lhs, rcSTR_String rhs) { return (memcmp(lhs, rhs, rhs.Length()+1)==0); }
+ inline friend bool operator!=(rcSTR_String lhs, rcSTR_String rhs) { return ((lhs.Length() != rhs.Length()) || (memcmp(lhs, rhs, lhs.Length())!=0)); }
+ inline friend bool operator!=(rcSTR_String lhs, const char *rhs) { return (memcmp(lhs, rhs, lhs.Length()+1)!=0); }
+ inline friend bool operator!=(const char *lhs, rcSTR_String rhs) { return (memcmp(lhs, rhs, rhs.Length()+1)!=0); }
+
+ // serializing
+ //int Serialize(pCStream stream);
+
+protected:
+ // Implementation
+ void AllocBuffer(int len, bool keep_contents);
+ rcSTR_String Copy(const char *src, int len);
+ rcSTR_String Concat(const char *data, int len);
+
+ static bool isLower(char c) { return !isUpper(c); }
+ static bool isUpper(char c) { return (c>='A') && (c <= 'Z'); }
+ static bool isSpace(char c) { return (c==' ') || (c=='\t'); }
+
+ char *pData; // -> STR_String data
+ int Len; // Data length
+ int Max; // Space in data buffer
+};
+
+inline STR_String operator+(rcSTR_String lhs, rcSTR_String rhs) { return STR_String(lhs.ReadPtr(), lhs.Length(), rhs.ReadPtr(), rhs.Length()); }
+inline STR_String operator+(rcSTR_String lhs, char rhs) { return STR_String(lhs.ReadPtr(), lhs.Length(), &rhs, 1); }
+inline STR_String operator+(char lhs, rcSTR_String rhs) { return STR_String(&lhs, 1, rhs.ReadPtr(), rhs.Length()); }
+inline STR_String operator+(rcSTR_String lhs, const char *rhs) { return STR_String(lhs.ReadPtr(), lhs.Length(), rhs, strlen(rhs)); }
+inline STR_String operator+(const char *lhs, rcSTR_String rhs) { return STR_String(lhs, strlen(lhs), rhs.ReadPtr(), rhs.Length()); }
+
+
+#endif //_STR_String_H_
diff --git a/intern/string/intern/Makefile b/intern/string/intern/Makefile
new file mode 100644
index 00000000000..925cdfed54a
--- /dev/null
+++ b/intern/string/intern/Makefile
@@ -0,0 +1,42 @@
+#
+# $Id$
+#
+# ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version. The Blender
+# Foundation also sells licenses for use in proprietary software under
+# the Blender License. See http://www.blender.org/BL/ for information
+# about this.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+#
+# The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): none yet.
+#
+# ***** END GPL/BL DUAL LICENSE BLOCK *****
+# string intern Makefile
+#
+
+LIBNAME = string
+DIR = $(OCGDIR)/intern/$(LIBNAME)
+
+include nan_compile.mk
+
+CCFLAGS += $(LEVEL_2_CPP_WARNINGS)
+
+CPPFLAGS += -I..
+
diff --git a/intern/string/intern/STR_String.cpp b/intern/string/intern/STR_String.cpp
new file mode 100644
index 00000000000..074bdc7acea
--- /dev/null
+++ b/intern/string/intern/STR_String.cpp
@@ -0,0 +1,743 @@
+/**
+ * $Id$
+ * ***** BEGIN GPL/BL DUAL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version. The Blender
+ * Foundation also sells licenses for use in proprietary software under
+ * the Blender License. See http://www.blender.org/BL/ for information
+ * about this.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL/BL DUAL LICENSE BLOCK *****
+ */
+
+/**
+
+ * $Id$
+ * Copyright (C) 2001 NaN Technologies B.V.
+ * This file was formerly known as: GEN_StdString.cpp.
+ * @date April, 25, 2001
+ */
+
+#include <stdio.h>
+#include <stdarg.h>
+#include "STR_String.h"
+
+/*-------------------------------------------------------------------------------------------------
+ Construction / destruction
+-------------------------------------------------------------------------------------------------*/
+
+
+
+//
+// Construct an empty string
+//
+STR_String::STR_String() :
+ pData(new char [32]),
+ Len(0),
+ Max(32)
+{
+ pData[0] = 0;
+}
+
+
+
+//
+// Construct a string of one character
+//
+STR_String::STR_String(char c) :
+ pData(new char [9]),
+ Len(1),
+ Max(9)
+{
+ pData[0] = c;
+ pData[1] = 0;
+}
+
+
+
+//
+// Construct a string of multiple repeating characters
+//
+STR_String::STR_String(char c, int len) :
+ pData(new char [len+8]),
+ Len(len),
+ Max(len+8)
+{
+ assertd(pData != NULL);
+ memset(pData, c, len);
+ pData[len] = 0;
+}
+
+
+
+//
+// Construct a string from a pointer-to-ASCIIZ-string
+//
+// MAART: Changed to test for null strings
+STR_String::STR_String(const char *str)
+{
+ if (str) {
+ Len = ::strlen(str);
+ Max = Len + 8;
+ pData = new char [Max];
+ assertd(pData != NULL);
+ ::memcpy(pData, str, Len);
+ pData[Len] = 0;
+ }
+ else {
+ pData = 0;
+ Len = 0;
+ Max = 8;
+ }
+}
+
+
+
+//
+// Construct a string from a pointer-to-ASCII-string and a length
+//
+STR_String::STR_String(const char *str, int len) :
+ pData(new char [len+8]),
+ Len(len),
+ Max(len+8)
+{
+ assertd(pData != NULL);
+ memcpy(pData, str, len);
+ pData[len] = 0;
+}
+
+
+
+//
+// Construct a string from another string
+//
+STR_String::STR_String(rcSTR_String str) :
+ pData(new char [str.Length()+8]),
+ Len(str.Length()),
+ Max(str.Length()+8)
+{
+ assertd(pData != NULL);
+ assertd(str.pData != NULL);
+ memcpy(pData, str.pData, str.Length());
+ pData[str.Length()] = 0;
+}
+
+
+
+//
+// Construct a string from the first number of characters in another string
+//
+STR_String::STR_String(rcSTR_String str, int len) :
+ pData(new char [len+8]),
+ Len(len),
+ Max(len+8)
+{
+ assertd(pData != NULL);
+ assertd(str.pData != NULL);
+ memcpy(pData, str.pData, str.Length());
+ pData[str.Length()] = 0;
+}
+
+
+
+//
+// Create a string by concatenating two sources
+//
+STR_String::STR_String(const char *src1, int len1, const char *src2, int len2) :
+ pData(new char [len1+len2+8]),
+ Len(len1+len2),
+ Max(len1+len2+8)
+{
+ assertd(pData != NULL);
+ memcpy(pData, src1, len1);
+ memcpy(pData+len1, src2, len2);
+ pData[len1+len2] = 0;
+}
+
+
+
+//
+// Create a string with an integer value
+//
+STR_String::STR_String(int val) :
+ pData(new char [32]),
+ Max(32)
+{
+ assertd(pData != NULL);
+ Len=sprintf(pData, "%d", val);
+}
+
+
+
+
+//
+// Create a string with a dword value
+//
+STR_String::STR_String(dword val) :
+ pData(new char [32]),
+ Max(32)
+{
+ assertd(pData != NULL);
+ Len=sprintf(pData, "%lu", val);
+}
+
+
+
+//
+// Create a string with a floating point value
+//
+STR_String::STR_String(float val) :
+ pData(new char [32]),
+ Max(32)
+{
+ assertd(pData != NULL);
+ Len=sprintf(pData, "%g", val);
+}
+
+
+
+//
+// Create a string with a double value
+//
+STR_String::STR_String(double val) :
+ pData(new char [32]),
+ Max(32)
+{
+ assertd(pData != NULL);
+ Len=sprintf(pData, "%g", val);
+}
+
+
+
+/*-------------------------------------------------------------------------------------------------
+ Buffer management
+-------------------------------------------------------------------------------------------------*/
+
+
+
+//
+// Make sure that the allocated buffer is at least <len> in size
+//
+void STR_String::AllocBuffer(int len, bool keep_contents)
+{
+ // Check if we have enough space
+ if (len+1 <= Max) return;
+
+ // Reallocate string
+ char *new_data = new char [len+8];
+ if (keep_contents) memcpy(new_data, pData, Len);
+ delete[] pData;
+
+ // Accept new data
+ Max = len+8;
+ pData = new_data;
+ assertd(pData != NULL);
+}
+
+
+
+/*-------------------------------------------------------------------------------------------------
+ Basic string operations
+-------------------------------------------------------------------------------------------------*/
+
+
+
+//
+// Format string (as does sprintf)
+//
+STR_String& STR_String::Format(const char *fmt, ...)
+{
+ AllocBuffer(2048, false);
+
+ assertd(pData != NULL);
+ // Expand arguments and format to string
+ va_list args;
+ va_start(args, fmt);
+ Len = vsprintf(pData, fmt, args);
+ assertd(Len <= 2048);
+ va_end(args);
+
+ return *this;
+}
+
+
+
+//
+// Format string (as does sprintf)
+//
+STR_String& STR_String::FormatAdd(const char *fmt, ...)
+{
+ AllocBuffer(2048, false);
+
+ assertd(pData != NULL);
+ // Expand arguments and format to string
+ va_list args;
+ va_start(args, fmt);
+ Len += vsprintf(pData+Len, fmt, args);
+ assertd(Len <= 2048);
+ va_end(args);
+
+ return *this;
+}
+
+
+
+/*-------------------------------------------------------------------------------------------------
+ Properties
+-------------------------------------------------------------------------------------------------*/
+
+
+
+//
+// Check if string is entirely in UPPERCase
+//
+bool STR_String::IsUpper() const
+{
+ for (int i=0; i<Len; i++)
+ if (isLower(pData[i]))
+ return false;
+
+ return true;
+}
+
+
+
+//
+// Check if string is entirely in lowerCase
+//
+bool STR_String::IsLower() const
+{
+ for (int i=0; i<Len; i++)
+ if (isUpper(pData[i]))
+ return false;
+
+ return true;
+}
+
+
+
+/*-------------------------------------------------------------------------------------------------
+ Search/Replace
+-------------------------------------------------------------------------------------------------*/
+
+
+
+//
+// Find the first orccurence of <c> in the string
+//
+int STR_String::Find(char c, int pos) const
+{
+ assertd(pos >= 0);
+ assertd(Len==0 || pos<Len);
+ assertd(pData != NULL);
+ char *find_pos = strchr(pData+pos, c);
+ return (find_pos) ? (find_pos-pData) : -1;
+}
+
+
+
+//
+// Find the first occurence of <str> in the string
+//
+int STR_String::Find(const char *str, int pos) const
+{
+ assertd(pos >= 0);
+ assertd(Len==0 || pos<Len);
+ assertd(pData != NULL);
+ char *find_pos = strstr(pData+pos, str);
+ return (find_pos) ? (find_pos-pData) : -1;
+}
+
+
+
+//
+// Find the first occurence of <str> in the string
+//
+int STR_String::Find(rcSTR_String str, int pos) const
+{
+ assertd(pos >= 0);
+ assertd(Len==0 || pos<Len);
+ assertd(pData != NULL);
+ char *find_pos = strstr(pData+pos, str.ReadPtr());
+ return (find_pos) ? (find_pos-pData) : -1;
+}
+
+
+
+//
+// Find the last occurence of <c> in the string
+//
+int STR_String::RFind(char c) const
+{
+ assertd(pData != NULL);
+ char *pos = strrchr(pData, c);
+ return (pos) ? (pos-pData) : -1;
+}
+
+
+
+//
+// Find the first occurence of any character in character set <set> in the string
+//
+int STR_String::FindOneOf(const char *set, int pos) const
+{
+ assertd(pos >= 0);
+ assertd(Len==0 || pos<Len);
+ assertd(pData != NULL);
+ char *find_pos = strpbrk(pData+pos, set);
+ return (find_pos) ? (find_pos-pData) : -1;
+}
+
+
+
+//
+// Replace a character in this string with another string
+//
+void STR_String::Replace(int pos, rcSTR_String str)
+{
+ //bounds(pos, 0, Length()-1);
+
+ if (str.Length() < 1)
+ {
+ // Remove one character from the string
+ memcpy(pData+pos, pData+pos+1, Len-pos);
+ }
+ else
+ {
+ // Insert zero or more characters into the string
+ AllocBuffer(Len + str.Length() - 1, true);
+ if (str.Length() != 1) memcpy(pData+pos+str.Length(), pData+pos+1, Length()-pos);
+ memcpy(pData+pos, str.ReadPtr(), str.Length());
+ }
+
+ Len += str.Length()-1;
+}
+
+
+
+//
+// Replace a substring of this string with another string
+//
+void STR_String::Replace(int pos, int num, rcSTR_String str)
+{
+ //bounds(pos, 0, Length()-1);
+ //bounds(pos+num, 0, Length());
+ assertd(num >= 1);
+
+ if (str.Length() < num)
+ {
+ // Remove some data from the string by replacement
+ memcpy(pData+pos+str.Length(), pData+pos+num, Len-pos-num+1);
+ memcpy(pData+pos, str.ReadPtr(), str.Length());
+ }
+ else
+ {
+ // Insert zero or more characters into the string
+ AllocBuffer(Len + str.Length() - num, true);
+ if (str.Length() != num) memcpy(pData+pos+str.Length(), pData+pos+num, Length()-pos-num+1);
+ memcpy(pData+pos, str.ReadPtr(), str.Length());
+ }
+
+ Len += str.Length()-num;
+}
+
+
+
+/*-------------------------------------------------------------------------------------------------
+ Comparison
+-------------------------------------------------------------------------------------------------*/
+
+
+
+//
+// Compare two strings and return the result, <0 if *this<rhs, >0 if *this>rhs or 0 if *this==rhs
+//
+int STR_String::Compare(rcSTR_String rhs) const
+{
+ return strcmp(pData, rhs.pData);
+}
+
+
+
+//
+// Compare two strings without respecting case and return the result, <0 if *this<rhs, >0 if *this>rhs or 0 if *this==rhs
+//
+int STR_String::CompareNoCase(rcSTR_String rhs) const
+{
+#ifdef WIN32
+ return stricmp(pData, rhs.pData);
+#else
+ return strcasecmp(pData, rhs.pData);
+#endif
+}
+
+
+
+/*-------------------------------------------------------------------------------------------------
+ Formatting
+-------------------------------------------------------------------------------------------------*/
+
+
+
+//
+// Capitalize string, "heLLo" -> "HELLO"
+//
+STR_String& STR_String::Upper()
+{
+ assertd(pData != NULL);
+#ifdef WIN32
+ _strupr(pData);
+#else
+ for (int i=0;i<Len;i++)
+ pData[i] = (pData[i] >= 'a' && pData[i] <= 'z')?pData[i]+'A'-'a':pData[i];
+#endif
+ return *this;
+}
+
+
+
+//
+// Lower string, "heLLo" -> "hello"
+//
+STR_String& STR_String::Lower()
+{
+ assertd(pData != NULL);
+#ifdef WIN32
+ _strlwr(pData);
+#else
+ for (int i=0;i<Len;i++)
+ pData[i] = (pData[i] >= 'A' && pData[i] <= 'Z')?pData[i]+'a'-'A':pData[i];
+#endif
+ return *this;
+}
+
+
+
+//
+// Capitalize string, "heLLo" -> "Hello"
+//
+STR_String& STR_String::Capitalize()
+{
+ assertd(pData != NULL);
+#ifdef WIN32
+ if (Len>0) pData[0] = toupper(pData[0]);
+ if (Len>1) _strlwr(pData+1);
+#else
+ if (Len > 0)
+ pData[0] = (pData[0] >= 'A' && pData[0] <= 'A')?pData[0]+'a'-'A':pData[0];
+ for (int i=1;i<Len;i++)
+ pData[i] = (pData[i] >= 'a' && pData[i] <= 'z')?pData[i]+'A'-'a':pData[i];
+#endif
+ return *this;
+}
+
+
+
+//
+// Trim whitespace from the left side of the string
+//
+STR_String& STR_String::TrimLeft()
+{
+ int skip;
+ assertd(pData != NULL);
+ for (skip=0; isSpace(pData[skip]); skip++, Len--);
+ memmove(pData, pData+skip, Len+1);
+ return *this;
+}
+
+
+
+//
+// Trim whitespaces from the right side of the string
+//
+STR_String& STR_String::TrimRight()
+{
+ assertd(pData != NULL);
+ while (Len && isSpace(pData[Len-1])) Len--;
+ pData[Len]=0;
+ return *this;
+}
+
+
+
+//
+// Trim spaces from both sides of the character set
+//
+STR_String& STR_String::Trim()
+{
+ TrimRight();
+ TrimLeft();
+ return *this;
+}
+
+
+
+//
+// Trim characters from the character set <set> from the left side of the string
+//
+STR_String& STR_String::TrimLeft(char *set)
+{
+ int skip;
+ assertd(pData != NULL);
+ for (skip=0; Len && strchr(set, pData[skip]); skip++, Len--);
+ memmove(pData, pData+skip, Len+1);
+ return *this;
+}
+
+
+
+//
+// Trim characters from the character set <set> from the right side of the string
+//
+STR_String& STR_String::TrimRight(char *set)
+{
+ assertd(pData != NULL);
+ while (Len && strchr(set, pData[Len-1])) Len--;
+ pData[Len]=0;
+ return *this;
+}
+
+
+
+//
+// Trim characters from the character set <set> from both sides of the character set
+//
+STR_String& STR_String::Trim(char *set)
+{
+ TrimRight(set);
+ TrimLeft(set);
+ return *this;
+}
+
+
+
+//
+// Trim quotes from both sides of the string
+//
+STR_String& STR_String::TrimQuotes()
+{
+ // Trim quotes if they are on both sides of the string
+ assertd(pData != NULL);
+ if ((Len >= 2) && (pData[0] == '\"') && (pData[Len-1] == '\"'))
+ {
+ memmove(pData, pData+1, Len-2+1);
+ Len-=2;
+ }
+ return *this;
+}
+
+
+
+/*-------------------------------------------------------------------------------------------------
+ Assignment/Concatenation
+-------------------------------------------------------------------------------------------------*/
+
+
+
+//
+// Set the string's conents to a copy of <src> with length <len>
+//
+rcSTR_String STR_String::Copy(const char *src, int len)
+{
+ assertd(len>=0);
+ assertd(src);
+ assertd(pData != NULL);
+
+ AllocBuffer(len, false);
+ Len = len;
+ memcpy(pData, src, len);
+ pData[Len] = 0;
+
+ return *this;
+}
+
+
+
+//
+// Concate a number of bytes to the current string
+//
+rcSTR_String STR_String::Concat(const char *data, int len)
+{
+ assertd(Len>=0);
+ assertd(len>=0);
+ assertd(data);
+ assertd(pData != NULL);
+
+ AllocBuffer(Len+len, true);
+ memcpy(pData+Len, data, len);
+ Len+=len;
+ pData[Len] = 0;
+
+ return *this;
+}
+
+
+
+
+
+vector<STR_String> STR_String::Explode(char c) const
+{
+ STR_String lcv = *this;
+ vector<STR_String> uc;
+
+ while (lcv.Length())
+ {
+ int pos = lcv.Find(c);
+ if (pos < 0)
+ {
+ uc.push_back(lcv);
+ lcv.Clear();
+ } else
+ {
+ uc.push_back(lcv.Left(pos));
+ lcv = lcv.Mid(pos+1);
+ }
+ }
+
+ //uc. -= STR_String("");
+
+ return uc;
+}
+
+
+/*
+
+int STR_String::Serialize(pCStream stream)
+{
+ if (stream->GetAccess() == CStream::Access_Read)
+ {
+ int ln;
+ stream->Read(&ln, sizeof(ln));
+ AllocBuffer(ln, false);
+ stream->Read(pData, ln);
+ pData[ln] = '\0';
+ Len = ln;
+ } else
+ {
+ stream->Write(&Len, sizeof(Len));
+ stream->Write(pData, Len);
+ }
+
+ return Len + sizeof(Len);
+}
+*/
+
diff --git a/intern/string/make/msvc_6_0/string.dsp b/intern/string/make/msvc_6_0/string.dsp
new file mode 100644
index 00000000000..4f0efe56f49
--- /dev/null
+++ b/intern/string/make/msvc_6_0/string.dsp
@@ -0,0 +1,122 @@
+# Microsoft Developer Studio Project File - Name="string" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Static Library" 0x0104
+
+CFG=string - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "string.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "string.mak" CFG="string - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "string - Win32 Release" (based on "Win32 (x86) Static Library")
+!MESSAGE "string - Win32 Debug" (based on "Win32 (x86) Static Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "string - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "../../../../../obj/windows/intern/string"
+# PROP Intermediate_Dir "../../../../../obj/windows/intern/string"
+# PROP Target_Dir ""
+LINK32=link.exe -lib
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "../.." /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Cmds=ECHO Copying header files COPY "..\..\*.h" "..\..\..\..\lib\windows\string\include" ECHO Copying lib COPY "..\..\..\..\..\obj\windows\intern\string\string.lib" "..\..\..\..\..\develop\lib\windows\string\lib\libstring.a" ECHO Done
+# End Special Build Tool
+
+!ELSEIF "$(CFG)" == "string - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "../../../../../obj/windows/intern/string/debug"
+# PROP Intermediate_Dir "../../../../../obj/windows/intern/string/debug"
+# PROP Target_Dir ""
+LINK32=link.exe -lib
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /I "../.." /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LIB32=link.exe -lib
+# ADD BASE LIB32 /nologo
+# ADD LIB32 /nologo
+# Begin Special Build Tool
+SOURCE="$(InputPath)"
+PostBuild_Cmds=ECHO Copying header files COPY "..\..\*.h" "..\..\..\..\lib\windows\string\include" ECHO Copying lib COPY "..\..\..\..\..\obj\windows\intern\string\debug\string.lib" "..\..\..\..\..\develop\lib\windows\string\lib\debug\libstring.a" ECHO Done
+# End Special Build Tool
+
+!ENDIF
+
+# Begin Target
+
+# Name "string - Win32 Release"
+# Name "string - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\..\intern\STR_String.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Group "intern"
+
+# PROP Default_Filter ""
+# End Group
+# Begin Group "extern"
+
+# PROP Default_Filter ""
+# Begin Source File
+
+SOURCE=..\..\STR_HashedString.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\STR_String.h
+# End Source File
+# End Group
+# End Group
+# End Target
+# End Project
diff --git a/intern/string/make/msvc_6_0/string.dsw b/intern/string/make/msvc_6_0/string.dsw
new file mode 100644
index 00000000000..b599b6407c5
--- /dev/null
+++ b/intern/string/make/msvc_6_0/string.dsw
@@ -0,0 +1,29 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "string"=".\string.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+