00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <iostream>
00021 #include <fstream>
00022 #include <string>
00023 #include <drizzled/message/catalog.pb.h>
00024
00025 using namespace std;
00026 using namespace drizzled;
00027
00028
00029
00030
00031
00032
00033 static void printCatalog(const message::Catalog *catalog)
00034 {
00035 cout << "CREATE CATALOG `" << catalog->name() << "` ";
00036
00037 for (int option_nr=0; option_nr < catalog->engine().options_size(); option_nr++)
00038 {
00039 cout << " " << catalog->engine().options(option_nr).name() << " = "
00040 << "'" << catalog->engine().options(option_nr).state() << "'";
00041 }
00042
00043 cout << ";" << endl;
00044 }
00045
00046 int main(int argc, char* argv[])
00047 {
00048 GOOGLE_PROTOBUF_VERIFY_VERSION;
00049
00050 if (argc != 2) {
00051 cerr << "Usage: " << argv[0] << " CATALOG" << endl;
00052 return -1;
00053 }
00054
00055 message::Catalog catalog;
00056
00057 {
00058
00059 fstream input(argv[1], ios::in | ios::binary);
00060 if (!catalog.ParseFromIstream(&input))
00061 {
00062 cerr << "Failed to parse catalog." << endl;
00063 return -1;
00064 }
00065 }
00066
00067 printCatalog(&catalog);
00068
00069 return 0;
00070 }