COOPY » Guide
version 0.6.5
|
00001 #include <coopy/Coopy.h> 00002 #include <coopy/FileIO.h> 00003 #include <coopy/JsWrap.h> 00004 #include <coopy/JsonBook.h> 00005 00006 #include <stdio.h> 00007 00008 extern std::string coopy_js(); 00009 extern std::string coopy_test_js(); 00010 00011 using namespace coopy::app; 00012 using namespace coopy::store; 00013 using namespace coopy::store::json; 00014 using namespace coopy::js; 00015 using namespace std; 00016 00017 int main(int argc, char *argv[]) { 00018 if (argc!=4) return 1; 00019 const char *in_name = argv[1]; 00020 const char *format = argv[2]; 00021 const char *out_name = argv[3]; 00022 Coopy coopy; 00023 PolyBook book = coopy.loadBook(in_name); 00024 if (!book.isValid()) return 2; 00025 if (book.getSheetCount()!=1) return 3; 00026 PolySheet sheet = book.readSheetByIndex(0); 00027 00028 JsWrap wrap; 00029 wrap.apply(coopy_js()); 00030 wrap.apply(coopy_test_js()); 00031 wrap.send("set_format",format); 00032 Property opts; 00033 opts.put("hash",0); 00034 wrap.send("set_input",JsonBook::render(&book,opts)); 00035 00036 FileIO fout; 00037 if (!fout.openForWrite(out_name,Property())) { 00038 return 4; 00039 } 00040 fprintf(fout.get(),"%s",wrap.apply("test_reader()").c_str()); 00041 00042 return 0; 00043 }