~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/serialize/schema_reader.cc

  • Committer: Brian Aker
  • Date: 2008-07-13 21:20:24 UTC
  • Revision ID: brian@tangent.org-20080713212024-o6263c1vha7yxdeu
More bool removal. More cow bell!

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#include <iostream>
2
 
#include <fstream>
3
 
#include <string>
4
 
#include "schema.pb.h"
5
 
using namespace std;
6
 
 
7
 
/* 
8
 
  Written from Google proto example
9
 
*/
10
 
 
11
 
void printSchema(const drizzle::Schema *schema) 
12
 
{
13
 
  cout << "CREATE SCHEMA `" << schema->name() << "` ";
14
 
  if (schema->has_collation())
15
 
    cout << "COLLATE `" << schema->collation() << "` ";
16
 
  if (schema->has_characterset())
17
 
    cout << "CHARACTER SET `" << schema->characterset() <<"` ";
18
 
  cout << ";" << endl;
19
 
}
20
 
 
21
 
int main(int argc, char* argv[]) 
22
 
{
23
 
  GOOGLE_PROTOBUF_VERIFY_VERSION;
24
 
 
25
 
  if (argc != 2) {
26
 
    cerr << "Usage:  " << argv[0] << " SCHEMA" << endl;
27
 
    return -1;
28
 
  }
29
 
 
30
 
  drizzle::Schema schema;
31
 
 
32
 
  {
33
 
    // Read the existing address book.
34
 
    fstream input(argv[1], ios::in | ios::binary);
35
 
    if (!schema.ParseFromIstream(&input)) 
36
 
    {
37
 
      cerr << "Failed to parse schema." << endl;
38
 
      return -1;
39
 
    }
40
 
  }
41
 
 
42
 
  printSchema(&schema);
43
 
 
44
 
  return 0;
45
 
}