~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/schema_identifier.h

  • Committer: Brian Aker
  • Date: 2010-06-02 17:48:07 UTC
  • mto: (1578.6.10 explain-drizzle)
  • mto: This revision was merged to the branch mainline in revision 1589.
  • Revision ID: brian@gir-2.local-20100602174807-9unmrwp18ewkwol5
Modify merge-buffer to use std::vector in one location (just curious to see
if this shows up on benchmarks).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2009 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2009 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
29
29
  This will replace Table_ident.
30
30
  */
31
31
 
32
 
 
33
 
 
34
 
#ifndef DRIZZLED_IDENTIFIER_SCHEMA_H
35
 
#define DRIZZLED_IDENTIFIER_SCHEMA_H
 
32
#ifndef DRIZZLED_SCHEMA_IDENTIFIER_H
 
33
#define DRIZZLED_SCHEMA_IDENTIFIER_H
36
34
 
37
35
#include <drizzled/enum.h>
38
 
#include <drizzled/definitions.h>
39
 
#include <drizzled/message/table.pb.h>
40
 
#include <drizzled/catalog/local.h>
 
36
#include "drizzled/definitions.h"
 
37
#include "drizzled/message/table.pb.h"
41
38
#include <string.h>
42
39
 
43
40
#include <assert.h>
48
45
#include <functional>
49
46
#include <iostream>
50
47
 
51
 
#include <boost/algorithm/string.hpp>
52
 
 
53
 
#include <drizzled/visibility.h>
54
 
 
55
48
namespace drizzled {
56
 
namespace identifier {
57
49
 
58
 
class DRIZZLED_API Schema : public Identifier
 
50
class SchemaIdentifier
59
51
{
60
52
  std::string db;
61
53
  std::string db_path;
62
 
 
63
 
public:
64
 
  typedef std::vector <Schema> vector;
65
 
  typedef const Schema& const_reference;
66
 
 
67
 
  Schema(const std::string &db_arg);
68
 
 
69
 
  virtual ~Schema()
 
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
  }
 
73
 
 
74
  virtual ~SchemaIdentifier()
70
75
  { }
71
76
 
72
 
  virtual void getSQLPath(std::string &arg) const;
73
 
 
74
 
  const std::string &getPath() const;
 
77
  virtual const std::string &getSQLPath();
 
78
  const std::string &getPath();
75
79
 
76
80
  const std::string &getSchemaName() const
77
81
  {
78
82
    return db;
79
83
  }
80
84
 
81
 
  const std::string &getCatalogName() const;
82
 
 
83
 
  virtual bool isValid() const;
84
 
 
85
 
  inline virtual bool isSystem() const
86
 
  {
 
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;
 
91
  }
 
92
 
 
93
  friend std::ostream& operator<<(std::ostream& output,
 
94
                                  SchemaIdentifier &identifier)
 
95
  {
 
96
    output << "SchemaIdentifier:(";
 
97
    output <<  identifier.db;
 
98
    output << ", ";
 
99
    output << identifier.getPath();
 
100
    output << ")";
 
101
 
 
102
    return output;  // for multiple << operators.
 
103
  }
 
104
 
 
105
  friend bool operator==(const SchemaIdentifier &left,
 
106
                         const SchemaIdentifier &right)
 
107
  {
 
108
    if (left.lower_db == right.lower_db)
 
109
    {
 
110
      return true;
 
111
    }
 
112
 
87
113
    return false;
88
114
  }
89
115
 
90
 
  bool compare(const std::string &arg) const;
91
 
  bool compare(Schema::const_reference) const;
92
 
 
93
 
  friend bool operator<(Schema::const_reference left, Schema::const_reference right)
94
 
  {
95
 
    return  boost::algorithm::to_upper_copy(left.getSchemaName()) < boost::algorithm::to_upper_copy(right.getSchemaName());
96
 
  }
97
 
 
98
 
  friend bool operator==(Schema::const_reference left,
99
 
                         Schema::const_reference right)
100
 
  {
101
 
    return boost::iequals(left.getSchemaName(), right.getSchemaName());
102
 
  }
103
116
};
104
117
 
105
 
std::ostream& operator<<(std::ostream& output, const Schema&identifier);
106
 
 
107
 
 
108
 
} /* namespace identifier */
 
118
typedef std::list <SchemaIdentifier> SchemaIdentifierList;
 
119
 
109
120
} /* namespace drizzled */
110
121
 
111
 
#endif /* DRIZZLED_IDENTIFIER_SCHEMA_H */
 
122
#endif /* DRIZZLED_SCHEMA_IDENTIFIER_H */