lean cpp library
A lean C++ library providing efficient utility classes for high-performance C++ applications.
serializer.h
00001 /*****************************************************/
00002 /* lean IO                      (c) Tobias Zirr 2011 */
00003 /*****************************************************/
00004 
00005 #ifndef LEAN_IO_SERIALIZER
00006 #define LEAN_IO_SERIALIZER
00007 
00008 #include "../lean.h"
00009 #include "../strings/types.h"
00010 #include <typeinfo>
00011 #include <iosfwd>
00012 
00013 namespace lean
00014 {
00015 namespace io
00016 {
00017 
00019 class serializer
00020 {
00021 protected:
00022     ~serializer() throw() { }
00023 
00024 public:
00026     virtual size_t max_length(size_t count) const = 0;
00027 
00029     virtual bool write(std::basic_ostream<utf8_t> &stream, const std::type_info &type, const void *values, size_t count) const = 0;
00031     virtual utf8_t* write(utf8_t *begin, const std::type_info &type, const void *values, size_t count) const = 0;
00032 
00034     virtual bool read(std::basic_istream<utf8_t> &stream, const std::type_info &type, void *values, size_t count) const = 0;
00036     virtual const utf8_t* read(const utf8_t *begin, const utf8_t *end, const std::type_info &type, void *values, size_t count) const = 0;
00037 
00039     virtual const std::type_info& type_info() const = 0;
00040 };
00041 
00042 } // namespace
00043 
00044 using io::serializer;
00045 
00046 } // namespace
00047 
00048 #endif