COOPY » Guide  version 0.6.5
/home/paulfitz/cvs/coopy_scm/coopy/src/libcoopy_core/include/coopy/FoldedSheet.h
Go to the documentation of this file.
00001 #ifndef COOPY_FOLDEDSHEET
00002 #define COOPY_FOLDEDSHEET
00003 
00004 #include <string>
00005 #include <coopy/TypedSheet.h>
00006 
00007 namespace coopy {
00011   namespace fold {
00012     class FoldedCell;
00013     class FoldedSheet;
00014   }
00015 }
00016 
00017 class coopy::fold::FoldedCell {
00018 public:
00019   coopy::store::SheetCell datum;
00020   FoldedSheet *sheet;
00021 
00022   FoldedCell() {
00023     sheet = 0 /*NULL*/;
00024   }
00025 
00026   ~FoldedCell() {
00027     clear();
00028   }
00029 
00030   FoldedCell(const FoldedCell& alt) {
00031     sheet = 0 /*NULL*/;
00032     if (alt.sheet) {
00033       sheet = alt.sheet;
00034       ((coopy::store::RefCount*)sheet)->addReference();
00035     }
00036     datum = alt.datum;
00037   }
00038 
00039   const FoldedCell& operator = (const FoldedCell& alt) {
00040     clear();
00041     if (alt.sheet) {
00042       sheet = alt.sheet;
00043       ((coopy::store::RefCount*)sheet)->addReference();
00044     }    
00045     datum = alt.datum;
00046     return *this;
00047   }
00048 
00049   void clear();
00050 
00051   FoldedSheet *getSheet() { return sheet; }
00052 
00053   FoldedSheet *getOrCreateSheet();
00054 };
00055 
00056 class coopy::fold::FoldedSheet : public coopy::store::TypedSheet<FoldedCell> {
00057 public:
00058   using coopy::store::DataSheet::cellString;
00059 
00060   virtual std::string cellString(int x, int y) const {
00061     bool b;
00062     return cellString(x,y,b);
00063   }
00064 
00065   virtual std::string cellString(int x, int y, bool& escaped) const {
00066     coopy::store::SheetCell c = cellSummary(x,y);
00067     escaped = c.escaped;
00068     return c.text;
00069   }
00070 
00071   virtual bool cellString(int x, int y, const std::string& str) {
00072     return cellSummary(x,y,coopy::store::SheetCell(str,false));
00073   }
00074   
00075   virtual bool cellString(int x, int y, const std::string& str, bool escaped) {
00076     return cellSummary(x,y,coopy::store::SheetCell(str,escaped));
00077   }
00078 
00079   virtual coopy::store::SheetCell cellSummary(int x, int y) const;
00080 
00081   virtual bool cellSummary(int x, int y, const coopy::store::SheetCell& c) {
00082     FoldedCell& c2 = cell(x,y);
00083     c2.datum = c;
00084     c2.sheet = 0/*NULL*/;
00085     return true;
00086   }
00087 
00088   virtual DataSheet *getNestedSheet(int x, int y) {
00089     FoldedCell& c = cell(x,y);
00090     return c.sheet;
00091   }
00092 
00093   virtual bool hasExternalColumnNames() const {
00094     return false;
00095   }
00096 };
00097 
00098 #endif
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines