summaryrefslogtreecommitdiff
path: root/utils/zenutils/libraries/pelib-0.9/pelib/buffer/OutputBuffer.h
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2008-07-11 15:50:46 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2008-07-11 15:50:46 +0000
commit14c7f45cdae826f88dc539c8c38dd95caf305731 (patch)
tree832da054b7cfb2dc6fd63339af736625f31d21aa /utils/zenutils/libraries/pelib-0.9/pelib/buffer/OutputBuffer.h
parent7c84ede3781c27db73403bd6302f320c76a58c8c (diff)
downloadrockbox-14c7f45cdae826f88dc539c8c38dd95caf305731.tar.gz
rockbox-14c7f45cdae826f88dc539c8c38dd95caf305731.zip
Add zook's ZenUtils to SVN
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18010 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/zenutils/libraries/pelib-0.9/pelib/buffer/OutputBuffer.h')
-rwxr-xr-xutils/zenutils/libraries/pelib-0.9/pelib/buffer/OutputBuffer.h51
1 files changed, 51 insertions, 0 deletions
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 @@
1/*
2* OutputBuffer.h - Part of the PeLib library.
3*
4* Copyright (c) 2004 - 2005 Sebastian Porst (webmaster@the-interweb.com)
5* All rights reserved.
6*
7* This software is licensed under the zlib/libpng License.
8* For more details see http://www.opensource.org/licenses/zlib-license.php
9* or the license information file (license.htm) in the root directory
10* of PeLib.
11*/
12
13#ifndef OUTPUTBUFFER_H
14#define OUTPUTBUFFER_H
15
16#include <vector>
17#include <iterator>
18
19namespace PeLib
20{
21 class OutputBuffer
22 {
23 private:
24 std::vector<unsigned char>& m_vBuffer;
25
26 public:
27 OutputBuffer(std::vector<unsigned char>& vBuffer);
28 const unsigned char* data() const;
29 unsigned long size();
30
31 template<typename T>
32 OutputBuffer& operator<<(const T& value)
33 {
34 const unsigned char* p = reinterpret_cast<const unsigned char*>(&value);
35 std::copy(p, p + sizeof(value), std::back_inserter(m_vBuffer));
36 return *this;
37 }
38 void add(const char* lpBuffer, unsigned long ulSize);
39 void reset();
40 void resize(unsigned int uiSize);
41 void set(unsigned int uiPosition);
42
43 template<typename T>
44 void update(unsigned long ulIndex, const T& value)
45 {
46 *(T*)(&m_vBuffer[ulIndex]) = value;
47 }
48 };
49}
50
51#endif