~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/message.cc

  • Committer: Brian Aker
  • Date: 2010-10-21 00:18:50 UTC
  • mto: This revision was merged to the branch mainline in revision 1885.
  • Revision ID: brian@tangent.org-20101021001850-u5hv5x1up5n1gn3l
Cleanup display code around DD/IS

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
#include "drizzled/message/table.pb.h"
30
30
#include "drizzled/message/schema.pb.h"
 
31
 
 
32
#include <string>
31
33
#include <uuid/uuid.h>
32
34
 
33
35
namespace drizzled {
34
36
namespace message {
35
37
 
 
38
// These are used to generate strings for types
 
39
static const std::string VARCHAR("VARCHAR");
 
40
static const std::string DOUBLE("DOUBLE");
 
41
static const std::string BLOB("BLOB");
 
42
static const std::string ENUM("ENUM");
 
43
static const std::string INTEGER("INTEGER");
 
44
static const std::string BIGINT("BIGINT");
 
45
static const std::string DECIMAL("DECIMAL");
 
46
static const std::string DATE("DATE");
 
47
static const std::string TIMESTAMP("TIMESTAMP");
 
48
static const std::string DATETIME("DATETIME");
 
49
 
 
50
static const std::string UNDEFINED("UNDEFINED");
 
51
static const std::string RESTRICT("RESTRICT");
 
52
static const std::string CASCADE("CASCADE");
 
53
static const std::string SET_NULL("SET NULL");
 
54
static const std::string NO_ACTION("NO ACTION");
 
55
static const std::string DEFAULT("DEFAULT");
 
56
 
 
57
static const std::string YES("YES");
 
58
static const std::string NO("NO");
 
59
 
 
60
static const std::string UNKNOWN_INDEX("UNKNOWN_INDEX");
 
61
static const std::string BTREE("BTREE");
 
62
static const std::string RTREE("RTREE");
 
63
static const std::string HASH("HASH");
 
64
static const std::string FULLTEXT("FULLTEXT");
 
65
 
36
66
void init(drizzled::message::Table &arg, const std::string &name_arg, const std::string &schema_arg, const std::string &engine_arg)
37
67
{
38
68
  arg.set_name(name_arg);
82
112
  arg.set_update_timestamp(time(NULL));
83
113
}
84
114
 
 
115
const std::string &type(drizzled::message::Table::Field::FieldType type)
 
116
{
 
117
  switch (type)
 
118
  {
 
119
  default:
 
120
  case message::Table::Field::VARCHAR:
 
121
    return VARCHAR;
 
122
  case message::Table::Field::DOUBLE:
 
123
    return DOUBLE;
 
124
  case message::Table::Field::BLOB:
 
125
    return BLOB;
 
126
  case message::Table::Field::ENUM:
 
127
    return ENUM;
 
128
  case message::Table::Field::INTEGER:
 
129
    return INTEGER;
 
130
  case message::Table::Field::BIGINT:
 
131
    return BIGINT;
 
132
  case message::Table::Field::DECIMAL:
 
133
    return DECIMAL;
 
134
  case message::Table::Field::DATE:
 
135
    return DATE;
 
136
  case message::Table::Field::TIMESTAMP:
 
137
    return TIMESTAMP;
 
138
  case message::Table::Field::DATETIME:
 
139
    return DATETIME;
 
140
  }
 
141
}
 
142
 
 
143
const std::string &type(drizzled::message::Table::ForeignKeyConstraint::ForeignKeyOption type)
 
144
{
 
145
  switch (type)
 
146
  {
 
147
  default:
 
148
  case message::Table::ForeignKeyConstraint::OPTION_UNDEF:
 
149
    return UNDEFINED;
 
150
  case message::Table::ForeignKeyConstraint::OPTION_RESTRICT:
 
151
    return RESTRICT;
 
152
  case message::Table::ForeignKeyConstraint::OPTION_CASCADE:
 
153
    return CASCADE;
 
154
  case message::Table::ForeignKeyConstraint::OPTION_SET_NULL:
 
155
    return SET_NULL;
 
156
  case message::Table::ForeignKeyConstraint::OPTION_NO_ACTION:
 
157
    return NO_ACTION;
 
158
  case message::Table::ForeignKeyConstraint::OPTION_DEFAULT:
 
159
    return DEFAULT;
 
160
  }
 
161
}
 
162
 
 
163
// This matches SQL standard of using YES/NO not the normal TRUE/FALSE
 
164
const std::string &type(bool type)
 
165
{
 
166
  return type ? YES : NO;
 
167
}
 
168
 
 
169
const std::string &type(drizzled::message::Table::Index::IndexType type)
 
170
{
 
171
  switch (type)
 
172
  {
 
173
  default:
 
174
  case message::Table::Index::UNKNOWN_INDEX:
 
175
    return UNKNOWN_INDEX;
 
176
  case message::Table::Index::BTREE:
 
177
    return BTREE;
 
178
  case message::Table::Index::RTREE:
 
179
    return RTREE;
 
180
  case message::Table::Index::HASH:
 
181
    return HASH;
 
182
  case message::Table::Index::FULLTEXT:
 
183
    return FULLTEXT;
 
184
  }
 
185
}
 
186
 
85
187
} /* namespace message */
86
188
} /* namespace drizzled */