MongoDB C++ Driver legacy-1.0.5
Loading...
Searching...
No Matches
bson_extract.h
1/* Copyright 2012 10gen 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
16#pragma once
17
18#include <string>
19#include <vector>
20
21#include "mongo/base/status.h"
22#include "mongo/base/string_data.h"
23#include "mongo/bson/bsontypes.h"
24
25namespace mongo {
26
27 class BSONObj;
28 class BSONElement;
29 class OID;
30
38 const StringData& fieldName,
39 BSONElement* outElement);
40
50 const StringData& fieldName,
51 BSONType type,
52 BSONElement* outElement);
53
63 const StringData& fieldName,
64 bool* out);
65
77 const StringData& fieldName,
78 long long* out);
79
89 const StringData& fieldName,
90 std::string* out);
91
101 const StringData& fieldName,
102 OID* out);
103
115 const StringData& fieldName,
116 bool defaultValue,
117 bool* out);
118
130 const StringData& fieldName,
131 long long defaultValue,
132 long long* out);
133
145 const StringData& fieldName,
146 const StringData& defaultValue,
147 std::string* out);
148
158 const StringData& fieldName,
159 const OID& defaultValue,
160 OID* out);
161
162} // namespace mongo
BSONElement represents an "element" in a BSONObj.
Definition bsonelement.h:55
C++ representation of a "BSON" object – that is, an extended JSON-style object in a binary representa...
Definition bsonobj.h:78
Object ID type.
Definition oid.h:60
the main MongoDB namespace
Definition bulk_operation_builder.h:24
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.
Status bsonExtractBooleanField(const BSONObj &object, const StringData &fieldName, bool *out)
Finds a bool-like element named "fieldName" in "object".
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".
Status bsonExtractField(const BSONObj &object, const StringData &fieldName, BSONElement *outElement)
Finds an element named "fieldName" in "object".
Status bsonExtractBooleanFieldWithDefault(const BSONObj &object, const StringData &fieldName, bool defaultValue, bool *out)
Finds a bool-like element named "fieldName" in "object".
Status bsonExtractTypedField(const BSONObj &object, const StringData &fieldName, BSONType type, BSONElement *outElement)
Finds an element named "fieldName" in "object".
Status bsonExtractStringFieldWithDefault(const BSONObj &object, const StringData &fieldName, const StringData &defaultValue, std::string *out)
Finds a string element named "fieldName" in "object".
MONGO_CLIENT_API Status(MONGO_CLIENT_FUNC *saslClientAuthenticate)(DBClientWithCommands *client
Attempts to authenticate "client" using the SASL protocol.
Status bsonExtractIntegerField(const BSONObj &object, const StringData &fieldName, long long *out)
Finds an element named "fieldName" in "object" that represents an integral value.
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".
BSONType
the complete list of valid BSON types see also bsonspec.org
Definition bsontypes.h:38
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.