diff options
author | Tuowen Zhao <ztuowen@gmail.com> | 2016-09-17 19:27:15 +0000 |
---|---|---|
committer | Tuowen Zhao <ztuowen@gmail.com> | 2016-09-17 19:27:15 +0000 |
commit | ad1cadf3512f3dd789151983e5c93af411f929db (patch) | |
tree | d6d25d562617d9bec7b13286cf413ed8f7567275 /omegalib/omega_lib/include/basic/ConstString.h | |
parent | cfafd2ffcad803e7bb02b60c085eafd73f28f87a (diff) | |
download | chill-ad1cadf3512f3dd789151983e5c93af411f929db.tar.gz chill-ad1cadf3512f3dd789151983e5c93af411f929db.tar.bz2 chill-ad1cadf3512f3dd789151983e5c93af411f929db.zip |
restructure
Diffstat (limited to 'omegalib/omega_lib/include/basic/ConstString.h')
-rw-r--r-- | omegalib/omega_lib/include/basic/ConstString.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/omegalib/omega_lib/include/basic/ConstString.h b/omegalib/omega_lib/include/basic/ConstString.h new file mode 100644 index 0000000..5149e55 --- /dev/null +++ b/omegalib/omega_lib/include/basic/ConstString.h @@ -0,0 +1,58 @@ +#if ! defined _Const_String_h +#define _Const_String_h 1 + +#include <string> + +namespace omega { + +// should be inside Const_String, but I can't get it to +// compile the hashTable when it is: hashTable can't be +// global, but if it and its size are static to Const_String, +// the compiler still doesn't seem to like the definition, +// or the declaration either for that matter. + +class ConstStringRep { +public: + const char *name; + int count; + ConstStringRep *nextInBucket; + ConstStringRep(const char *t); +}; + +class Const_String { +private: + ConstStringRep *rep; + void buildRep(const char *t); + +public: + Const_String(); + Const_String(const char* t); + Const_String(const std::string &s); + Const_String(const Const_String & t) {rep = t.rep;} + + operator int() const; + int null() const; + + operator const char*() const; + operator std::string() const; + int operator++(int); + int operator++(); + int operator--(int); + int operator--(); + friend int operator==(const Const_String &x, const Const_String &y); + friend int operator!=(const Const_String &x, const Const_String &y); + friend int operator<(const Const_String &x, const Const_String &y); + friend int operator >(const Const_String &x, const Const_String &y); + +}; + +#if defined SCREWED_UP_CASTING_RULES +static int operator==(const Const_String &x, const char *y) +{ return x == (Const_String) y; } +static int operator!=(const Const_String &x, const char *y) +{ return x != (Const_String) y; } +#endif + +} // namespace + +#endif |