MongoDB C++ Driver 4.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
index.hpp
Go to the documentation of this file.
1// Copyright 2009-present MongoDB, Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <chrono>
18#include <memory>
19
22
28
30
32
33namespace mongocxx {
34namespace v_noabi {
35namespace options {
36
43class index {
44 public:
45 BSONCXX_PRIVATE_WARNINGS_PUSH();
46 BSONCXX_PRIVATE_WARNINGS_DISABLE(MSVC(4251));
47 BSONCXX_PRIVATE_WARNINGS_DISABLE(MSVC(4275));
48
54 class MONGOCXX_ABI_EXPORT base_storage_options {
55 public:
56 virtual ~base_storage_options();
57
58 base_storage_options(base_storage_options&&) = default;
59 base_storage_options& operator=(base_storage_options&&) = default;
60 base_storage_options(base_storage_options const&) = default;
61 base_storage_options& operator=(base_storage_options const&) = default;
62
63 base_storage_options() = default;
64
65 private:
66 friend ::mongocxx::v_noabi::options::index;
67
68 virtual int type() const = 0;
69 };
70
76 class MONGOCXX_ABI_EXPORT wiredtiger_storage_options final : public base_storage_options {
77 public:
78 ~wiredtiger_storage_options() override;
79
80 wiredtiger_storage_options(wiredtiger_storage_options&&) = default;
81 wiredtiger_storage_options& operator=(wiredtiger_storage_options&&) = default;
82 wiredtiger_storage_options(wiredtiger_storage_options const&) = default;
83 wiredtiger_storage_options& operator=(wiredtiger_storage_options const&) = default;
84
85 wiredtiger_storage_options() = default;
86
94
101
102 private:
103 friend ::mongocxx::v_noabi::collection;
104
105 MONGOCXX_ABI_NO_EXPORT int type() const override;
106
108 };
109
110 BSONCXX_PRIVATE_WARNINGS_POP();
111
113
129
135 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bool> const&) background() const;
136
152
158 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bool> const&) unique() const;
159
175
181 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bool> const&) hidden() const;
182
194
200 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::string::view_or_value> const&)
201 name() const;
202
217
227 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view> const&)
228 collation() const;
229
245
251 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bool> const&) sparse() const;
252
268 std::unique_ptr<base_storage_options> storage_options);
269
282
301 storage_engine(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view> storage_engine);
302
306 BSONCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view> const&)
308
323 MONGOCXX_ABI_EXPORT_CDECL(index&) expire_after(std::chrono::seconds seconds);
324
330 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<std::chrono::seconds> const&)
332
343 MONGOCXX_ABI_EXPORT_CDECL(index&) version(std::int32_t v);
344
350 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<std::int32_t> const&)
351 version() const;
352
365
371 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view> const&)
372 weights() const;
373
387
393 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::string::view_or_value> const&)
395
409
415 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::string::view_or_value> const&)
417
430
436 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view> const&)
438
450
456 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<std::uint8_t> const&)
458
470
476 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<std::uint8_t> const&)
478
490
496 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<double> const&)
498
510
516 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<double> const&)
518
538 MONGOCXX_ABI_EXPORT_CDECL(index&) haystack_bucket_size_deprecated(double haystack_bucket_size);
539
548 MONGOCXX_DEPRECATED MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<double> const&)
550 MONGOCXX_ABI_EXPORT_CDECL(bsoncxx::v_noabi::stdx::optional<double> const&)
551 haystack_bucket_size_deprecated() const;
552
562
563 private:
564 friend ::mongocxx::v_noabi::collection;
565
566 bsoncxx::v_noabi::stdx::optional<bool> _background;
567 bsoncxx::v_noabi::stdx::optional<bool> _unique;
568 bsoncxx::v_noabi::stdx::optional<bool> _hidden;
569 bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::string::view_or_value> _name;
570 bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view> _collation;
571 bsoncxx::v_noabi::stdx::optional<bool> _sparse;
572 std::unique_ptr<base_storage_options> _storage_options;
573 bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view> _storage_engine;
574 bsoncxx::v_noabi::stdx::optional<std::chrono::seconds> _expire_after;
575 bsoncxx::v_noabi::stdx::optional<std::int32_t> _version;
576 bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view> _weights;
577 bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::string::view_or_value> _default_language;
578 bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::string::view_or_value> _language_override;
579 bsoncxx::v_noabi::stdx::optional<bsoncxx::v_noabi::document::view> _partial_filter_expression;
580 bsoncxx::v_noabi::stdx::optional<std::uint8_t> _twod_sphere_version;
581 bsoncxx::v_noabi::stdx::optional<std::uint8_t> _twod_bits_precision;
582 bsoncxx::v_noabi::stdx::optional<double> _twod_location_min;
583 bsoncxx::v_noabi::stdx::optional<double> _twod_location_max;
584 bsoncxx::v_noabi::stdx::optional<double> _haystack_bucket_size;
585
586 //
587 // Return the current storage_options setting.
588 //
589 std::unique_ptr<base_storage_options> const& storage_options() const;
590};
591
592} // namespace options
593} // namespace v_noabi
594} // namespace mongocxx
595
596#include <bsoncxx/config/postlude.hpp>
597
599
#define BSONCXX_ABI_EXPORT_CDECL(...)
Equivalent to BSONCXX_ABI_EXPORT with BSONCXX_ABI_CDECL.
Definition export.hpp:52
The bsoncxx v_noabi macro guard prelude header.
A polyfill for std::optional<T>.
Definition optional.hpp:800
A view-or-value variant type for strings.
Definition view_or_value.hpp:41
A MongoDB collection.
Definition collection.hpp:87
Base class representing the optional storage engine options for indexes.
Definition index.hpp:54
The optional WiredTiger storage engine options for indexes.
Definition index.hpp:76
void config_string(bsoncxx::v_noabi::string::view_or_value config_string)
Set the WiredTiger configuration string.
bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::string::view_or_value > const & config_string() const
The current config_string setting.
index & haystack_bucket_size(double haystack_bucket_size)
For geoHaystack indexes, specify the number of units within which to group the location values; i....
index & hidden(bool hidden)
Whether or not the index is hidden from the query planner. A hidden index is not evaluated as part of...
index & language_override(bsoncxx::v_noabi::string::view_or_value language_override)
For text indexes, the name of the field, in the collection’s documents, that contains the override la...
index & twod_location_max(double twod_location_max)
For 2d indexes, the upper inclusive boundary for the longitude and latitude values.
index & background(bool background)
Whether or not to build the index in the background so that building the index does not block other d...
index & expire_after(std::chrono::seconds seconds)
Set a value, in seconds, as a TTL to control how long MongoDB retains documents in this collection.
index & weights(bsoncxx::v_noabi::document::view weights)
For text indexes, sets the weight document. The weight document contains field and weight pairs.
index & unique(bool unique)
Whether or not to create a unique index so that the collection will not accept insertion of documents...
index & storage_options(std::unique_ptr< base_storage_options > storage_options)
Specifies the storage engine options for the index.
index & collation(bsoncxx::v_noabi::document::view collation)
Sets the collation for this index.
index & name(bsoncxx::v_noabi::string::view_or_value name)
The name of the index.
index & storage_engine(bsoncxx::v_noabi::stdx::optional< bsoncxx::v_noabi::document::view > storage_engine)
Specifies the storage engine options for the index.
index & version(std::int32_t v)
Sets the index version.
index & twod_location_min(double twod_location_min)
For 2d indexes, the lower inclusive boundary for the longitude and latitude values.
index & default_language(bsoncxx::v_noabi::string::view_or_value default_language)
For text indexes, the language that determines the list of stop words and the rules for the stemmer a...
index & twod_bits_precision(std::uint8_t twod_bits_precision)
For 2d indexes, the precision of the stored geohash value of the location data.
index & partial_filter_expression(bsoncxx::v_noabi::document::view partial_filter_expression)
Sets the document for the partial filter expression for partial indexes.
operator bsoncxx::v_noabi::document::view_or_value()
Conversion operator that provides a view of the options in document form.
index & twod_sphere_version(std::uint8_t twod_sphere_version)
For 2dsphere indexes, the 2dsphere index version number. Version can be either 1 or 2.
index & sparse(bool sparse)
Whether or not to create a sparse index. Sparse indexes only reference documents with the indexed fie...
Declares mongocxx::v_noabi::collection.
Provides bsoncxx::v_noabi::document::value.
Provides bsoncxx::v_noabi::document::view.
Provides bsoncxx::v_noabi::document::view_or_value.
Declares mongocxx::v_noabi::options::index.
#define MONGOCXX_DEPRECATED
Declares the associated entity as deprecated.
Definition export.hpp:25
#define MONGOCXX_ABI_NO_EXPORT
Excludes the associated entity from being part of the ABI.
Definition export.hpp:20
#define MONGOCXX_ABI_EXPORT_CDECL(...)
Equivalent to MONGOCXX_ABI_EXPORT with MONGOCXX_ABI_CDECL.
Definition export.hpp:52
#define MONGOCXX_ABI_EXPORT
Exports the associated entity as part of the ABI.
Definition export.hpp:15
The mongocxx v_noabi macro guard postlude header.
The mongocxx v_noabi macro guard prelude header.
The top-level namespace within which all bsoncxx library entities are declared.
Declares entities representing options to use with various commands.
Declares entities whose ABI stability is NOT guaranteed.
The top-level namespace within which all mongocxx library entities are declared.
Provides bsoncxx::v_noabi::string::view_or_value.
Provides std::optional-related polyfills for library API usage.