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 <string.h>
00026
00027 #include <assert.h>
00028
00029 #include <ostream>
00030 #include <vector>
00031 #include <algorithm>
00032 #include <functional>
00033 #include <iostream>
00034
00035 #include <boost/algorithm/string.hpp>
00036
00037 namespace drizzled {
00038
00039 class lex_string_t;
00040
00041 namespace identifier {
00042
00043 class Catalog : public Identifier
00044 {
00045 std::string _name;
00046 std::string path;
00047
00048 void init();
00049
00050 public:
00051 typedef std::vector<Catalog> vector;
00052 typedef const Catalog& const_reference;
00053 typedef Catalog& reference;
00054
00055 Catalog(const std::string &name_arg);
00056 Catalog(const drizzled::lex_string_t &name_arg);
00057
00058 virtual ~Catalog()
00059 { }
00060
00061 const std::string &getPath() const;
00062
00063 const std::string &getName() const
00064 {
00065 return _name;
00066 }
00067
00068 const std::string &name() const
00069 {
00070 return _name;
00071 }
00072
00073 virtual void getSQLPath(std::string &sql_path) const;
00074
00075 bool isValid() const;
00076 bool compare(const std::string &arg) const;
00077
00078 size_t getHashValue() const
00079 {
00080 return hash_value;
00081 }
00082
00083 friend bool operator<(const Catalog &left, const Catalog &right)
00084 {
00085 return boost::algorithm::to_upper_copy(left.getName()) < boost::algorithm::to_upper_copy(right.getName());
00086 }
00087
00088 friend std::ostream& operator<<(std::ostream& output, const Catalog &identifier)
00089 {
00090 output << "Catalog:(";
00091 output << identifier.getName();
00092 output << ", ";
00093 output << identifier.getPath();
00094 output << ")";
00095
00096 return output;
00097 }
00098
00099 friend bool operator==(const Catalog &left,
00100 const Catalog &right)
00101 {
00102 return boost::iequals(left.getName(), right.getName());
00103 }
00104
00105 private:
00106 size_t hash_value;
00107
00108 };
00109
00110 std::size_t hash_value(Catalog const& b);
00111
00112 }
00113 }