| 152 | } |
| 153 | |
| 154 | bool pipe_manager::update_end(pipe_stream* out /* = NULL */) |
| 155 | { |
| 156 | if (m_streams.empty()) { |
| 157 | return true; |
| 158 | } |
| 159 | |
| 160 | std::list<pipe_stream*>::iterator it = m_streams.begin(); |
| 161 | |
| 162 | string* pBuf = m_pBuf2; |
| 163 | pBuf->clear(); |
| 164 | |
| 165 | if ((*it)->pop_end(pBuf, 0) == -1) { |
| 166 | return false; |
| 167 | } |
| 168 | |
| 169 | string* pLast = pBuf; |
| 170 | const char* ptr = pLast->c_str(); |
| 171 | size_t len = pLast->length(); |
| 172 | |
| 173 | pBuf = m_pBuf1; |
| 174 | pBuf->clear(); |
| 175 | |
| 176 | ++it; |
| 177 | for (; it != m_streams.end(); ++it) { |
| 178 | if (len > 0 && (*it)->push_pop(ptr, len, pBuf, 0) == -1) { |
| 179 | return false; |
| 180 | } |
| 181 | if ((*it)->pop_end(pBuf, 0) == -1) { |
| 182 | return false; |
| 183 | } |
| 184 | |
| 185 | pLast = pBuf; |
| 186 | ptr = pLast->c_str(); |
| 187 | len = pLast->length(); |
| 188 | |
| 189 | if (pBuf == m_pBuf1) { |
| 190 | pBuf = m_pBuf2; |
| 191 | } else { |
| 192 | pBuf = m_pBuf1; |
| 193 | } |
| 194 | pBuf->clear(); |
| 195 | } |
| 196 | |
| 197 | if (!pLast->empty() && out != NULL) { |
| 198 | return out->push_pop(pLast->c_str(), |
| 199 | pLast->length(), NULL, 0) != -1; |
| 200 | } |
| 201 | return true; |
| 202 | } |
| 203 | |
| 204 | pipe_manager& pipe_manager::operator<<(const acl::string& s) |
| 205 | { |