COOPY » Guide  version 0.6.5
/home/paulfitz/cvs/coopy_scm/coopy/src/libcoopy_core/include/coopy/SheetStyle.h
Go to the documentation of this file.
00001 #ifndef SHEETSTYLE_INC
00002 #define SHEETSTYLE_INC
00003 
00004 #include <string>
00005 
00006 #include <coopy/Property.h>
00007 
00008 namespace coopy {
00009   namespace store {
00010     class SheetStyle;
00011   }
00012 }
00013 
00014 class coopy::store::SheetStyle {
00015 private:
00016   std::string delim;
00017   std::string eol;
00018   std::string nullToken;
00019   bool haveNull;
00020   bool quoteCollision;
00021   bool trimEnd;
00022   bool markHeader;
00023   bool eolAtEof;
00024 public:
00025   SheetStyle() {
00026     delim = ",";
00027     nullToken = "NULL";
00028 
00029     eol =  "\r\n"; // use Windows encoding, since UNIX is more forgiving
00030     // (victim logic, I know...)
00031 
00032     eolAtEof = true;
00033 
00034     haveNull = true;
00035     markHeader = false;
00036     quoteCollision = true;
00037     trimEnd = true; // needed for a Gnumeric bug in parsing CSV like this:
00038     //1,2,3
00039     //"hi","there
00040     //you
00041     //","oops"
00042   }
00043 
00044   bool setFromFilename(const char *fname);
00045 
00046   void setFromInspection(const char *buffer, int len);
00047 
00048   void setFromProperty(const Property& config);
00049 
00050   std::string getDelimiter() const {
00051     return delim;
00052   }
00053 
00054   void setDelimiter(const std::string& delim) {
00055     this->delim = delim;
00056   }
00057 
00058   std::string getEol() const {
00059     return eol;
00060   }
00061 
00062   void setEol(const std::string& eol) {
00063     this->eol = eol;
00064   }
00065 
00066   std::string getNullToken() const {
00067     return nullToken;
00068   }
00069 
00070   bool haveNullToken() const {
00071     return haveNull;
00072   }
00073 
00074   bool quoteCollidingText() const {
00075     return quoteCollision;
00076   }
00077 
00078   bool shouldTrimEnd() const {
00079     return trimEnd;
00080   }
00081 
00082   bool shouldMarkHeader() const {
00083     return markHeader;
00084   }
00085 
00086   bool shouldEolAtEof() const {
00087     return eolAtEof;
00088   }
00089 
00090   void setMarkHeader(bool flag) {
00091     markHeader = flag;
00092   }
00093 
00094   bool setEolAtEof(bool flag) {
00095     eolAtEof = flag;
00096     return true;
00097   }
00098 
00099   static const SheetStyle defaultStyle;
00100 };
00101 
00102 #endif
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines