| 237 | void decrRefCount(robj_roptr o); |
| 238 | void incrRefCount(robj_roptr o); |
| 239 | class robj_sharedptr |
| 240 | { |
| 241 | redisObject *m_ptr; |
| 242 | |
| 243 | public: |
| 244 | robj_sharedptr() |
| 245 | : m_ptr(nullptr) |
| 246 | {} |
| 247 | explicit robj_sharedptr(redisObject *ptr) |
| 248 | : m_ptr(ptr) |
| 249 | { |
| 250 | if(m_ptr) |
| 251 | incrRefCount(ptr); |
| 252 | } |
| 253 | ~robj_sharedptr() |
| 254 | { |
| 255 | if (m_ptr) |
| 256 | decrRefCount(m_ptr); |
| 257 | } |
| 258 | robj_sharedptr(const robj_sharedptr& other) |
| 259 | : m_ptr(other.m_ptr) |
| 260 | { |
| 261 | if(m_ptr) |
| 262 | incrRefCount(m_ptr); |
| 263 | } |
| 264 | |
| 265 | robj_sharedptr(robj_sharedptr&& other) |
| 266 | { |
| 267 | m_ptr = other.m_ptr; |
| 268 | other.m_ptr = nullptr; |
| 269 | } |
| 270 | |
| 271 | robj_sharedptr &operator=(const robj_sharedptr& other) |
| 272 | { |
| 273 | robj_sharedptr tmp(other); |
| 274 | using std::swap; |
| 275 | swap(m_ptr, tmp.m_ptr); |
| 276 | return *this; |
| 277 | } |
| 278 | robj_sharedptr &operator=(redisObject *ptr) |
| 279 | { |
| 280 | robj_sharedptr tmp(ptr); |
| 281 | using std::swap; |
| 282 | swap(m_ptr, tmp.m_ptr); |
| 283 | return *this; |
| 284 | } |
| 285 | |
| 286 | redisObject* operator->() const |
| 287 | { |
| 288 | return m_ptr; |
| 289 | } |
| 290 | |
| 291 | bool operator!() const |
| 292 | { |
| 293 | return !m_ptr; |
| 294 | } |
| 295 | |
| 296 | explicit operator bool() const{ |
no test coverage detected