29
29
This will replace Table_ident.
32
#ifndef DRIZZLED_IDENTIFIER_SCHEMA_H
33
#define DRIZZLED_IDENTIFIER_SCHEMA_H
32
#ifndef DRIZZLED_SCHEMA_IDENTIFIER_H
33
#define DRIZZLED_SCHEMA_IDENTIFIER_H
35
35
#include <drizzled/enum.h>
36
36
#include "drizzled/definitions.h"
45
45
#include <functional>
46
46
#include <iostream>
48
#include <boost/algorithm/string.hpp>
50
48
namespace drizzled {
52
static std::string catalog("local");
54
50
class SchemaIdentifier
57
53
std::string db_path;
61
typedef std::vector <SchemaIdentifier> vector;
62
typedef const SchemaIdentifier& const_reference;
64
SchemaIdentifier(const std::string &db_arg);
56
// @note this should be changed to protected once Session contains an
57
// identifier for current db.
60
const std::string &getLower()
66
SchemaIdentifier(const std::string &db_arg) :
70
std::transform(lower_db.begin(), lower_db.end(),
71
lower_db.begin(), ::tolower);
66
74
virtual ~SchemaIdentifier()
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();
72
80
const std::string &getSchemaName() const
77
const std::string &getCatalogName() const
82
virtual bool isValid() const;
84
bool compare(const std::string &arg) const;
85
bool compare(SchemaIdentifier::const_reference) const;
87
friend bool operator<(SchemaIdentifier::const_reference left, SchemaIdentifier::const_reference right)
89
return boost::algorithm::to_upper_copy(left.getSchemaName()) < boost::algorithm::to_upper_copy(right.getSchemaName());
86
bool compare(std::string arg) const;
88
friend bool operator<(const SchemaIdentifier &left, const SchemaIdentifier &right)
90
return left.lower_db < right.lower_db;
92
93
friend std::ostream& operator<<(std::ostream& output,
93
SchemaIdentifier::const_reference identifier)
94
SchemaIdentifier &identifier)
95
96
output << "SchemaIdentifier:(";
96
output << identifier.catalog;
98
97
output << identifier.db;
100
99
output << identifier.getPath();
103
102
return output; // for multiple << operators.
106
friend bool operator==(SchemaIdentifier::const_reference left,
107
SchemaIdentifier::const_reference right)
105
friend bool operator==(const SchemaIdentifier &left,
106
const SchemaIdentifier &right)
109
return boost::iequals(left.getSchemaName(), right.getSchemaName());
108
if (left.lower_db == right.lower_db)
118
typedef std::list <SchemaIdentifier> SchemaIdentifierList;
114
120
} /* namespace drizzled */
116
#endif /* DRIZZLED_IDENTIFIER_SCHEMA_H */
122
#endif /* DRIZZLED_SCHEMA_IDENTIFIER_H */