| 228 | } |
| 229 | |
| 230 | bool stream::set_ctx(void* ctx, const char* key /* = NULL */, |
| 231 | bool replace /* = true */) |
| 232 | { |
| 233 | if (key == NULL || *key == 0) { |
| 234 | if (!replace && default_ctx_ != NULL) { |
| 235 | return false; |
| 236 | } |
| 237 | default_ctx_ = ctx; |
| 238 | return true; |
| 239 | } |
| 240 | |
| 241 | if (ctx_table_ == NULL) { |
| 242 | ctx_table_ = NEW std::map<string, void*>; |
| 243 | } |
| 244 | |
| 245 | if (replace) { |
| 246 | (*ctx_table_)[key] = ctx; |
| 247 | return true; |
| 248 | } |
| 249 | |
| 250 | std::map<string, void*>::const_iterator cit = ctx_table_->find(key); |
| 251 | if (cit != ctx_table_->end()) { |
| 252 | return false; |
| 253 | } |
| 254 | (*ctx_table_)[key] = ctx; |
| 255 | return true; |
| 256 | } |
| 257 | |
| 258 | void* stream::get_ctx(const char* key /* = NULL */) const |
| 259 | { |
no test coverage detected