00001 #ifndef _STR_StaticBuffer_H_ // -*- mode: c++; c-file-style: "hopper" -*-
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifdef __GNUG__
00022 # pragma interface
00023 #endif
00024
00025
00026
00027
00028
00029 #include <StrMod/StrChunk.h>
00030 #include <cstddef>
00031
00032 #define _STR_StaticBuffer_H_
00033
00034 namespace strmod {
00035 namespace strmod {
00036
00037
00038
00039
00040
00041
00042 class StaticBuffer : public StrChunk
00043 {
00044 private:
00045 typedef lcore::U1Byte U1Byte;
00046 public:
00047 static const STR_ClassIdent identifier;
00048
00049
00050
00051
00052
00053
00054
00055 inline StaticBuffer(const void *buf, size_t buflen);
00056
00057
00058
00059 virtual ~StaticBuffer() { }
00060
00061 virtual int AreYouA(const lcore::ClassIdent &cid) const {
00062 return (identifier == cid) || StrChunk::AreYouA(cid);
00063 }
00064
00065 virtual unsigned int Length() const { return buflen_; }
00066
00067
00068 const void *getVoidP() { return(buf_); }
00069
00070 inline const U1Byte *getCharP();
00071
00072 protected:
00073 virtual const lcore::ClassIdent *i_GetIdent() const { return &identifier; }
00074
00075 inline virtual void acceptVisitor(ChunkVisitor &visitor)
00076 throw(ChunkVisitor::halt_visitation);
00077
00078 private:
00079 const void * const buf_;
00080 const size_t buflen_;
00081 };
00082
00083
00084
00085 inline StaticBuffer::StaticBuffer(const void *buf, size_t buflen)
00086 : buf_(buf), buflen_(buflen)
00087 {
00088 }
00089
00090 inline const lcore::U1Byte *StaticBuffer::getCharP()
00091 {
00092 return(static_cast<const U1Byte *>(buf_));
00093 }
00094
00095 inline void StaticBuffer::acceptVisitor(ChunkVisitor &visitor)
00096 throw(ChunkVisitor::halt_visitation)
00097 {
00098 call_visitDataBlock(visitor, const_cast<void *>(buf_), buflen_);
00099 }
00100
00101 };
00102 };
00103
00104 #endif