COOPY » Guide  version 0.6.5
/home/paulfitz/cvs/coopy_scm/coopy/src/libcoopy_core/include/coopy/NameSniffer.h
Go to the documentation of this file.
00001 #ifndef COOPY_NAME_SNIFFER
00002 #define COOPY_NAME_SNIFFER
00003 
00004 #include <coopy/DataSheet.h>
00005 #include <coopy/CompareFlags.h>
00006 
00007 #include <vector>
00008 #include <string>
00009 
00010 namespace coopy {
00011   namespace store {
00012     class NameSniffer;
00013   }
00014 }
00015 
00016 class coopy::store::NameSniffer {
00017 private:
00018   const DataSheet& sheet;
00019   std::vector<std::string> names;
00020   std::vector<int> subset_index;
00021   std::vector<ColumnType> ct;
00022   const coopy::cmp::CompareFlags& flags;
00023   bool embed;
00024   bool fake;
00025   bool canUseTop;
00026   bool sniffed;
00027   int div;
00028 public:
00029  NameSniffer(const DataSheet& sheet, 
00030              const coopy::cmp::CompareFlags& flags,
00031              bool autosniff=true) : sheet(sheet), flags(flags) {
00032     div = -1;
00033     fake = true;
00034     sniffed = false;
00035     canUseTop = false;
00036     if (autosniff) {
00037       sniff();
00038     }
00039   }
00040 
00041   void sniff(int suggest = -1); 
00042 
00043   bool resniff(NameSniffer& alt); 
00044 
00045   int getHeaderHeight() const {
00046     if (div<0) return 0;
00047     return div+1;
00048   }
00049 
00050   int dataWidth() const {
00051     return sheet.width();
00052   }
00053 
00054   int dataHeight() const {
00055     if (div<0) return sheet.height();
00056     return sheet.height()-(div+1);
00057   }
00058 
00059   virtual std::string suggestColumnName(int col) const;
00060 
00061   virtual const ColumnType& suggestColumnType(int col) const {
00062     return ct[col];
00063   }
00064 
00065   virtual const std::vector<std::string>& suggestNames() const {
00066     return names;
00067   }
00068 
00069   virtual const std::vector<int>& getSubset() const {
00070     return subset_index;
00071   }
00072 
00073   virtual const std::vector<ColumnType>& suggestTypes() const {
00074     return ct;
00075   }
00076 
00077   bool isEmbedded() {
00078     return embed;
00079   }
00080 
00081   bool isFake() {
00082     return fake;
00083   }
00084   
00085   bool hasSubset() const {
00086     return subset_index.size()>0;
00087   }
00088 
00089   bool subset(std::vector<std::string>& names);
00090 };
00091 
00092 #endif
00093 
00094 
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines