00001 #ifndef TYPELIB_VALUE_OPS_HH 00002 #define TYPELIB_VALUE_OPS_HH 00003 00004 #include <typelib/memory_layout.hh> 00005 #include <typelib/value.hh> 00006 #include <iosfwd> 00007 00008 namespace Typelib 00009 { 00010 void init(Value v); 00011 void init(Value v, MemoryLayout const& ops); 00012 void init(uint8_t* data, MemoryLayout const& ops); 00013 00014 void zero(Value v); 00015 void zero(Value v, MemoryLayout const& ops); 00016 void zero(uint8_t* data, MemoryLayout const& ops); 00017 00018 void destroy(Value v); 00019 void destroy(Value v, MemoryLayout const& ops); 00020 void destroy(uint8_t* data, MemoryLayout const& ops); 00021 00022 void copy(Value dst, Value src); 00023 void copy(void* dst, void* src, Type const& type); 00024 00025 bool compare(Value dst, Value src); 00026 bool compare(void* dst, void* src, Type const& type); 00027 00028 void display(std::ostream& io, 00029 MemoryLayout::const_iterator const begin, MemoryLayout::const_iterator const end); 00030 00031 std::vector<uint8_t> dump(Value v); 00032 00033 void dump(Value v, std::vector<uint8_t>& buffer); 00034 void dump(Value v, std::vector<uint8_t>& buffer, MemoryLayout const& ops); 00035 void dump(uint8_t const* v, std::vector<uint8_t>& buffer, MemoryLayout const& ops); 00036 00037 void dump(Value v, std::ostream& stream); 00038 void dump(Value v, std::ostream& stream, MemoryLayout const& ops); 00039 void dump(uint8_t const* v, std::ostream& stream, MemoryLayout const& ops); 00040 00041 void dump(Value v, int fd); 00042 void dump(Value v, int fd, MemoryLayout const& ops); 00043 void dump(uint8_t const* v, int fd, MemoryLayout const& ops); 00044 00045 void dump(Value v, FILE* fd); 00046 void dump(Value v, FILE* fd, MemoryLayout const& ops); 00047 void dump(uint8_t const* v, FILE* fd, MemoryLayout const& ops); 00048 00049 int dump(Value v, uint8_t* buffer, unsigned int buffer_size); 00050 int dump(Value v, uint8_t* buffer, unsigned int buffer_size, MemoryLayout const& ops); 00051 int dump(uint8_t const* v, uint8_t* buffer, unsigned int buffer_size, MemoryLayout const& ops); 00052 00053 struct OutputStream 00054 { 00055 virtual void write(uint8_t const* data, size_t size) = 0; 00056 }; 00057 void dump(Value v, OutputStream& stream); 00058 void dump(Value v, OutputStream& stream, MemoryLayout const& ops); 00059 void dump(uint8_t const* v, OutputStream& stream, MemoryLayout const& ops); 00060 00061 00062 size_t getDumpSize(Value v); 00063 size_t getDumpSize(Value v, MemoryLayout const& ops); 00064 size_t getDumpSize(uint8_t const* v, MemoryLayout const& ops); 00065 00066 struct InputStream 00067 { 00068 virtual void read(uint8_t* data, size_t size) = 0; 00069 }; 00070 void load(Value v, InputStream& stream); 00071 void load(Value v, InputStream& stream, MemoryLayout const& ops); 00072 void load(uint8_t* v, Type const& type, InputStream& stream, MemoryLayout const& ops); 00073 00074 void load(Value v, std::vector<uint8_t> const& buffer); 00075 void load(Value v, std::vector<uint8_t> const& buffer, MemoryLayout const& ops); 00076 void load(uint8_t* v, Type const& type, std::vector<uint8_t> const& buffer, MemoryLayout const& ops); 00077 00078 void load(Value v, uint8_t const* buffer, unsigned int buffer_size); 00079 void load(Value v, uint8_t const* buffer, unsigned int buffer_size, MemoryLayout const& ops); 00080 void load(uint8_t* v, Type const& type, uint8_t const* buffer, unsigned int buffer_size, MemoryLayout const& ops); 00081 } 00082 00083 #endif 00084