~brianaker/libmemcached/update-m4-sept

« back to all changes in this revision

Viewing changes to libmemcached/result.h

  • Committer: Continuous Integration
  • Date: 2012-12-17 04:09:26 UTC
  • mfrom: (1088.1.3 libmemcached-1.2)
  • Revision ID: ci@tangent.org-20121217040926-h5fq4ad02z6l0a74
Merge lp:~tangent-org/libmemcached/1.2-build/ Build: jenkins-Libmemcached-169

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 */
37
37
 
38
38
#pragma once
 
39
 
 
40
#include "libmemcached/string.hpp"
 
41
 
 
42
struct Result {
 
43
  struct {
 
44
    bool is_allocated;
 
45
    bool is_initialized;
 
46
  } options;
 
47
  uint32_t item_flags;
 
48
  time_t item_expiration;
 
49
  size_t key_length;
 
50
  uint64_t item_cas;
 
51
  struct memcached_st *root;
 
52
  memcached_string_st value;
 
53
  uint64_t numeric_value;
 
54
  uint64_t count;
 
55
  char item_key[MEMCACHED_MAX_KEY];
 
56
  /* Add result callback function */
 
57
 
 
58
  Result(memcached_result_st* shell_, const struct memcached_st* memc_) :
 
59
    item_flags(0),
 
60
    item_expiration(0),
 
61
    key_length(0),
 
62
    item_cas(0),
 
63
    root(const_cast<memcached_st*>(memc_)),
 
64
    numeric_value(UINT64_MAX),
 
65
    count(0),
 
66
    _shell(shell_)
 
67
  {
 
68
    item_key[0]= 0;
 
69
 
 
70
    if (shell_)
 
71
    {
 
72
      memcached_set_allocated(_shell, false);
 
73
    }
 
74
    else
 
75
    {
 
76
      _shell= &_owned_shell;
 
77
      memcached_set_allocated(_shell, true);
 
78
    }
 
79
 
 
80
    _shell->impl(this);
 
81
    memcached_set_initialized(_shell, true);
 
82
 
 
83
    memcached_string_create((memcached_st*)root, &value, 0);
 
84
  }
 
85
 
 
86
  ~Result()
 
87
  {
 
88
  }
 
89
 
 
90
  memcached_result_st* shell()
 
91
  {
 
92
    return _shell;
 
93
  }
 
94
 
 
95
private:
 
96
  memcached_result_st* _shell;
 
97
  memcached_result_st _owned_shell;
 
98
};
 
99
 
39
100
void memcached_result_reset_value(memcached_result_st *ptr);