SerUt
|
00001 /* 00002 00003 This file is a part of SerUt, a library containing some serialization 00004 utilities. 00005 00006 Copyright (C) 2008-2012 Jori Liesenborgs 00007 00008 Contact: jori.liesenborgs@gmail.com 00009 00010 This library is free software; you can redistribute it and/or 00011 modify it under the terms of the GNU Lesser General Public 00012 License as published by the Free Software Foundation; either 00013 version 2.1 of the License, or (at your option) any later version. 00014 00015 This library is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 Lesser General Public License for more details. 00019 00020 You should have received a copy of the GNU Lesser General Public 00021 License along with this library; if not, write to the Free Software 00022 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 00023 USA 00024 00025 */ 00026 00031 #ifndef SERUT_MEMORYSERIALIZER_H 00032 00033 #define SERUT_MEMORYSERIALIZER_H 00034 00035 #include "serutconfig.h" 00036 #include "serializationinterface.h" 00037 00038 namespace serut 00039 { 00040 00042 class SERUT_IMPORTEXPORT MemorySerializer : public SerializationInterface 00043 { 00044 public: 00052 MemorySerializer(const void *pReadBuffer, size_t readSize, 00053 void *pWriteBuffer, size_t writeSize); 00054 00055 ~MemorySerializer(); 00056 00058 size_t getBytesRead() const { return m_readPosition; } 00059 00061 size_t getBytesWritten() const { return m_writePosition; } 00062 00063 bool readBytes(void *pBuffer, size_t amount); 00064 bool writeBytes(const void *pBuffer, size_t amount); 00065 private: 00066 const uint8_t *m_pReadBuffer; 00067 uint8_t *m_pWriteBuffer; 00068 size_t m_readPosition; 00069 size_t m_writePosition; 00070 size_t m_readSize; 00071 size_t m_writeSize; 00072 }; 00073 00074 } // end namespace 00075 00076 #endif // SERUT_MEMORYSERIALIZER_H 00077