~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/identifier/schema.h

  • Committer: Brian Aker
  • Date: 2010-11-11 04:16:59 UTC
  • mto: (1932.2.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 1930.
  • Revision ID: brian@tangent.org-20101111041659-5xb7ymjrasq1520p
Adding in support for EXECUTE to have WITH NO RETURN.

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