~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/identifier/schema.h

  • Committer: Brian Aker
  • Date: 2010-07-15 23:18:11 UTC
  • mto: This revision was merged to the branch mainline in revision 1661.
  • Revision ID: brian@gaz-20100715231811-c5erivy1nvwf6bii
Merge in move identifier work.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
#include <functional>
46
46
#include <iostream>
47
47
 
48
 
#include <boost/algorithm/string.hpp>
49
48
 
50
49
namespace drizzled {
51
50
 
52
 
static std::string catalog("local");
 
51
static std::string catalog("");
53
52
 
54
53
class SchemaIdentifier
55
54
{
56
55
  std::string db;
57
56
  std::string db_path;
58
 
  std::string catalog;
59
 
 
60
 
public:
61
 
  typedef std::vector <SchemaIdentifier> vector;
62
 
  typedef const SchemaIdentifier& const_reference;
63
 
 
 
57
  std::string lower_db;
 
58
 
 
59
 
 
60
  // @note this should be changed to protected once Session contains an
 
61
  // identifier for current db.
 
62
public:
 
63
 
 
64
  const std::string &getLower() const
 
65
  {
 
66
    return lower_db;
 
67
  }
 
68
 
 
69
public:
64
70
  SchemaIdentifier(const std::string &db_arg);
65
71
 
66
72
  virtual ~SchemaIdentifier()
67
73
  { }
68
74
 
69
 
  virtual void getSQLPath(std::string &arg) const;
 
75
  virtual const std::string &getSQLPath();
70
76
  const std::string &getPath() const;
71
77
 
72
78
  const std::string &getSchemaName() const
79
85
    return catalog;
80
86
  }
81
87
 
82
 
  virtual bool isValid() const;
83
 
 
84
 
  bool compare(const std::string &arg) const;
85
 
  bool compare(SchemaIdentifier::const_reference) const;
86
 
 
87
 
  friend bool operator<(SchemaIdentifier::const_reference left, SchemaIdentifier::const_reference right)
 
88
  bool isValid() const;
 
89
  bool compare(std::string arg) const;
 
90
 
 
91
  friend bool operator<(const SchemaIdentifier &left, const SchemaIdentifier &right)
88
92
  {
89
 
    return  boost::algorithm::to_upper_copy(left.getSchemaName()) < boost::algorithm::to_upper_copy(right.getSchemaName());
 
93
    return left.lower_db < right.lower_db;
90
94
  }
91
95
 
92
96
  friend std::ostream& operator<<(std::ostream& output,
93
 
                                  SchemaIdentifier::const_reference identifier)
 
97
                                  SchemaIdentifier &identifier)
94
98
  {
95
99
    output << "SchemaIdentifier:(";
96
 
    output <<  identifier.catalog;
97
 
    output << ", ";
98
100
    output <<  identifier.db;
99
101
    output << ", ";
100
102
    output << identifier.getPath();
103
105
    return output;  // for multiple << operators.
104
106
  }
105
107
 
106
 
  friend bool operator==(SchemaIdentifier::const_reference left,
107
 
                         SchemaIdentifier::const_reference right)
 
108
  friend bool operator==(const SchemaIdentifier &left,
 
109
                         const SchemaIdentifier &right)
108
110
  {
109
 
    return boost::iequals(left.getSchemaName(), right.getSchemaName());
 
111
    if (left.lower_db == right.lower_db)
 
112
    {
 
113
      return true;
 
114
    }
 
115
 
 
116
    return false;
110
117
  }
 
118
 
111
119
};
112
120
 
 
121
typedef std::vector <SchemaIdentifier> SchemaIdentifiers;
113
122
 
114
123
} /* namespace drizzled */
115
124