MongoDB C++ Driver 4.1.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
mongocxx::v_noabi::read_concern Class Reference

#include <mongocxx/v_noabi/mongocxx/read_concern.hpp>

Description

Controls the consistency and isolation properties of data read from replica sets and sharded clusters.

Read concern can be set at the client, database, or collection level. The read concern can also be provided via connection string, and will be parsed and set on the client constructed for the URI.

See also

Public Types

enum class  level
 A class to represent the read concern level for read operations. More...
 

Public Member Functions

 read_concern ()
 Constructs a new read_concern with default acknowledge_level of k_server_default.
 
 read_concern (read_concern &&) noexcept
 Move constructs a read_concern.
 
 read_concern (read_concern const &)
 Copy constructs a read_concern.
 
 ~read_concern ()
 Destroys a read_concern.
 
level acknowledge_level () const
 Gets the current read concern level.
 
void acknowledge_level (level rc_level)
 Sets the read concern level.
 
bsoncxx::v_noabi::stdx::string_view acknowledge_string () const
 Gets the current read concern string.
 
void acknowledge_string (bsoncxx::v_noabi::stdx::string_view rc_string)
 Sets the read concern string. Any valid read concern string (e.g. "local", "majority", "linearizable", "") may be passed in. For forward-compatibility with read concern levels introduced in the future, no validation is performed on this string.
 
read_concernoperator= (read_concern &&) noexcept
 Move assigns a read_concern.
 
read_concernoperator= (read_concern const &)
 Copy assigns a read_concern.
 
bsoncxx::v_noabi::document::value to_document () const
 Gets the document form of this read_concern.
 

Related Symbols

(Note that these are not member symbols.)

bool operator== (read_concern const &, read_concern const &)
 Compares two read_concern objects for (in)-equality.
 
bool operator!= (read_concern const &, read_concern const &)
 Compares two read_concern objects for (in)-equality.
 

Member Enumeration Documentation

◆ level

A class to represent the read concern level for read operations.

See also
Enumerator
k_local 

Represent read concern level "local".

k_majority 

Represent read concern level "majority".

k_linearizable 

Represent read concern level "linearizable".

k_server_default 

Represent the server's default read concern level.

k_unknown 

Represent an unknown read concern level.

k_available 

Represent read concern level "available".

k_snapshot 

Represent read concern level "snapshot".

Constructor & Destructor Documentation

◆ read_concern() [1/3]

mongocxx::v_noabi::read_concern::read_concern ( )

Constructs a new read_concern with default acknowledge_level of k_server_default.

The k_server_default acknowledge level has an empty acknowledge_string. Queries that run with this read_concern will use the server's default read_concern instead of specifying one.

◆ read_concern() [2/3]

mongocxx::v_noabi::read_concern::read_concern ( read_concern const & )

Copy constructs a read_concern.

◆ read_concern() [3/3]

mongocxx::v_noabi::read_concern::read_concern ( read_concern && )
noexcept

Move constructs a read_concern.

◆ ~read_concern()

mongocxx::v_noabi::read_concern::~read_concern ( )

Destroys a read_concern.

Member Function Documentation

◆ acknowledge_level() [1/2]

level mongocxx::v_noabi::read_concern::acknowledge_level ( ) const

Gets the current read concern level.

If this was set with acknowledge_string to anything other than "local", "majority", "linearizable", or an empty string, this will return k_unknown.

Returns
The read concern level.

◆ acknowledge_level() [2/2]

void mongocxx::v_noabi::read_concern::acknowledge_level ( level rc_level)

Sets the read concern level.

Parameters
rc_levelEither k_local, k_majority, k_linearizable, or k_server_default.
Exceptions
mongocxx::v_noabi::exceptionif rc_level is not k_local, k_majority, k_linearizable, or k_server_default.

◆ acknowledge_string() [1/2]

bsoncxx::v_noabi::stdx::string_view mongocxx::v_noabi::read_concern::acknowledge_string ( ) const

Gets the current read concern string.

If the read concern level was set with acknowledge_level, this will return either "local", "majority", "linearizable", or an empty string for k_server_default.

Returns
The read concern string.

◆ acknowledge_string() [2/2]

void mongocxx::v_noabi::read_concern::acknowledge_string ( bsoncxx::v_noabi::stdx::string_view rc_string)

Sets the read concern string. Any valid read concern string (e.g. "local", "majority", "linearizable", "") may be passed in. For forward-compatibility with read concern levels introduced in the future, no validation is performed on this string.

Parameters
rc_stringThe read concern string.

◆ operator=() [1/2]

read_concern & mongocxx::v_noabi::read_concern::operator= ( read_concern && )
noexcept

Move assigns a read_concern.

◆ operator=() [2/2]

read_concern & mongocxx::v_noabi::read_concern::operator= ( read_concern const & )

Copy assigns a read_concern.

◆ to_document()

bsoncxx::v_noabi::document::value mongocxx::v_noabi::read_concern::to_document ( ) const

Gets the document form of this read_concern.

Returns
Document representation of this read_concern.

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( read_concern const & ,
read_concern const &  )
friend

Compares two read_concern objects for (in)-equality.

◆ operator==

bool operator== ( read_concern const & ,
read_concern const &  )
friend

Compares two read_concern objects for (in)-equality.


The documentation for this class was generated from the following file: