Main Page | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

ustring.h

Go to the documentation of this file.
00001 /* ===========================================================================
00002  *        Filename:  ustring.h
00003  *     Description:  Unified String class
00004  * 
00005  *         Version:  $Rev: 11 $
00006  *         Changed:  $Date: 2005-08-04 17:58:36 -0400 (Do, 04 Aug 2005) $
00007  *         Licence:  GPL (read COPYING file for details)
00008  * 
00009  *          Author:  Erich Schubert (eS), erich@debian.org
00010  *                   Institut für Informatik, LMU München
00011  * ======================================================================== */
00012 #ifndef  USTRING_H
00013 #define  USTRING_H
00014 
00015 #include "config.h"
00016 
00017 #include <iostream>
00018 #include <map>
00019 #include <ext/hash_map>
00020 
00021 #include <libxml/tree.h> /* for xmlChar */
00022 
00023 using namespace std;
00024 using namespace __gnu_cxx;
00025 
00026 namespace SSD {
00027 
00029 struct eq_str {
00031         bool operator()(const char* s1, const char* s2) const { return strcmp(s1, s2) == 0; }
00032 };
00033 
00037 class ustring {
00039         const char* cstr;
00040 
00042         static hash_map< const char*, const char*, hash<char*>, eq_str> store;
00043 public:
00046         ustring(const char* s);
00049         ustring(const xmlChar* s);
00050 
00053         bool operator==(const ustring other) const {
00054                 return (cstr == other.cstr);
00055         }
00058         bool operator<=(const ustring other) const {
00059                 return (cstr <= other.cstr);
00060         }
00063         bool operator<(const ustring other) const {
00064                 return (cstr < other.cstr);
00065         }
00068         bool operator>=(const ustring other) const {
00069                 return (cstr >= other.cstr);
00070         }
00073         bool operator>(const ustring other) const {
00074                 return (cstr > other.cstr);
00075         }
00078         bool operator!=(const ustring other) const {
00079                 return (cstr != other.cstr);
00080         }
00082         bool empty() const { return (cstr == NULL); }
00084         size_t hashfun() const { return reinterpret_cast<size_t>(cstr); }
00085 
00089         friend std::ostream &operator<<(std::ostream &out, const ustring &str);
00090 };
00091 
00093 static ustring empty_ustring((char*)NULL);
00094 
00096 struct hash_ustring {
00099         size_t operator()(const SSD::ustring u) const {
00100                 return u.hashfun();
00101         };
00102 };
00103 }
00104 
00105 #endif   /* ----- #ifndef SSDDOC_H  ----- */

Generated on Thu Aug 4 17:57:12 2005 for SSDDiff by  doxygen 1.4.3-20050530