#ifndef GRID_SERIALISATION_BINARY_READER_H #define GRID_SERIALISATION_BINARY_READER_H #include #include #include #include #include #include #include namespace Grid { class BinaryWriter : public Writer { private: std::ofstream file; public: BinaryWriter(const std::string &_file) : file(_file,std::ios::binary|std::ios::out) {} ~BinaryWriter() {} // Binary is scopeless void push(const std::string &s) {} void pop(void) {} void write(const std::string& s,const std::string &output) { uint32_t sz = output.size(); write(s,sz); const char * cstr = output.c_str(); for(int c=0;c void writeInternal( const std::string& s, T output ){ // FIXME --- htons, htonl, htno64 etc.. file.write((char *)&output,sizeof(T)); } }; class BinaryReader : public Reader{ private: std::ifstream file; public: BinaryReader(const std::string &_file) : file(_file,std::ios::binary|std::ios::in) {} ~BinaryReader() {} // Binary is scopeless void push(const std::string &s) { } void pop(void) { } void read( const std::string& s,std::string &output ) { output.clear(); uint32_t sz; file.read((char *)&sz,sizeof(sz)); for(int c=0;c void readInternal( const std::string& path, T &output ){ file.read((char *)&output,sizeof(output)); // byte order?? } }; } #endif