src/stream/ZStreamR_Boundary.h

00001 /*  @(#) $Id: ZStreamR_Boundary.h,v 1.8 2006/04/27 03:19:32 agreen Exp $ */
00002 
00003 /* ------------------------------------------------------------
00004 Copyright (c) 2001 Andrew Green and Learning in Motion, Inc.
00005 http://www.zoolib.org
00006 
00007 Permission is hereby granted, free of charge, to any person obtaining a copy
00008 of this software and associated documentation files (the "Software"), to deal
00009 in the Software without restriction, including without limitation the rights
00010 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00011 copies of the Software, and to permit persons to whom the Software is
00012 furnished to do so, subject to the following conditions:
00013 
00014 The above copyright notice and this permission notice shall be included in
00015 all copies or substantial portions of the Software.
00016 
00017 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00018 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00020 COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00021 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00022 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00023 ------------------------------------------------------------ */
00024 
00025 #ifndef __ZStreamR_Boundary__
00026 #define __ZStreamR_Boundary__ 1
00027 #include "zconfig.h"
00028 
00029 #include "ZStreamer.h"
00030 
00031 #include <string>
00032 
00033 // =================================================================================================
00034 #pragma mark -
00035 #pragma mark * ZStreamR_Boundary
00036 
00038 
00039 class ZStreamR_Boundary : public ZStreamR
00040         {
00041 public:
00042         ZStreamR_Boundary(const std::string& iBoundary, const ZStreamR& iStreamSource);
00043         ZStreamR_Boundary(const void* iBoundary, size_t iBoundarySize, const ZStreamR& iStreamSource);
00044         ~ZStreamR_Boundary();
00045 
00046 // From ZStreamR
00047         virtual void Imp_Read(void* iDest, size_t iCount, size_t* oCountRead);
00048         virtual size_t Imp_CountReadable();
00049 
00050 // Our protocol
00051         bool HitBoundary() const;
00052         void Reset();
00053 
00054 protected:
00055         void Internal_Init();
00056 
00057         const ZStreamR& fStreamSource;
00058         std::string fBoundary;
00059         size_t fDistance[256];
00060         uint8* fBuffer;
00061         size_t fDataStart;
00062         size_t fDataEnd;
00063         bool fHitBoundary;
00064         };
00065 
00066 // =================================================================================================
00067 #pragma mark -
00068 #pragma mark * ZStreamerR_Boundary
00069 
00071 
00072 class ZStreamerR_Boundary : public ZStreamerR
00073         {
00074 public:
00075         ZStreamerR_Boundary(const std::string& iBoundary, ZRef<ZStreamerR> iStreamerSource);
00076 
00077         ZStreamerR_Boundary(const void* iBoundary, size_t iBoundarySize,
00078                 ZRef<ZStreamerR> iStreamerSource);
00079 
00080         virtual ~ZStreamerR_Boundary();
00081 
00082 // From ZStreamerR
00083         virtual const ZStreamR& GetStreamR();
00084 
00085 protected:
00086         ZRef<ZStreamerR> fStreamerSource;
00087         ZStreamR_Boundary fStream;
00088         };
00089 
00090 // Alternate template-based definition:
00091 // typedef ZStreamerRFT<ZStreamR_Boundary> ZStreamerR_Boundary;
00092 
00093 // =================================================================================================
00094 
00095 #endif // __ZStreamR_Boundary__

Generated on Thu Jul 26 11:21:55 2007 for ZooLib by  doxygen 1.4.7