Couchbase C++ SDK
1.4.0 (rev. 59aa900)
Toggle main menu visibility
Loading...
Searching...
No Matches
codec_flags.hxx
Go to the documentation of this file.
1
/* -*- Mode: C++; tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2
/*
3
* Copyright 2020-Present Couchbase, Inc.
4
*
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
* you may not use this file except in compliance with the License.
7
* You may obtain a copy of the License at
8
*
9
* http://www.apache.org/licenses/LICENSE-2.0
10
*
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
* See the License for the specific language governing permissions and
15
* limitations under the License.
16
*/
17
18
#pragma once
19
20
#include <cinttypes>
21
22
namespace
couchbase::codec::codec_flags
23
{
24
40
constexpr
std::uint32_t
common_format_mask
= 0x0F000000;
41
42
enum class
common_flags
: std::uint32_t {
43
reserved
= 0x00,
44
client_specific
= 0x01,
// called PRIVATE in RFC and other SDKs
45
json
= 0x02,
46
binary
= 0x03,
47
string
= 0x04
48
};
49
56
constexpr
auto
57
create_common_flags
(
common_flags
flags) -> std::uint32_t
58
{
59
return
static_cast<
std::uint32_t
>
(flags) << 24U;
60
}
61
70
constexpr
auto
71
extract_common_flags
(std::uint32_t flags) ->
common_flags
72
{
73
switch
(
auto
value =
static_cast<
common_flags
>
(flags >> 24U)) {
74
case
common_flags::client_specific
:
75
case
common_flags::json
:
76
case
common_flags::binary
:
77
case
common_flags::string
:
78
return
value;
79
default
:
80
break
;
81
}
82
return
common_flags::reserved
;
83
}
84
94
constexpr
auto
95
has_common_flags
(std::uint32_t flags) ->
bool
96
{
97
return
extract_common_flags
(flags) !=
common_flags::reserved
;
98
}
99
108
constexpr
auto
109
has_common_flags
(std::uint32_t flags, std::uint32_t expected_common_flag) ->
bool
110
{
111
return
has_common_flags
(flags) && (flags &
common_format_mask
) == expected_common_flag;
112
}
113
122
constexpr
auto
123
has_common_flags
(std::uint32_t flags,
common_flags
expected_common_flag) ->
bool
124
{
125
return
has_common_flags
(flags) &&
126
(flags &
common_format_mask
) ==
create_common_flags
(expected_common_flag);
127
}
128
138
constexpr
auto
139
has_compression_flags
(std::uint32_t flags) ->
bool
140
{
141
return
(flags >> 29U) > 0;
142
}
143
144
constexpr
std::uint32_t
private_common_flags
=
create_common_flags
(
common_flags::client_specific
);
145
constexpr
std::uint32_t
json_common_flags
=
create_common_flags
(
common_flags::json
);
146
constexpr
std::uint32_t
binary_common_flags
=
create_common_flags
(
common_flags::binary
);
147
constexpr
std::uint32_t
string_common_flags
=
create_common_flags
(
common_flags::string
);
148
}
// namespace couchbase::codec::codec_flags
couchbase::codec::codec_flags
Definition
codec_flags.hxx:23
couchbase::codec::codec_flags::binary_common_flags
constexpr std::uint32_t binary_common_flags
Definition
codec_flags.hxx:146
couchbase::codec::codec_flags::has_common_flags
constexpr auto has_common_flags(std::uint32_t flags) -> bool
Checks whether the upper 8 bits are set, indicating common flags presence.
Definition
codec_flags.hxx:95
couchbase::codec::codec_flags::string_common_flags
constexpr std::uint32_t string_common_flags
Definition
codec_flags.hxx:147
couchbase::codec::codec_flags::common_flags
common_flags
Definition
codec_flags.hxx:42
couchbase::codec::codec_flags::common_flags::client_specific
@ client_specific
Definition
codec_flags.hxx:44
couchbase::codec::codec_flags::common_flags::json
@ json
Definition
codec_flags.hxx:45
couchbase::codec::codec_flags::common_flags::reserved
@ reserved
Definition
codec_flags.hxx:43
couchbase::codec::codec_flags::common_flags::binary
@ binary
Definition
codec_flags.hxx:46
couchbase::codec::codec_flags::common_flags::string
@ string
Definition
codec_flags.hxx:47
couchbase::codec::codec_flags::private_common_flags
constexpr std::uint32_t private_common_flags
Definition
codec_flags.hxx:144
couchbase::codec::codec_flags::extract_common_flags
constexpr auto extract_common_flags(std::uint32_t flags) -> common_flags
Returns only the common flags from the full flags.
Definition
codec_flags.hxx:71
couchbase::codec::codec_flags::common_format_mask
constexpr std::uint32_t common_format_mask
32bit flag is composed of:
Definition
codec_flags.hxx:40
couchbase::codec::codec_flags::has_compression_flags
constexpr auto has_compression_flags(std::uint32_t flags) -> bool
Checks whether the upper 3 bits are set, indicating compression presence.
Definition
codec_flags.hxx:139
couchbase::codec::codec_flags::json_common_flags
constexpr std::uint32_t json_common_flags
Definition
codec_flags.hxx:145
couchbase::codec::codec_flags::create_common_flags
constexpr auto create_common_flags(common_flags flags) -> std::uint32_t
Takes a enum representation of common flags and moves them to the common flags MSBs.
Definition
codec_flags.hxx:57
couchbase::codec::binary
std::vector< std::byte > binary
Definition
encoded_value.hxx:25
couchbase
codec
codec_flags.hxx
Generated by
1.17.0