~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/table_identifier.h

  • Committer: Monty Taylor
  • Date: 2008-08-01 22:33:44 UTC
  • mto: (236.1.42 codestyle)
  • mto: This revision was merged to the branch mainline in revision 261.
  • Revision ID: monty@inaugust.com-20080801223344-vzhlflfmtijp1imv
First pass at gettexizing the error messages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2009 Sun Microsystems
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; either version 2 of the License, or
9
 
 *  (at your option) any later version.
10
 
 *
11
 
 *  This program is distributed in the hope that it will be useful,
12
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
 *  GNU General Public License for more details.
15
 
 *
16
 
 *  You should have received a copy of the GNU General Public License
17
 
 *  along with this program; if not, write to the Free Software
18
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
 
 */
20
 
 
21
 
/* 
22
 
  This is a "work in progress". The concept needs to be replicated throughout
23
 
  the code, but we will start with baby steps for the moment. To not incur
24
 
  cost until we are complete, for the moment it will do no allocation.
25
 
 
26
 
  This is mainly here so that it can be used in the SE interface for
27
 
  the time being.
28
 
 
29
 
  This will replace Table_ident.
30
 
  */
31
 
 
32
 
#ifndef DRIZZLED_TABLE_IDENTIFIER_H
33
 
#define DRIZZLED_TABLE_IDENTIFIER_H
34
 
 
35
 
#include <drizzled/enum.h>
36
 
#include "drizzled/definitions.h"
37
 
#include <string.h>
38
 
 
39
 
#include <ostream>
40
 
 
41
 
namespace drizzled {
42
 
 
43
 
class TableIdentifier
44
 
{
45
 
private:
46
 
  bool path_inited;
47
 
 
48
 
  tmp_table_type type;
49
 
  char path[FN_REFLEN];
50
 
  const char *db;
51
 
  const char *table_name;
52
 
 
53
 
public:
54
 
  TableIdentifier( const char *db_arg,
55
 
                   const char *table_name_arg,
56
 
                   tmp_table_type tmp_arg) :
57
 
    path_inited(false),
58
 
    type(tmp_arg),
59
 
    db(db_arg),
60
 
    table_name(table_name_arg)
61
 
  { }
62
 
 
63
 
  bool isTmp() const
64
 
  {
65
 
    return type == NO_TMP_TABLE ? false  : true;
66
 
  }
67
 
 
68
 
  const char *getPath();
69
 
 
70
 
  const char *getDBName() const
71
 
  {
72
 
    return db;
73
 
  }
74
 
 
75
 
  const char *getTableName() const
76
 
  {
77
 
    return table_name;
78
 
  }
79
 
 
80
 
  friend std::ostream& operator<<(std::ostream& output, const TableIdentifier &identifier)
81
 
  {
82
 
    const char *type_str;
83
 
 
84
 
    output << "TableIdentifier:(";
85
 
    output <<  identifier.getDBName();
86
 
    output << ", ";
87
 
    output << identifier.getTableName();
88
 
    output << ", ";
89
 
 
90
 
    switch (identifier.type) {
91
 
    case NO_TMP_TABLE:
92
 
      type_str= "standard";
93
 
      break;
94
 
    case INTERNAL_TMP_TABLE:
95
 
      type_str= "internal";
96
 
      break;
97
 
    case TEMP_TABLE:
98
 
      type_str= "temporary";
99
 
      break;
100
 
    case SYSTEM_TMP_TABLE:
101
 
      type_str= "system";
102
 
    }
103
 
 
104
 
    output << type_str;
105
 
    output << ")";
106
 
 
107
 
    return output;  // for multiple << operators.
108
 
  }
109
 
 
110
 
  friend bool operator==(const TableIdentifier &left, const TableIdentifier &right)
111
 
  {
112
 
    if (left.type == right.type)
113
 
    {
114
 
      if (! strcmp(left.db, right.db))
115
 
      {
116
 
        if (! strcmp(left.table_name, right.table_name))
117
 
        {
118
 
          return true;
119
 
        }
120
 
      }
121
 
    }
122
 
 
123
 
    return false;
124
 
  }
125
 
 
126
 
};
127
 
 
128
 
} /* namespace drizzled */
129
 
 
130
 
#endif /* DRIZZLED_TABLE_IDENTIFIER_H */