21 #ifndef TPSTREAMER_CPP
22 #define TPSTREAMER_CPP
24 #include "TPStreamer.hpp"
34 this->_mtxstream.Lock();
35 this->_stream.append(buffer);
36 this->_mtxstream.Release();
40 this->_mtxstream.Lock();
41 this->_stream.append(buffer, bsize);
42 this->_mtxstream.Release();
46 TPStreamerDirection direction) {
47 this->_mtxstream.Lock();
49 if(this->_stream.empty()) {
50 this->_mtxstream.Release();
54 if(this->ImplHas(hdr, trl, direction) ==
false) {
55 this->_mtxstream.Release();
61 std::string::size_type p_hdr, p_trl, delta;
64 p_hdr = this->_stream.find(hdr);
65 p_trl = this->_stream.find(trl, p_hdr);
67 p_hdr = this->_stream.rfind(hdr);
68 p_trl = this->_stream.rfind(trl, p_hdr);
72 if(p_hdr == std::string::npos || p_trl == std::string::npos) {
73 this->_mtxstream.Release();
78 this->_mtxstream.Release();
86 *buffer = this->_stream.substr(p_hdr, p_trl - p_hdr + delta);
87 this->_stream.erase(p_hdr, p_trl - p_hdr + delta);
88 this->_mtxstream.Release();
94 TPStreamerDirection direction) {
96 this->_mtxstream.Lock();
97 result = this->ImplHas(hdr, trl, direction);
98 this->_mtxstream.Release();
105 this->_mtxstream.Lock();
106 if(!this->_stream.empty()) {
107 std::string::size_type pos(0);
109 while (pos != std::string::npos) {
110 pos = this->_stream.find(hdr, pos);
111 if(pos != std::string::npos) {
117 this->_mtxstream.Release();
123 this->_mtxstream.Lock();
124 std::cout <<
"[TPStreamer::Dump] " << this->_stream << std::endl;
125 this->_mtxstream.Release();
130 this->_mtxstream.Lock();
131 size = this->_stream.size();
132 this->_mtxstream.Release();
138 this->_mtxstream.Lock();
139 this->_stream.clear();
140 this->_mtxstream.Release();
143 bool TPStreamer::ImplHas(std::string hdr, std::string trl,
144 TPStreamerDirection direction) {
146 if(this->_stream.empty())
149 std::string::size_type p_hdr, p_trl;
152 p_hdr = this->_stream.find(hdr);
153 p_trl = this->_stream.find(trl, p_hdr);
155 p_hdr = this->_stream.rfind(hdr);
156 p_trl = this->_stream.rfind(trl, p_hdr);
159 if(p_hdr == std::string::npos || p_trl == std::string::npos)