Couchbase C++ SDK
1.4.0 (rev. 59aa900)
Toggle main menu visibility
Loading...
Searching...
No Matches
lookup_in_specs.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 <
couchbase/subdoc/fwd/command.hxx
>
21
#include <
couchbase/subdoc/fwd/command_bundle.hxx
>
22
23
#include <
couchbase/codec/json_transcoder.hxx
>
24
#include <
couchbase/subdoc/count.hxx
>
25
#include <
couchbase/subdoc/exists.hxx
>
26
#include <
couchbase/subdoc/get.hxx
>
27
28
#include <memory>
29
#include <vector>
30
31
namespace
couchbase
32
{
33
class
lookup_in_specs
34
{
35
public
:
36
lookup_in_specs
() =
default
;
37
38
template
<
typename
... Operation>
39
explicit
lookup_in_specs
(Operation... args)
40
{
41
push_back
(args...);
42
}
43
53
static
auto
get
(std::string path) ->
subdoc::get
54
{
55
return
subdoc::get
{ std::move(path) };
56
}
57
67
static
auto
get
(
subdoc::lookup_in_macro
macro) ->
subdoc::get
68
{
69
return
subdoc::get
{ macro };
70
}
71
81
static
auto
exists
(std::string path) ->
subdoc::exists
82
{
83
return
subdoc::exists
{ std::move(path) };
84
}
85
95
static
auto
count
(std::string path) ->
subdoc::count
96
{
97
return
subdoc::count
{ std::move(path) };
98
}
99
109
template
<
typename
Operation>
110
void
push_back
(
const
Operation& operation)
111
{
112
operation.encode(bundle());
113
}
114
126
template
<
typename
Operation,
typename
... Rest>
127
void
push_back
(
const
Operation& operation, Rest... args)
128
{
129
push_back
(operation);
130
push_back
(args...);
131
}
132
140
[[nodiscard]]
auto
specs
() const -> const std::vector<
core
::impl::
subdoc
::command>&;
141
142
private:
143
[[nodiscard]] auto bundle() ->
core
::impl::
subdoc
::command_bundle&;
144
145
std::shared_ptr<
core
::impl::
subdoc
::command_bundle> specs_{};
146
};
147
}
// namespace couchbase
couchbase::lookup_in_specs::push_back
void push_back(const Operation &operation)
Add subdocument operation to list of specs.
Definition
lookup_in_specs.hxx:110
couchbase::lookup_in_specs::push_back
void push_back(const Operation &operation, Rest... args)
Add subdocument operations to list of specs.
Definition
lookup_in_specs.hxx:127
couchbase::lookup_in_specs::specs
auto specs() const -> const std::vector< core::impl::subdoc::command > &
Returns internal representation of the specs.
couchbase::lookup_in_specs::lookup_in_specs
lookup_in_specs()=default
couchbase::lookup_in_specs::count
static auto count(std::string path) -> subdoc::count
Counts the number of values at a given path in the document.
Definition
lookup_in_specs.hxx:95
couchbase::lookup_in_specs::exists
static auto exists(std::string path) -> subdoc::exists
Checks if a value at the given path exists in the document.
Definition
lookup_in_specs.hxx:81
couchbase::lookup_in_specs::get
static auto get(subdoc::lookup_in_macro macro) -> subdoc::get
Fetches the content from a field represented by given virtual attribute (macro).
Definition
lookup_in_specs.hxx:67
couchbase::lookup_in_specs::get
static auto get(std::string path) -> subdoc::get
Fetches the content from a field (if present) at the given path.
Definition
lookup_in_specs.hxx:53
couchbase::lookup_in_specs::lookup_in_specs
lookup_in_specs(Operation... args)
Definition
lookup_in_specs.hxx:39
couchbase::subdoc::count
An intention to perform a SubDocument count operation.
Definition
count.hxx:39
couchbase::subdoc::exists
An intention to perform a SubDocument exists operation.
Definition
exists.hxx:39
couchbase::subdoc::get
An intention to perform a SubDocument get operation.
Definition
get.hxx:41
command.hxx
command_bundle.hxx
count.hxx
exists.hxx
get.hxx
json_transcoder.hxx
couchbase::core
Definition
expiry.hxx:24
couchbase::subdoc
Definition
array_add_unique.hxx:33
couchbase::subdoc::lookup_in_macro
lookup_in_macro
Definition
lookup_in_macro.hxx:29
couchbase
Represents a single item from the result of scan().
Definition
allow_querying_search_index_options.hxx:28
couchbase
lookup_in_specs.hxx
Generated by
1.17.0