MongoDB C++ Driver
legacy-1.0.3
|
the main MongoDB namespace More...
Namespaces | |
client | |
the MongoDB C++ driver namespace | |
Classes | |
class | _BufBuilder |
class | AbstractMessagingPort |
class | AssertionException |
class | BackgroundJob |
Background thread dispatching. More... | |
class | Backoff |
struct | BSONArray |
class | BSONArrayBuilder |
class | BSONArrayIteratorSorted |
Provides iteration of a BSONArray's BSONElements in numeric field order. More... | |
struct | BSONBinData |
struct | BSONCode |
struct | BSONCodeWScope |
struct | BSONDBRef |
class | BSONElement |
BSONElement represents an "element" in a BSONObj. More... | |
struct | BSONElementCmpWithoutField |
class | BSONField |
class | BSONFieldValue |
A BSONField holds the name and the type intended for a given BSON element. More... | |
class | BSONIteratorSorted |
Base class implementing ordered iteration through BSONElements. More... | |
class | BSONObj |
C++ representation of a "BSON" object – that is, an extended JSON-style object in a binary representation. More... | |
class | BSONObjBuilder |
Utility for creating a BSONObj. More... | |
class | BSONObjBuilderValueStream |
class | BSONObjCmp |
class | BSONObjIterator |
iterator for a BSONObj More... | |
class | BSONObjIteratorSorted |
Provides iteration of a BSONObj's BSONElements in lexical field order. More... | |
struct | BSONRegEx |
class | BSONSizeTracker |
used in conjuction with BSONObjBuilder, allows for proper buffer size to prevent crazy memory usage More... | |
struct | BSONSymbol |
class | BulkOperationBuilder |
Class for constructing and executing bulk operations against MongoDB via a fluent API. More... | |
class | BulkUpdateBuilder |
Class for constructing bulk write operations which have an applied filter. More... | |
class | BulkUpsertBuilder |
Class for constructing bulk write operations which have an applied filter and are to be performed as an upsert. More... | |
class | CommandWriter |
class | ConnectException |
class | ConnectionCache |
class | ConnectionString |
ConnectionString can parse MongoDB URIs with the following format: More... | |
class | CyrusSaslClientSession |
Implementation of the client side of a SASL authentication conversation. More... | |
struct | Date_t |
struct | DateNowLabeler |
class | DBClientBase |
abstract class that implements the core db operations More... | |
class | DBClientConnection |
A basic connection to the database. More... | |
class | DBClientCursor |
Queries return a cursor object. More... | |
class | DBClientCursorBatchIterator |
iterate over objects in current batch only - will not cause a network call More... | |
class | DBClientCursorInterface |
for mock purposes only – do not create variants of DBClientCursor, nor hang code here More... | |
class | DBClientCursorShim |
DBClientCursorShim provides an abstract interface for providing polymorphic cursors. More... | |
class | DBClientCursorShimArray |
DBClientCursorShimArray implements the shim interface over an array of bson obj's. More... | |
class | DBClientCursorShimCursorID |
DBClientCursorShimCursorID implements the shim interface over a cursor reply document, rather than the traditional OP_REPLY. More... | |
class | DBClientCursorShimTransform |
DBClientCursorShimTransform implements the shim interface over a cursor reply document by allowing a transformation to be applied. More... | |
class | DBClientInterface |
The interface that any db connection should implement. More... | |
class | DBClientMockCursor |
class | DBClientReplicaSet |
Use this class to connect to a replica set of servers. More... | |
class | DBClientWithCommands |
DB "commands" Basically just invocations of connection. More... | |
class | DBClientWriter |
class | DBConnector |
interface that handles communication with the db More... | |
class | DBException |
Most mongo exceptions inherit from this; this is commonly caught in most threads. More... | |
class | DeleteWriteOperation |
class | EmbeddedBuilder |
class | ErrorMsg |
helper class that builds error strings. More... | |
struct | ExceptionInfo |
class | FailPoint |
A simple thread-safe fail point implementation that can be activated and deactivated, as well as embed temporary data into it. More... | |
class | FailPointRegistry |
Class for storing FailPoint instances. More... | |
struct | GENOIDLabeler |
class | GridFile |
wrapper for a file stored in the Mongo database More... | |
class | GridFileBuilder |
class which allow to build GridFiles in a stream fashion way More... | |
class | GridFS |
GridFS is for storing large file-style objects in MongoDB. More... | |
class | GridFSChunk |
struct | HostAndPort |
Name of a process on the network. More... | |
class | IndexSpec |
class | InsertWriteOperation |
class | JParse |
Parser class. More... | |
class | Labeler |
class | LexNumCmp |
Functor for combining lexical and numeric comparisons. More... | |
struct | MaxKeyLabeler |
class | Message |
class | MessagingPort |
struct | MinKeyLabeler |
class | MsgAssertionException |
class | NativeSaslClientSession |
Implementation of the client side of a SASL authentication conversation using the native SASL implementation. More... | |
class | Notification |
class | NotifyAll |
establishes a synchronization point between threads. More... | |
struct | NullLabeler |
class | ObjScopeGuardImpl0 |
class | ObjScopeGuardImpl1 |
class | ObjScopeGuardImpl2 |
class | OID |
Object ID type. More... | |
class | OperationException |
General runtime exception generated by the MongoDB client driver. More... | |
class | Ordering |
A precomputation of a BSON index or sort key pattern. More... | |
class | Query |
Represents a Mongo query expression. More... | |
class | QuerySpec |
Represents a full query description, including all options required for the query to be passed on to other hosts. More... | |
struct | ReadPreferenceSetting |
class | RefToValue |
Transports a reference as a value Serves to implement the Colvin/Gibbons trick for SmartPtr/ScopeGuard. More... | |
class | ReplicaSetMonitor |
Holds state about a replica set and provides a means to refresh the local view. More... | |
class | SaslClientConversation |
Abstract class for implementing the clent-side of a SASL mechanism conversation. More... | |
class | SaslClientSession |
Base class for the client side of a SASL authentication conversation. More... | |
class | SaslPLAINClientConversation |
Client side authentication session for SASL PLAIN. More... | |
class | SaslSCRAMSHA1ClientConversation |
Client side authentication session for SASL PLAIN. More... | |
class | ScopedFailPoint |
Helper class for making sure that FailPoint::shouldFailCloseBlock is called when FailPoint::shouldFailOpenBlock was called. More... | |
class | ScopeGuardImpl0 |
class | ScopeGuardImpl1 |
class | ScopeGuardImpl2 |
class | ScopeGuardImpl3 |
class | ScopeGuardImplBase |
ScopeGuard. More... | |
class | SharedBuffer |
struct | SockAddr |
wrapped around os representation of network address More... | |
class | Socket |
thin wrapped around file descriptor and system calls todo: ssl More... | |
class | SocketException |
thrown by Socket and SockAddr More... | |
class | StackAllocator |
class | StackBufBuilder |
The StackBufBuilder builds smaller datasets on the stack instead of using malloc. More... | |
class | StatusWith |
class | StringBuilderImpl |
std::stringstream deals with locale so this is a lot faster than std::stringstream for UTF8 More... | |
class | StringMap |
struct | StringMapDefaultConvertor |
struct | StringMapDefaultConvertorOther |
struct | StringMapDefaultEqual |
class | StringSplitter |
class | TagSet |
A simple object for representing the list of tags requested by a $readPreference. More... | |
class | ThreadLocalValue |
class | Timer |
Time tracking object. More... | |
class | Timestamp_t |
class | TrivialAllocator |
struct | TSP |
struct | UndefinedLabeler |
class | UnorderedFastKeyTable |
struct | UnorderedFastKeyTable_LS_C |
class | UpdateWriteOperation |
class | UserException |
class | WireProtocolWriter |
class | WriteConcern |
Class to encapsulate client side "Write Concern" concept. More... | |
class | WriteOperation |
Represents a single server side write operation and encapsulates the process for encoding the operation into either a wire protocol request message or a command. More... | |
class | WriteOperationBase |
class | WriteResult |
Class representing the result of a write operations sent to the server. More... | |
Typedefs | |
typedef const ScopeGuardImplBase & | ScopeGuard |
See Andrei's and Petru Marginean's CUJ article http://www.cuj.com/documents/s=8000/cujcexp1812alexandr/alexandr.htm. More... | |
Enumerations | |
enum | UpdateOptions { UpdateOption_Upsert = 1 << 0, UpdateOption_Multi = 1 << 1, UpdateOption_Broadcast = 1 << 2 } |
enum | RemoveOptions { RemoveOption_JustOne = 1 << 0, RemoveOption_Broadcast = 1 << 1 } |
enum | InsertOptions { InsertOption_ContinueOnError = 1 << 0 } |
need to put in DbMesssage::ReservedOptions as well More... | |
enum | BSONType { MinKey =-1, EOO =0, NumberDouble =1, String =2, Object =3, Array =4, BinData =5, Undefined =6, jstOID =7, Bool =8, Date =9, jstNULL =10, RegEx =11, DBRef =12, Code =13, Symbol =14, CodeWScope =15, NumberInt = 16, Timestamp = 17, NumberLong = 18, JSTypeMax =18, MaxKey =127 } |
the complete list of valid BSON types see also bsonspec.org More... | |
enum | JsonStringFormat { Strict, TenGen, JS } |
Formatting mode for generating JSON from BSON. More... | |
Functions | |
MONGO_CLIENT_API std::string MONGO_CLIENT_FUNC | nsGetDB (const std::string &ns) |
MONGO_CLIENT_API std::string MONGO_CLIENT_FUNC | nsGetCollection (const std::string &ns) |
MONGO_CLIENT_API bool MONGO_CLIENT_FUNC | serverAlive (const std::string &uri) |
pings server to check if it's up | |
MONGO_CLIENT_API | Status (MONGO_CLIENT_FUNC *saslClientAuthenticate)(DBClientWithCommands *client |
Attempts to authenticate "client" using the SASL protocol. More... | |
MONGO_CLIENT_API Status MONGO_CLIENT_FUNC | saslExtractPayload (const BSONObj &cmdObj, std::string *payload, BSONType *type) |
Extracts the payload field from "cmdObj", and store it into "*payload". More... | |
MONGO_CLIENT_API BSONObj MONGO_CLIENT_FUNC | fromjson (const std::string &str) |
Create a BSONObj from a JSON http://www.json.org, http://www.ietf.org/rfc/rfc4627.txt string. More... | |
MONGO_CLIENT_API BSONObj MONGO_CLIENT_FUNC | fromjson (const char *str, int *len=NULL) |
MONGO_CLIENT_API bool | isArray (const StringData &str) |
Tests whether the JSON string is an Array. More... | |
MONGO_CLIENT_API std::string | tojson (const BSONArray &arr, JsonStringFormat format=Strict, bool pretty=false) |
Convert a BSONArray to a JSON string. More... | |
MONGO_CLIENT_API std::string | tojson (const BSONObj &obj, JsonStringFormat format=Strict, bool pretty=false) |
Convert a BSONObj to a JSON string. More... | |
Status | validateBSON (const char *buf, uint64_t maxLength) |
const char * | typeName (BSONType type) |
returns the name of the argument's type | |
int | canonicalizeBSONType (BSONType type) |
Returns a number for where a given type falls in the sort order. More... | |
Status | bsonExtractField (const BSONObj &object, const StringData &fieldName, BSONElement *outElement) |
Finds an element named "fieldName" in "object". More... | |
Status | bsonExtractTypedField (const BSONObj &object, const StringData &fieldName, BSONType type, BSONElement *outElement) |
Finds an element named "fieldName" in "object". More... | |
Status | bsonExtractBooleanField (const BSONObj &object, const StringData &fieldName, bool *out) |
Finds a bool-like element named "fieldName" in "object". More... | |
Status | bsonExtractIntegerField (const BSONObj &object, const StringData &fieldName, long long *out) |
Finds an element named "fieldName" in "object" that represents an integral value. More... | |
Status | bsonExtractStringField (const BSONObj &object, const StringData &fieldName, std::string *out) |
Finds a string-typed element named "fieldName" in "object" and stores its value in "out". More... | |
Status | bsonExtractOIDField (const BSONObj &object, const StringData &fieldName, OID *out) |
Finds an OID-typed element named "fieldName" in "object" and stores its value in "out". More... | |
Status | bsonExtractBooleanFieldWithDefault (const BSONObj &object, const StringData &fieldName, bool defaultValue, bool *out) |
Finds a bool-like element named "fieldName" in "object". More... | |
Status | bsonExtractIntegerFieldWithDefault (const BSONObj &object, const StringData &fieldName, long long defaultValue, long long *out) |
Finds an element named "fieldName" in "object" that represents an integral value. More... | |
Status | bsonExtractStringFieldWithDefault (const BSONObj &object, const StringData &fieldName, const StringData &defaultValue, std::string *out) |
Finds a string element named "fieldName" in "object". More... | |
Status | bsonExtractOIDFieldWithDefault (const BSONObj &object, const StringData &fieldName, const OID &defaultValue, OID *out) |
Finds an OID-typed element named "fieldName" in "object" and stores its value in *out. More... | |
MONGO_CLIENT_API MONGO_COMPILER_NORETURN void MONGO_CLIENT_FUNC | uasserted (int msgid, const char *msg) |
a "user assertion". More... | |
MONGO_CLIENT_API MONGO_COMPILER_NORETURN void MONGO_CLIENT_FUNC | msgassertedNoTrace (int msgid, const char *msg) |
msgassert and massert are for errors that are internal but have a well defined error text std::string. More... | |
MONGO_CLIENT_API void MONGO_CLIENT_FUNC | fassert (int msgid, bool testOK) |
aborts on condition failure | |
FailPointRegistry * | getGlobalFailPointRegistry () |
std::string | errnoWithPrefix (const char *prefix) |
output the error # and error message with prefix. More... | |
void | logContext (const char *msg=NULL) |
Write the optional "msg". | |
std::string | getHostName () |
this is not cache and does a syscall | |
std::string | createPasswordDigest (const StringData &username, const StringData &clearTextPassword) |
Hashes the password so that it can be stored in a user object or used for MONGODB-CR authentication. | |
template<class T > | |
RefToValue< T > | ByRef (T &t) |
RefToValue creator. | |
std::string | constructUtf8WindowsCommandLine (const std::vector< std::string > &argv) |
Construct a Windows command line string, UTF-8 encoded, from a vector of UTF-8 arguments, "argv". More... | |
MONGO_CLIENT_API std::string MONGO_CLIENT_FUNC | timeToISOString (time_t time) |
Formats "time" according to the ISO 8601 extended form standard, including date, and time, in the UTC timezone. More... | |
MONGO_CLIENT_API std::string MONGO_CLIENT_FUNC | dateToISOStringUTC (Date_t date) |
Formats "date" according to the ISO 8601 extended form standard, including date, and time with milliseconds decimal component, in the UTC timezone. More... | |
MONGO_CLIENT_API std::string MONGO_CLIENT_FUNC | dateToISOStringLocal (Date_t date) |
Formats "date" according to the ISO 8601 extended form standard, including date, and time with milliseconds decimal component, in the local timezone. More... | |
MONGO_CLIENT_API std::string MONGO_CLIENT_FUNC | dateToCtimeString (Date_t date) |
Formats "date" in fixed width in the local time zone. More... | |
MONGO_CLIENT_API StatusWith< Date_t > MONGO_CLIENT_FUNC | dateFromISOString (const StringData &dateString) |
Parses a Date_t from an ISO 8601 string representation. More... | |
MONGO_CLIENT_API void MONGO_CLIENT_FUNC | outputDateAsISOStringUTC (std::ostream &os, Date_t date) |
Like dateToISOStringUTC, except outputs to a std::ostream. | |
MONGO_CLIENT_API void MONGO_CLIENT_FUNC | outputDateAsISOStringLocal (std::ostream &os, Date_t date) |
Like dateToISOStringLocal, except outputs to a std::ostream. | |
MONGO_CLIENT_API void MONGO_CLIENT_FUNC | outputDateAsCtime (std::ostream &os, Date_t date) |
Like dateToCtimeString, except outputs to a std::ostream. | |
MONGO_CLIENT_API Date_t MONGO_CLIENT_FUNC | jsTime () |
Date_t is milliseconds since epoch. | |
unsigned | curTimeMicros () |
warning this will wrap | |
Variables | |
MONGO_CLIENT_API const char *const | saslStartCommandName |
String name of the saslStart command. | |
MONGO_CLIENT_API const char *const | saslContinueCommandName |
String name of the saslContinue command. | |
MONGO_CLIENT_API const char *const | saslCommandAutoAuthorizeFieldName |
Name of the saslStart parameter indicating that the server should automatically grant the connection all privileges associated with the user after successful authentication. More... | |
MONGO_CLIENT_API const char *const | saslCommandCodeFieldName |
Name of the field contain the status code in responses from the server. | |
MONGO_CLIENT_API const char *const | saslCommandConversationIdFieldName |
Name of the field containing the conversation identifier in server respones and saslContinue commands. More... | |
MONGO_CLIENT_API const char *const | saslCommandDoneFieldName |
Name of the field that indicates whether or not the server believes authentication has completed successfully. More... | |
MONGO_CLIENT_API const char *const | saslCommandErrmsgFieldName |
Field in which to store error messages associated with non-success return codes. | |
MONGO_CLIENT_API const char *const | saslCommandMechanismFieldName |
Name of parameter to saslStart command indiciating the client's desired sasl mechanism. | |
MONGO_CLIENT_API const char *const | saslCommandMechanismListFieldName |
In the event that saslStart supplies an unsupported mechanism, the server responds with a field by this name, with a list of supported mechanisms. More... | |
MONGO_CLIENT_API const char *const | saslCommandPasswordFieldName |
Field containing password information for saslClientAuthenticate(). | |
MONGO_CLIENT_API const char *const | saslCommandPayloadFieldName |
Field containing sasl payloads passed to and from the server. | |
MONGO_CLIENT_API const char *const | saslCommandUserFieldName |
Field containing the string identifier of the user to authenticate in saslClientAuthenticate(). More... | |
MONGO_CLIENT_API const char *const | saslCommandUserDBFieldName |
Field containing the string identifier of the database containing credential information, or "$external" if the credential information is stored outside of the mongo cluster. More... | |
MONGO_CLIENT_API const char *const | saslCommandServiceHostnameFieldName |
Field overriding the FQDN of the hostname hosting the mongodb srevice in saslClientAuthenticate(). More... | |
MONGO_CLIENT_API const char *const | saslCommandServiceNameFieldName |
Field overriding the name of the mongodb service saslClientAuthenticate(). | |
MONGO_CLIENT_API const char *const | saslDefaultDBName |
Default database against which sasl authentication commands should run. | |
MONGO_CLIENT_API const char *const | saslDefaultServiceName |
Default sasl service name, "mongodb". | |
const size_t | MaxMessageSizeBytes = 48 * 1000 * 1000 |
Maximum accepted message size on the wire protocol. | |
the main MongoDB namespace
Copyright (C) 2014 MongoDB Inc.
Copyright 2012 10gen Inc.
Should NOT be included by other header files.
This is an internal header.
This should only be included by replica_set_monitor.cpp and replica_set_monitor_test.cpp. This should never be included by any header.
Include only in source files.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
typedef const ScopeGuardImplBase & mongo::ScopeGuard |
See Andrei's and Petru Marginean's CUJ article http://www.cuj.com/documents/s=8000/cujcexp1812alexandr/alexandr.htm.
Changes to the original code by Joshua Lehrer: http://www.lehrerfamily.com/scopeguard.html
enum mongo::BSONType |
the complete list of valid BSON types see also bsonspec.org
enum mongo::InsertOptions |
Formatting mode for generating JSON from BSON.
See http://dochub.mongodb.org/core/mongodbextendedjson for details.
enum mongo::RemoveOptions |
enum mongo::UpdateOptions |
Status mongo::bsonExtractBooleanField | ( | const BSONObj & | object, |
const StringData & | fieldName, | ||
bool * | out | ||
) |
Finds a bool-like element named "fieldName" in "object".
Returns Status::OK() and sets *out to the found element's boolean value on success. Returns ErrorCodes::NoSuchKey if there are no matches for "fieldName", and ErrorCodes::TypeMismatch if the type of the matching element is not Bool or a number type. For return values other than Status::OK(), the resulting value of "*out" is undefined.
Status mongo::bsonExtractBooleanFieldWithDefault | ( | const BSONObj & | object, |
const StringData & | fieldName, | ||
bool | defaultValue, | ||
bool * | out | ||
) |
Finds a bool-like element named "fieldName" in "object".
If a field named "fieldName" is present, and is either a number or boolean type, stores the truth value of the field into "*out". If no field named "fieldName" is present, sets "*out" to "defaultValue". In these cases, returns Status::OK().
If "fieldName" is present more than once, behavior is undefined. If the found field is not a boolean or number, returns ErrorCodes::TypeMismatch.
Status mongo::bsonExtractField | ( | const BSONObj & | object, |
const StringData & | fieldName, | ||
BSONElement * | outElement | ||
) |
Finds an element named "fieldName" in "object".
Returns Status::OK() and sets "*outElement" to the found element on success. Returns ErrorCodes::NoSuchKey if there are no matches.
Status mongo::bsonExtractIntegerField | ( | const BSONObj & | object, |
const StringData & | fieldName, | ||
long long * | out | ||
) |
Finds an element named "fieldName" in "object" that represents an integral value.
Returns Status::OK() and sets *out to the element's 64-bit integer value representation on success. Returns ErrorCodes::NoSuchKey if there are no matches for "fieldName". Returns ErrorCodes::TypeMismatch if the value of the matching element is not of a numeric type. Returns ErrorCodes::BadValue if the value does not have an exact 64-bit integer representation. For return values other than Status::OK(), the resulting value of "*out" is undefined.
Status mongo::bsonExtractIntegerFieldWithDefault | ( | const BSONObj & | object, |
const StringData & | fieldName, | ||
long long | defaultValue, | ||
long long * | out | ||
) |
Finds an element named "fieldName" in "object" that represents an integral value.
If a field named "fieldName" is present and is a value of numeric type with an exact 64-bit integer representation, returns that representation in *out and returns Status::OK(). If there is no field named "fieldName", stores defaultValue into *out and returns Status::OK(). If the field is found, but has non-numeric type, returns ErrorCodes::TypeMismatch. If the value has numeric type, but cannot be represented as a 64-bit integer, returns ErrorCodes::BadValue.
Status mongo::bsonExtractOIDField | ( | const BSONObj & | object, |
const StringData & | fieldName, | ||
OID * | out | ||
) |
Finds an OID-typed element named "fieldName" in "object" and stores its value in "out".
Returns Status::OK() and sets *out to the found element's OID value on success. Returns ErrorCodes::NoSuchKey if there are no matches for "fieldName", and ErrorCodes::TypeMismatch if the type of the matching element is not OID. For return values other than Status::OK(), the resulting value of "*out" is undefined.
Status mongo::bsonExtractOIDFieldWithDefault | ( | const BSONObj & | object, |
const StringData & | fieldName, | ||
const OID & | defaultValue, | ||
OID * | out | ||
) |
Finds an OID-typed element named "fieldName" in "object" and stores its value in *out.
Returns Status::OK() and sets *out to the found element's OID value on success. If no field named "fieldName" is present, *out is set to "defaultValue" and Status::OK() is returned. Returns ErrorCodes::TypeMismatch if the type of the matching element is not OID. For return values other than Status::OK(), the resulting value of *out is undefined.
Status mongo::bsonExtractStringField | ( | const BSONObj & | object, |
const StringData & | fieldName, | ||
std::string * | out | ||
) |
Finds a string-typed element named "fieldName" in "object" and stores its value in "out".
Returns Status::OK() and sets *out to the found element's string value on success. Returns ErrorCodes::NoSuchKey if there are no matches for "fieldName", and ErrorCodes::TypeMismatch if the type of the matching element is not String. For return values other than Status::OK(), the resulting value of "*out" is undefined.
Status mongo::bsonExtractStringFieldWithDefault | ( | const BSONObj & | object, |
const StringData & | fieldName, | ||
const StringData & | defaultValue, | ||
std::string * | out | ||
) |
Finds a string element named "fieldName" in "object".
If a field named "fieldName" is present, and is a string, stores the value of the field into "*out". If no field named fieldName is present, sets "*out" to "defaultValue". In these cases, returns Status::OK().
If "fieldName" is present more than once, behavior is undefined. If the found field is not a string, returns ErrorCodes::TypeMismatch.
Status mongo::bsonExtractTypedField | ( | const BSONObj & | object, |
const StringData & | fieldName, | ||
BSONType | type, | ||
BSONElement * | outElement | ||
) |
Finds an element named "fieldName" in "object".
Returns Status::OK() and sets *outElement to the found element on success. Returns ErrorCodes::NoSuchKey if there are no matches for "fieldName", and ErrorCodes::TypeMismatch if the type of the matching element is not "type". For return values other than Status::OK(), the resulting value of "*outElement" is undefined.
|
inline |
Returns a number for where a given type falls in the sort order.
Elements with the same return value should be compared for value equality. The return value is not a BSONType and should not be treated as one. Note: if the order changes, indexes have to be re-built or than can be corruption
std::string mongo::constructUtf8WindowsCommandLine | ( | const std::vector< std::string > & | argv | ) |
Construct a Windows command line string, UTF-8 encoded, from a vector of UTF-8 arguments, "argv".
See "Parsing C++ Command-Line Arguments (C++)" http://msdn.microsoft.com/en-us/library/windows/desktop/17w5ykft(v=vs.85).aspx
MONGO_CLIENT_API StatusWith<Date_t> MONGO_CLIENT_FUNC mongo::dateFromISOString | ( | const StringData & | dateString | ) |
Parses a Date_t from an ISO 8601 string representation.
Sample formats: "2013-07-23T18:42:14.072-05:00" "2013-07-23T18:42:14.072Z"
Local times are currently not supported.
MONGO_CLIENT_API std::string MONGO_CLIENT_FUNC mongo::dateToCtimeString | ( | Date_t | date | ) |
Formats "date" in fixed width in the local time zone.
Sample format: "Wed Oct 31 13:34:47.996"
MONGO_CLIENT_API std::string MONGO_CLIENT_FUNC mongo::dateToISOStringLocal | ( | Date_t | date | ) |
Formats "date" according to the ISO 8601 extended form standard, including date, and time with milliseconds decimal component, in the local timezone.
Sample format: "2013-07-23T18:42:14.072-05:00"
MONGO_CLIENT_API std::string MONGO_CLIENT_FUNC mongo::dateToISOStringUTC | ( | Date_t | date | ) |
Formats "date" according to the ISO 8601 extended form standard, including date, and time with milliseconds decimal component, in the UTC timezone.
Sample format: "2013-07-23T18:42:14.072Z"
std::string mongo::errnoWithPrefix | ( | const char * | prefix | ) |
output the error # and error message with prefix.
handy for use as parm in uassert/massert.
MONGO_CLIENT_API BSONObj MONGO_CLIENT_FUNC mongo::fromjson | ( | const std::string & | str | ) |
Create a BSONObj from a JSON http://www.json.org, http://www.ietf.org/rfc/rfc4627.txt string.
In addition to the JSON extensions extensions described here http://dochub.mongodb.org/core/mongodbextendedjson, this function accepts unquoted field names and allows single quotes to optionally be used when specifying field names and string values instead of double quotes. JSON unicode escape sequences (of the form ) are converted to utf8.
MsgAssertionException | if parsing fails. The message included with this assertion includes the character offset where parsing failed. |
MONGO_CLIENT_API BSONObj MONGO_CLIENT_FUNC mongo::fromjson | ( | const char * | str, |
int * | len = NULL |
||
) |
len | will be size of JSON object in text chars. |
FailPointRegistry* mongo::getGlobalFailPointRegistry | ( | ) |
MONGO_CLIENT_API bool mongo::isArray | ( | const StringData & | str | ) |
Tests whether the JSON string is an Array.
Useful for assigning the result of fromjson to the right object type. Either: BSONObj BSONArray
Example: Using the method to select the proper type.
If this method returns true, the user could store the result of fromjson inside a BSONArray, rather than a BSONObj, in order to have it print as an array when passed to tojson.
obj | The JSON string to test. |
MONGO_CLIENT_API MONGO_COMPILER_NORETURN void MONGO_CLIENT_FUNC mongo::msgassertedNoTrace | ( | int | msgid, |
const char * | msg | ||
) |
msgassert and massert are for errors that are internal but have a well defined error text std::string.
a stack trace is logged.
MONGO_CLIENT_API std::string MONGO_CLIENT_FUNC mongo::nsGetCollection | ( | const std::string & | ns | ) |
MONGO_CLIENT_API std::string MONGO_CLIENT_FUNC mongo::nsGetDB | ( | const std::string & | ns | ) |
MONGO_CLIENT_API Status MONGO_CLIENT_FUNC mongo::saslExtractPayload | ( | const BSONObj & | cmdObj, |
std::string * | payload, | ||
BSONType * | type | ||
) |
Extracts the payload field from "cmdObj", and store it into "*payload".
Sets "*type" to the BSONType of the payload field in cmdObj.
If the type of the payload field is String, the contents base64 decodes and stores into "*payload". If the type is BinData, the contents are stored directly into "*payload". In all other cases, returns
MONGO_CLIENT_API mongo::Status | ( | MONGO_CLIENT_FUNC * | saslClientAuthenticate | ) |
Attempts to authenticate "client" using the SASL protocol.
Do not use directly in client code. Use the DBClientWithCommands::auth(const BSONObj&) method, instead.
Test against NULL for availability. Client driver must be compiled with SASL support and client application must have successfully executed mongo::runGlobalInitializersOrDie() or its ilk to make this functionality available.
The "saslParameters" BSONObj should be initialized with zero or more of the fields below. Which fields are required depends on the mechanism. Consult the relevant IETF standards.
"mechanism": The string name of the sasl mechanism to use. Mandatory. "autoAuthorize": Truthy values tell the server to automatically acquire privileges on all resources after successful authentication, which is the default. Falsey values instruct the server to await separate privilege-acquisition commands. "user": The string name of the user to authenticate. "db": The database target of the auth command, which identifies the location of the credential information for the user. May be "$external" if credential information is stored outside of the mongo cluster. "pwd": The password. "serviceName": The GSSAPI service name to use. Defaults to "mongodb". "serviceHostname": The GSSAPI hostname to use. Defaults to the name of the remote host.
Other fields in saslParameters are silently ignored.
Returns an OK status on success, and ErrorCodes::AuthenticationFailed if authentication is rejected. Other failures, all of which are tantamount to authentication failure, may also be returned.
MONGO_CLIENT_API std::string MONGO_CLIENT_FUNC mongo::timeToISOString | ( | time_t | time | ) |
Formats "time" according to the ISO 8601 extended form standard, including date, and time, in the UTC timezone.
Sample format: "2013-07-23T18:42:14Z"
MONGO_CLIENT_API std::string mongo::tojson | ( | const BSONArray & | arr, |
JsonStringFormat | format = Strict , |
||
bool | pretty = false |
||
) |
Convert a BSONArray to a JSON string.
arr | The BSON Array. |
format | The JSON format (JS, TenGen, Strict). |
pretty | Enables pretty output. |
MONGO_CLIENT_API std::string mongo::tojson | ( | const BSONObj & | obj, |
JsonStringFormat | format = Strict , |
||
bool | pretty = false |
||
) |
Convert a BSONObj to a JSON string.
obj | The BSON Object. |
format | The JSON format (JS, TenGen, Strict). |
pretty | Enables pretty output. |
MONGO_CLIENT_API MONGO_COMPILER_NORETURN void MONGO_CLIENT_FUNC mongo::uasserted | ( | int | msgid, |
const char * | msg | ||
) |
a "user assertion".
throws UserAssertion. logs. typically used for errors that a user could cause, such as duplicate key, disk full, etc.
Status mongo::validateBSON | ( | const char * | buf, |
uint64_t | maxLength | ||
) |
buf | - bson data |
maxLength | - maxLength of buffer this is NOT the bson size, but how far we know the buffer is valid |
MONGO_CLIENT_API const char* const mongo::saslCommandAutoAuthorizeFieldName |
Name of the saslStart parameter indicating that the server should automatically grant the connection all privileges associated with the user after successful authentication.
MONGO_CLIENT_API const char* const mongo::saslCommandConversationIdFieldName |
Name of the field containing the conversation identifier in server respones and saslContinue commands.
MONGO_CLIENT_API const char* const mongo::saslCommandDoneFieldName |
Name of the field that indicates whether or not the server believes authentication has completed successfully.
MONGO_CLIENT_API const char* const mongo::saslCommandMechanismListFieldName |
In the event that saslStart supplies an unsupported mechanism, the server responds with a field by this name, with a list of supported mechanisms.
MONGO_CLIENT_API const char* const mongo::saslCommandServiceHostnameFieldName |
Field overriding the FQDN of the hostname hosting the mongodb srevice in saslClientAuthenticate().
MONGO_CLIENT_API const char* const mongo::saslCommandUserDBFieldName |
Field containing the string identifier of the database containing credential information, or "$external" if the credential information is stored outside of the mongo cluster.
MONGO_CLIENT_API const char* const mongo::saslCommandUserFieldName |
Field containing the string identifier of the user to authenticate in saslClientAuthenticate().