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/schema.pb.h>
00024
00025 using namespace std;
00026 using namespace drizzled;
00027
00028 int main(int argc, char* argv[])
00029 {
00030 GOOGLE_PROTOBUF_VERIFY_VERSION;
00031
00032 string file_name;
00033 message::Schema schema;
00034
00035 if (argc < 2)
00036 {
00037 cerr << "Usage: " << argv[0] << " SCHEMA" << endl;
00038 return -1;
00039 }
00040
00041 if (argc == 3)
00042 file_name= argv[2];
00043 else
00044 file_name= argv[1];
00045
00046 schema.set_name(argv[1]);
00047 schema.set_catalog("LOCAL");
00048 schema.mutable_engine()->set_name("filesystem");
00049 schema.set_creation_timestamp(time(NULL));
00050 schema.set_update_timestamp(time(NULL));
00051 schema.set_collation("utf8_general_ci");
00052 schema.set_uuid("schema_writer");
00053 schema.set_version(1);
00054
00055 fstream output(file_name.c_str(), ios::out | ios::trunc | ios::binary);
00056
00057 if (not schema.SerializeToOstream(&output))
00058 {
00059 cerr << "Failed to write schema." << endl;
00060 return -1;
00061 }
00062
00063 return 0;
00064 }