00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #pragma once
00022
00023 #include <drizzled/enum.h>
00024 #include <drizzled/definitions.h>
00025 #include <drizzled/util/data_ref.h>
00026 #include <cstring>
00027 #include <cassert>
00028 #include <ostream>
00029 #include <vector>
00030 #include <algorithm>
00031 #include <functional>
00032 #include <iosfwd>
00033 #include <boost/algorithm/string.hpp>
00034
00035 namespace drizzled {
00036 namespace identifier {
00037
00038 class Catalog : public Identifier
00039 {
00040 public:
00041 Catalog(str_ref);
00042 bool isValid() const;
00043 bool compare(const std::string &arg) const;
00044
00045 const std::string &getPath() const
00046 {
00047 return path;
00048 }
00049
00050 const std::string &getName() const
00051 {
00052 return _name;
00053 }
00054
00055 const std::string &name() const
00056 {
00057 return _name;
00058 }
00059
00060 virtual std::string getSQLPath() const
00061 {
00062 return _name;
00063 }
00064
00065 size_t getHashValue() const
00066 {
00067 return hash_value;
00068 }
00069
00070 friend bool operator<(const Catalog &left, const Catalog &right)
00071 {
00072 return boost::ilexicographical_compare(left.getName(), right.getName());
00073 }
00074
00075 friend std::ostream& operator<<(std::ostream& output, const Catalog &identifier)
00076 {
00077 return output << "Catalog:(" << identifier.getName() << ", " << identifier.getPath() << ")";
00078 }
00079
00080 friend bool operator==(const Catalog &left, const Catalog &right)
00081 {
00082 return boost::iequals(left.getName(), right.getName());
00083 }
00084
00085 void resetPath()
00086 {
00087 init();
00088 }
00089
00090 private:
00091 void init();
00092
00093 std::string _name;
00094 std::string path;
00095 size_t hash_value;
00096 };
00097
00098 inline std::size_t hash_value(Catalog const& b)
00099 {
00100 return b.getHashValue();
00101 }
00102
00103 }
00104 }