00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00018
00019 #ifndef NET_INSTAWEB_UTIL_PUBLIC_ATOM_H_
00020 #define NET_INSTAWEB_UTIL_PUBLIC_ATOM_H_
00021
00022 #include <set>
00023 #include "net/instaweb/util/public/string.h"
00024
00025 namespace net_instaweb {
00026
00027 struct CaseFold;
00028 struct CasePreserve;
00029 template<class CharTransform> class SymbolTable;
00030
00033 class Atom {
00034 public:
00035 Atom(const Atom& src) : str_(src.str_) {}
00036 Atom();
00037 ~Atom() {}
00038
00039 Atom& operator=(const Atom& src) {
00040 if (&src != this) {
00041 str_ = src.str_;
00042 }
00043 return *this;
00044 }
00045
00047 const char* c_str() const { return str_; }
00048 int size() const { return strlen(str_); }
00049
00052 bool operator==(const Atom& sym) const {
00053 return str_ == sym.str_;
00054 }
00055
00058 bool operator!=(const Atom& sym) const {
00059 return str_ != sym.str_;
00060 }
00061
00065 friend class SymbolTable<CaseFold>;
00066 friend class SymbolTable<CasePreserve>;
00067
00068 private:
00069 explicit Atom(const char* str) : str_(str) {}
00070 const char* str_;
00071 };
00072
00075 struct AtomCompare {
00076 bool operator()(const Atom& a1, const Atom& a2) const {
00077 return a1.c_str() < a2.c_str();
00078 }
00079 };
00080
00083 typedef std::set<Atom, AtomCompare> AtomSet;
00084
00085 }
00086
00087 #endif ///< NET_INSTAWEB_UTIL_PUBLIC_ATOM_H_