~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/schema_identifier.h

  • Committer: patrick crews
  • Date: 2010-05-20 03:29:50 UTC
  • mto: This revision was merged to the branch mainline in revision 1565.
  • Revision ID: patrick.crews@sun.com-20100520032950-7452uruysx9kb6bn
Fixed incorrectly altered test commenting to reflect the proper bug descriptions (mysqldump v. drizzledump)

Show diffs side-by-side

added added

removed removed

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