drizzle
C++ MySQL-protocol-compatible database server
Loading...
Searching...
No Matches
drizzled/identifier/catalog.h
1/* - mode: c; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2 * vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3 *
4 * Copyright (C) 2010 Brian Aker
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#pragma once
22
23#include <drizzled/enum.h>
25#include <drizzled/util/data_ref.h>
26#include <cstring>
27#include <cassert>
28#include <functional>
29#include <ostream>
30#include <vector>
31#include <algorithm>
32#include <functional>
33#include <iosfwd>
34#include <boost/algorithm/string.hpp>
35
36namespace drizzled {
37namespace identifier {
38
39class DRIZZLED_API Catalog : public Identifier
40{
41public:
42 Catalog(str_ref);
43 bool isValid() const;
44 bool compare(const std::string &arg) const;
45
46 const std::string &getPath() const
47 {
48 return path;
49 }
50
51 const std::string &getName() const
52 {
53 return _name;
54 }
55
56 const std::string &name() const
57 {
58 return _name;
59 }
60
61 virtual std::string getSQLPath() const
62 {
63 return _name;
64 }
65
66 size_t getHashValue() const
67 {
68 return hash_value;
69 }
70
71 friend bool operator<(const Catalog &left, const Catalog &right)
72 {
73 return boost::ilexicographical_compare(left.getName(), right.getName());
74 }
75
76 friend std::ostream& operator<<(std::ostream& output, const Catalog &identifier)
77 {
78 return output << "Catalog:(" << identifier.getName() << ", " << identifier.getPath() << ")";
79 }
80
81 friend bool operator==(const Catalog &left, const Catalog &right)
82 {
83 return boost::iequals(left.getName(), right.getName());
84 }
85
86 void resetPath()
87 {
88 init();
89 }
90
91private:
92 void init();
93
94 std::string _name;
95 std::string path;
96 size_t hash_value;
97};
98
99inline std::size_t hash_value(Catalog const& b)
100{
101 return b.getHashValue();
102}
103
104} /* namespace identifier */
105} /* namespace drizzled */
106
107namespace std {
108template<>
109struct hash<drizzled::identifier::Catalog>
110{
111 size_t operator()(const drizzled::identifier::Catalog& v) const
112 {
113 return drizzled::identifier::hash_value(v);
114 }
115};
116} /* namespace std */
TODO: Rename this file - func.h is stupid.
STL namespace.
#define DRIZZLED_API
Definition visibility.h:38