COOPY » Guide  version 0.6.5
/home/paulfitz/cvs/coopy_scm/coopy/src/libsqlite/test_sqlite.cpp
Go to the documentation of this file.
00001 
00002 #include <coopy/SqliteSheet.h>
00003 #include <coopy/SqliteTextBook.h>
00004 
00005 #include <sqlite3.h>
00006 
00007 #include <stdio.h>
00008 
00009 using namespace coopy::store;
00010 using namespace coopy::store::sqlite;
00011 using namespace std;
00012 
00013 int main(int argc, char *argv[]) {
00014   if (argc<2) {
00015     printf("Call with database_filename.db [table]\n");
00016   }
00017   SqliteTextBook book;
00018   Property p;
00019   book.read(argv[1],true,p);
00020   vector<string> names = book.getNames();
00021   PolySheet sheet;
00022   if (argc>2) {
00023     sheet = book.readSheet(argv[2]);
00024   } else {
00025     sheet = book.readSheet(names[0]);
00026   }
00027 
00028   for (int i=0; i<sheet.height(); i++) {
00029     for (int j=0; j<sheet.width(); j++) {
00030       printf("\"%s\" ", sheet.cellString(j,i).c_str());
00031     }
00032     printf("\n");
00033   }
00034 
00035   string tmp = sheet.cellString(2,1);
00036   sheet.cellString(2,1,sheet.cellString(2,0));
00037   sheet.cellString(2,0,tmp);
00038 
00039   printf("===\n");
00040   for (int i=0; i<sheet.height(); i++) {
00041     for (int j=0; j<sheet.width(); j++) {
00042       printf("\"%s\" ", sheet.cellString(j,i).c_str());
00043     }
00044     printf("\n");
00045   }
00046   return 1;
00047 }
00048 
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines