~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to drizzled/identifier/catalog.h

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2012-06-19 10:46:49 UTC
  • mfrom: (1.1.6)
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20120619104649-e2l0ggd4oz3um0f4
Tags: upstream-7.1.36-stable
ImportĀ upstreamĀ versionĀ 7.1.36-stable

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include <drizzled/enum.h>
24
24
#include <drizzled/definitions.h>
25
 
#include <string.h>
26
 
 
27
 
#include <assert.h>
28
 
 
 
25
#include <drizzled/util/data_ref.h>
 
26
#include <cstring>
 
27
#include <cassert>
29
28
#include <ostream>
30
29
#include <vector>
31
30
#include <algorithm>
32
31
#include <functional>
33
 
#include <iostream>
34
 
 
 
32
#include <iosfwd>
35
33
#include <boost/algorithm/string.hpp>
36
34
 
37
35
namespace drizzled {
38
 
 
39
 
class lex_string_t;
40
 
 
41
36
namespace identifier {
42
37
 
43
38
class Catalog : public Identifier
44
39
{
45
 
  std::string _name;
46
 
  std::string path;
47
 
 
48
 
  void init();
49
 
 
50
40
public:
51
 
  typedef std::vector<Catalog> vector;
52
 
  typedef const Catalog& const_reference;
53
 
  typedef Catalog& reference;
54
 
 
55
 
  Catalog(const std::string &name_arg);
56
 
  Catalog(const drizzled::lex_string_t &name_arg);
57
 
 
58
 
  virtual ~Catalog()
59
 
  { }
60
 
 
61
 
  const std::string &getPath() const;
 
41
  Catalog(str_ref);
 
42
  bool isValid() const;
 
43
  bool compare(const std::string &arg) const;
 
44
 
 
45
  const std::string &getPath() const
 
46
  {
 
47
    return path;
 
48
  }
62
49
 
63
50
  const std::string &getName() const
64
51
  {
70
57
    return _name;
71
58
  }
72
59
 
73
 
  virtual void getSQLPath(std::string &sql_path) const;
74
 
 
75
 
  bool isValid() const;
76
 
  bool compare(const std::string &arg) const;
 
60
  virtual std::string getSQLPath() const
 
61
  {
 
62
    return _name;
 
63
  }
77
64
 
78
65
  size_t getHashValue() const
79
66
  {
82
69
 
83
70
  friend bool operator<(const Catalog &left, const Catalog &right)
84
71
  {
85
 
    return  boost::algorithm::to_upper_copy(left.getName()) < boost::algorithm::to_upper_copy(right.getName());
 
72
    return boost::ilexicographical_compare(left.getName(), right.getName());
86
73
  }
87
74
 
88
75
  friend std::ostream& operator<<(std::ostream& output, const Catalog &identifier)
89
76
  {
90
 
    output << "Catalog:(";
91
 
    output <<  identifier.getName();
92
 
    output << ", ";
93
 
    output << identifier.getPath();
94
 
    output << ")";
95
 
 
96
 
    return output;  // for multiple << operators.
 
77
    return output << "Catalog:(" <<  identifier.getName() << ", " << identifier.getPath() << ")";
97
78
  }
98
79
 
99
 
  friend bool operator==(const Catalog &left,
100
 
                         const Catalog &right)
 
80
  friend bool operator==(const Catalog &left, const Catalog &right)
101
81
  {
102
82
    return boost::iequals(left.getName(), right.getName());
103
83
  }
104
84
 
 
85
  void resetPath()
 
86
  {
 
87
    init();
 
88
  }
 
89
 
105
90
private:
 
91
  void init();
 
92
 
 
93
  std::string _name;
 
94
  std::string path;
106
95
  size_t hash_value;
107
 
 
108
96
};
109
97
 
110
 
std::size_t hash_value(Catalog const& b);
 
98
inline std::size_t hash_value(Catalog const& b)
 
99
{
 
100
  return b.getHashValue();
 
101
}
111
102
 
112
103
} /* namespace identifier */
113
104
} /* namespace drizzled */