summaryrefslogtreecommitdiffstats
path: root/src/cls/cmpomap/ops.h
blob: 39b1049e8f98475d457e892552048631f2547168 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
// vim: ts=8 sw=2 smarttab ft=cpp

/*
 * Ceph - scalable distributed file system
 *
 * Copyright (C) 2020 Red Hat, Inc
 *
 * This is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1, as published by the Free Software
 * Foundation.  See file COPYING.
 */

#pragma once

#include "types.h"
#include "include/encoding.h"

namespace cls::cmpomap {

struct cmp_vals_op {
  Mode mode;
  Op comparison;
  ComparisonMap values;
  std::optional<ceph::bufferlist> default_value;
};

inline void encode(const cmp_vals_op& o, ceph::bufferlist& bl, uint64_t f=0)
{
  ENCODE_START(1, 1, bl);
  encode(o.mode, bl);
  encode(o.comparison, bl);
  encode(o.values, bl);
  encode(o.default_value, bl);
  ENCODE_FINISH(bl);
}

inline void decode(cmp_vals_op& o, ceph::bufferlist::const_iterator& bl)
{
  DECODE_START(1, bl);
  decode(o.mode, bl);
  decode(o.comparison, bl);
  decode(o.values, bl);
  decode(o.default_value, bl);
  DECODE_FINISH(bl);
}

struct cmp_set_vals_op {
  Mode mode;
  Op comparison;
  ComparisonMap values;
  std::optional<ceph::bufferlist> default_value;
};

inline void encode(const cmp_set_vals_op& o, ceph::bufferlist& bl, uint64_t f=0)
{
  ENCODE_START(1, 1, bl);
  encode(o.mode, bl);
  encode(o.comparison, bl);
  encode(o.values, bl);
  encode(o.default_value, bl);
  ENCODE_FINISH(bl);
}

inline void decode(cmp_set_vals_op& o, ceph::bufferlist::const_iterator& bl)
{
  DECODE_START(1, bl);
  decode(o.mode, bl);
  decode(o.comparison, bl);
  decode(o.values, bl);
  decode(o.default_value, bl);
  DECODE_FINISH(bl);
}

struct cmp_rm_keys_op {
  Mode mode;
  Op comparison;
  ComparisonMap values;
};

inline void encode(const cmp_rm_keys_op& o, ceph::bufferlist& bl, uint64_t f=0)
{
  ENCODE_START(1, 1, bl);
  encode(o.mode, bl);
  encode(o.comparison, bl);
  encode(o.values, bl);
  ENCODE_FINISH(bl);
}

inline void decode(cmp_rm_keys_op& o, ceph::bufferlist::const_iterator& bl)
{
  DECODE_START(1, bl);
  decode(o.mode, bl);
  decode(o.comparison, bl);
  decode(o.values, bl);
  DECODE_FINISH(bl);
}

} // namespace cls::cmpomap