~drizzle-trunk/drizzle/development

323 by Brian Aker
Updated proto file for table (not FRM work).
1
#include <iostream>
2
#include <fstream>
3
#include <string>
988.1.1 by Jay Pipes
Changes libserialize to libdrizzledmessage per ML discussion. All GPB messages are now in the drizzled::message namespace.
4
#include <drizzled/message/schema.pb.h>
323 by Brian Aker
Updated proto file for table (not FRM work).
5
using namespace std;
6
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
7
/*
323 by Brian Aker
Updated proto file for table (not FRM work).
8
  Written from Google proto example
9
*/
10
988.1.1 by Jay Pipes
Changes libserialize to libdrizzledmessage per ML discussion. All GPB messages are now in the drizzled::message namespace.
11
void printSchema(const drizzled::message::Schema *schema)
323 by Brian Aker
Updated proto file for table (not FRM work).
12
{
13
  cout << "CREATE SCHEMA `" << schema->name() << "` ";
14
  if (schema->has_collation())
15
    cout << "COLLATE `" << schema->collation() << "` ";
16
  cout << ";" << endl;
17
}
18
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
19
int main(int argc, char* argv[])
323 by Brian Aker
Updated proto file for table (not FRM work).
20
{
21
  GOOGLE_PROTOBUF_VERIFY_VERSION;
22
23
  if (argc != 2) {
24
    cerr << "Usage:  " << argv[0] << " SCHEMA" << endl;
25
    return -1;
26
  }
27
988.1.1 by Jay Pipes
Changes libserialize to libdrizzledmessage per ML discussion. All GPB messages are now in the drizzled::message namespace.
28
  drizzled::message::Schema schema;
323 by Brian Aker
Updated proto file for table (not FRM work).
29
30
  {
31
    // Read the existing address book.
32
    fstream input(argv[1], ios::in | ios::binary);
660.1.3 by Eric Herman
removed trailing whitespace with simple script:
33
    if (!schema.ParseFromIstream(&input))
323 by Brian Aker
Updated proto file for table (not FRM work).
34
    {
35
      cerr << "Failed to parse schema." << endl;
36
      return -1;
37
    }
38
  }
39
40
  printSchema(&schema);
41
42
  return 0;
43
}