COOPY » Guide
version 0.6.5
|
00001 #ifndef COOPY_FORMATSNIFFER_INC 00002 #define COOPY_FORMATSNIFFER_INC 00003 00004 #include <stdio.h> 00005 #include <string> 00006 00007 #include <coopy/Reader.h> 00008 #include <coopy/Format.h> 00009 #include <coopy/FileIO.h> 00010 00011 namespace coopy { 00012 namespace format { 00013 class FormatSniffer; 00014 } 00015 } 00016 00017 00018 class coopy::format::FormatSniffer : public Reader { 00019 private: 00020 coopy::store::FileIO fio; 00021 std::string cache; 00022 public: 00023 FormatSniffer() { 00024 } 00025 00026 virtual ~FormatSniffer() { 00027 close(); 00028 } 00029 00030 bool setString(const char *str); 00031 00032 bool open(const char *fname, bool caching = true); 00033 bool close(); 00034 00035 bool wrap(coopy::store::FileIO& fin, bool caching); 00036 00037 Format getFormat(); 00038 00039 virtual std::string read() { 00040 std::string tmp = cache; 00041 cache = ""; 00042 return tmp; 00043 } 00044 }; 00045 00046 #endif 00047