From 14c7f45cdae826f88dc539c8c38dd95caf305731 Mon Sep 17 00:00:00 2001 From: Maurus Cuelenaere Date: Fri, 11 Jul 2008 15:50:46 +0000 Subject: Add zook's ZenUtils to SVN git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18010 a1c6a512-1295-4272-9138-f99709370657 --- .../pelib-0.9/pelib/buffer/OutputBuffer.h | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100755 utils/zenutils/libraries/pelib-0.9/pelib/buffer/OutputBuffer.h (limited to 'utils/zenutils/libraries/pelib-0.9/pelib/buffer/OutputBuffer.h') diff --git a/utils/zenutils/libraries/pelib-0.9/pelib/buffer/OutputBuffer.h b/utils/zenutils/libraries/pelib-0.9/pelib/buffer/OutputBuffer.h new file mode 100755 index 0000000000..f1ab99039b --- /dev/null +++ b/utils/zenutils/libraries/pelib-0.9/pelib/buffer/OutputBuffer.h @@ -0,0 +1,51 @@ +/* +* OutputBuffer.h - Part of the PeLib library. +* +* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com) +* All rights reserved. +* +* This software is licensed under the zlib/libpng License. +* For more details see http://www.opensource.org/licenses/zlib-license.php +* or the license information file (license.htm) in the root directory +* of PeLib. +*/ + +#ifndef OUTPUTBUFFER_H +#define OUTPUTBUFFER_H + +#include +#include + +namespace PeLib +{ + class OutputBuffer + { + private: + std::vector& m_vBuffer; + + public: + OutputBuffer(std::vector& vBuffer); + const unsigned char* data() const; + unsigned long size(); + + template + OutputBuffer& operator<<(const T& value) + { + const unsigned char* p = reinterpret_cast(&value); + std::copy(p, p + sizeof(value), std::back_inserter(m_vBuffer)); + return *this; + } + void add(const char* lpBuffer, unsigned long ulSize); + void reset(); + void resize(unsigned int uiSize); + void set(unsigned int uiPosition); + + template + void update(unsigned long ulIndex, const T& value) + { + *(T*)(&m_vBuffer[ulIndex]) = value; + } + }; +} + +#endif -- cgit v1.2.3