Couchbase C++ SDK 1.0.4 (rev. 5355b0f)
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
22
27
28#include <memory>
29#include <vector>
30
31namespace couchbase
32{
34{
35public:
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
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
142private:
143 [[nodiscard]] auto bundle() -> core::impl::subdoc::command_bundle&;
144
145 std::shared_ptr<core::impl::subdoc::command_bundle> specs_{};
146};
147} // namespace couchbase
Definition lookup_in_specs.hxx:34
void push_back(const Operation &operation)
Add subdocument operation to list of specs.
Definition lookup_in_specs.hxx:110
void push_back(const Operation &operation, Rest... args)
Add subdocument operations to list of specs.
Definition lookup_in_specs.hxx:127
auto specs() const -> const std::vector< core::impl::subdoc::command > &
Returns internal representation of the specs.
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
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
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
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
lookup_in_specs(Operation... args)
Definition lookup_in_specs.hxx:39
An intention to perform a SubDocument count operation.
Definition count.hxx:39
An intention to perform a SubDocument exists operation.
Definition exists.hxx:39
An intention to perform a SubDocument get operation.
Definition get.hxx:41
lookup_in_macro
Definition lookup_in_macro.hxx:29
Represents a single item from the result of collection::scan()
Definition allow_querying_search_index_options.hxx:28