~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/identifier/catalog.h

  • Committer: Mark Atwood
  • Date: 2011-08-11 03:05:03 UTC
  • mfrom: (2385.1.12 refactor4)
  • Revision ID: me@mark.atwood.name-20110811030503-rp9xjihc5x3y0x4q
merge lp:~olafvdspek/drizzle/refactor4

Show diffs side-by-side

added added

removed removed

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