aboutsummaryrefslogtreecommitdiff
path: root/src/staticmembuf.h
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2012-02-09 05:30:38 +0000
committerMike Buland <eichlan@xagasoft.com>2012-02-09 05:30:38 +0000
commit10747b4fb6ff74fa83384859b09ba695378aea60 (patch)
tree24af7800d3392a4b7add7fc31b9961b6295465a6 /src/staticmembuf.h
parent5a6476514c075743ca13d566bd306b2d71d1952a (diff)
downloadlibbu++-10747b4fb6ff74fa83384859b09ba695378aea60.tar.gz
libbu++-10747b4fb6ff74fa83384859b09ba695378aea60.tar.bz2
libbu++-10747b4fb6ff74fa83384859b09ba695378aea60.tar.xz
libbu++-10747b4fb6ff74fa83384859b09ba695378aea60.zip
Added StaticMemBuf and used it in bin2cpp. You can also set the name of the
class that bin2cpp generates for you.
Diffstat (limited to 'src/staticmembuf.h')
-rw-r--r--src/staticmembuf.h65
1 files changed, 65 insertions, 0 deletions
diff --git a/src/staticmembuf.h b/src/staticmembuf.h
new file mode 100644
index 0000000..f168de3
--- /dev/null
+++ b/src/staticmembuf.h
@@ -0,0 +1,65 @@
1/*
2 * Copyright (C) 2007-2011 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libbu++ library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
8#ifndef BU_STATIC_MEM_BUF_H
9#define BU_STATIC_MEM_BUF_H
10
11#include <stdint.h>
12
13#include "bu/config.h"
14#include "bu/stream.h"
15
16namespace Bu
17{
18 /**
19 * An immutable, read-only memory buffer. Construct this buffer around a
20 * block of raw memory, provide the length of the block, and you can read
21 * from that block via this class as though it were a normal stream.
22 *
23 * Use this class instead of MemBuf when you have a string already, and
24 * don't need to change it. MemBuf will make a copy of your string for
25 * it's own use (often) and this will not (ever).
26 *@ingroup Streams
27 */
28 class StaticMemBuf : public Stream
29 {
30 public:
31 StaticMemBuf( const void *pData, size iSize );
32 virtual ~StaticMemBuf();
33
34 virtual void close();
35 virtual size read( void *pBuf, size iBytes );
36
37 virtual size write( const void *pBuf, size iBytes );
38 using Stream::write;
39 virtual size tell();
40 virtual void seek( size offset );
41 virtual void setPos( size pos );
42 virtual void setPosEnd( size pos );
43 virtual bool isEos();
44 virtual bool isOpen();
45 virtual void flush();
46 virtual bool canRead();
47 virtual bool canWrite();
48 virtual bool isReadable();
49 virtual bool isWritable();
50 virtual bool isSeekable();
51 virtual bool isBlocking();
52 virtual void setBlocking( bool bBlocking=true );
53 virtual void setSize( size iSize );
54 virtual size getSize() const;
55 virtual size getBlockSize() const;
56 virtual Bu::String getLocation() const;
57
58 private:
59 const void *pData;
60 size iSize;
61 size nPos;
62 };
63}
64
65#endif