~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/message/schema_reader.cc

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

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; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
19
 
 
20
 
#include <iostream>
21
 
#include <fstream>
22
 
#include <string>
23
 
#include <drizzled/message/schema.pb.h>
24
 
using namespace std;
25
 
 
26
 
/*
27
 
  Written from Google proto example
28
 
*/
29
 
 
30
 
static void printSchema(const drizzled::message::Schema *schema)
31
 
{
32
 
  cout << "CREATE SCHEMA `" << schema->name() << "` ";
33
 
  if (schema->has_collation())
34
 
    cout << "COLLATE `" << schema->collation() << "` ";
35
 
  cout << ";" << endl;
36
 
}
37
 
 
38
 
int main(int argc, char* argv[])
39
 
{
40
 
  GOOGLE_PROTOBUF_VERIFY_VERSION;
41
 
 
42
 
  if (argc != 2) {
43
 
    cerr << "Usage:  " << argv[0] << " SCHEMA" << endl;
44
 
    return -1;
45
 
  }
46
 
 
47
 
  drizzled::message::Schema schema;
48
 
 
49
 
  {
50
 
    // Read the existing address book.
51
 
    fstream input(argv[1], ios::in | ios::binary);
52
 
    if (!schema.ParseFromIstream(&input))
53
 
    {
54
 
      cerr << "Failed to parse schema." << endl;
55
 
      return -1;
56
 
    }
57
 
  }
58
 
 
59
 
  printSchema(&schema);
60
 
 
61
 
  return 0;
62
 
}