00001 #ifndef _STR_CharChopper_H_ // -*-c++-*-
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
00030
00031
00032
00033
00034
00035 #include <cstddef>
00036 #include <cassert>
00037 #include <StrMod/StreamProcessor.h>
00038 #include <StrMod/StrChunkPtrT.h>
00039 #include <StrMod/BufferChunk.h>
00040 #include <StrMod/GroupChunk.h>
00041
00042 #define _STR_CharChopper_H_
00043
00044 namespace strmod {
00045 namespace strmod {
00046
00047 class GroupVector;
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064 class CharChopper : public StreamProcessor
00065 {
00066 public:
00067 static const STR_ClassIdent identifier;
00068
00069
00070
00071
00072
00073
00074 CharChopper(char chopchar) : chopchar_(chopchar) { }
00075
00076
00077 inline virtual int AreYouA(const lcore::ClassIdent &cid) const;
00078
00079 private:
00080 const char chopchar_;
00081 StrChunkPtrT<GroupChunk> groupdata_;
00082 StrChunkPtrT<BufferChunk> curdata_;
00083 size_t usedsize_;
00084 enum { INYes, INNo, INMaybe } incoming_is_bc_;
00085
00086 virtual const lcore::ClassIdent *i_GetIdent() const { return &identifier; }
00087
00088 virtual void processIncoming();
00089
00090 void addChunk(const StrChunkPtr &chnk);
00091 inline void checkIncoming();
00092 inline void zeroIncoming();
00093 inline void replaceIncoming(const StrChunkPtr &data);
00094
00095 private:
00096 CharChopper(const CharChopper &b);
00097 };
00098
00099
00100
00101 inline int CharChopper::AreYouA(const lcore::ClassIdent &cid) const
00102 {
00103 return((identifier == cid) || StreamProcessor::AreYouA(cid));
00104 }
00105
00106 inline void CharChopper::checkIncoming()
00107 {
00108 assert(incoming_);
00109 if (incoming_is_bc_ == INMaybe)
00110 {
00111 if (incoming_->AreYouA(BufferChunk::identifier))
00112 {
00113 incoming_is_bc_ = INYes;
00114 }
00115 else
00116 {
00117 incoming_is_bc_ = INNo;
00118 }
00119 }
00120 }
00121
00122 inline void CharChopper::zeroIncoming()
00123 {
00124 incoming_.ReleasePtr();
00125 incoming_is_bc_ = INMaybe;
00126 }
00127
00128 inline void CharChopper::replaceIncoming(const StrChunkPtr &data)
00129 {
00130 incoming_ = data;
00131 }
00132
00133 };
00134 };
00135
00136 #endif