COOPY » Guide  version 0.6.5
/home/paulfitz/cvs/coopy_scm/coopy/src/libcoopy_core/CsvSheet.cpp
Go to the documentation of this file.
00001 #include <coopy/CsvSheet.h>
00002 #include <coopy/CsvWrite.h>
00003 #include <coopy/Dbg.h>
00004 
00005 #include <stdio.h>
00006 #include <stdlib.h>
00007 
00008 using namespace coopy::store;
00009 
00010 void CsvSheet::addField(const char *s, bool escaped) {
00011   /*
00012   if (isStrict()) {
00013     if (th>=1&&tw>=this->s.w) {
00014       fprintf(stderr,"Attempt to add a spurious field to a sheet (\"%s\")\n",
00015               s);
00016       if (tw==this->s.w) {
00017         addRecord();
00018       }
00019       fprintf(stderr,"w*h = %d*%d, tw*th = %d*%d\n",
00020               this->s.w,this->s.h,tw,th);
00021       const char *name = "__spurious_field.prior.csv";
00022       fprintf(stderr,"Saving sheet as is to %s\n",name);
00023       CsvFile::write(*this,name);
00024       coopy_print_trace(stdout,__FILE__,__LINE__);
00025       exit(1);
00026     }
00027   }
00028   */
00029   pairCellType p(s,escaped);
00030   rec.push_back(p);
00031   tw++;
00032 }
00033 
00034 void CsvSheet::addRecord() {
00035   s.arr.push_back(rec);
00036   rec.clear();
00037   if (s.w!=tw && s.w!=0) {
00038     valid = false;
00039   }
00040   if (tw>s.w) {
00041     s.w = tw;
00042   }
00043   tw = 0;
00044   th++;
00045   s.h = th;
00046 }
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines