MongoDB C++ Driver  legacy-1.0.5
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 
25 namespace mongo {
26 
27  class BSONObj;
28  class BSONElement;
29  class OID;
30 
37  Status bsonExtractField(const BSONObj& object,
38  const StringData& fieldName,
39  BSONElement* outElement);
40 
49  Status bsonExtractTypedField(const BSONObj& object,
50  const StringData& fieldName,
51  BSONType type,
52  BSONElement* outElement);
53 
62  Status bsonExtractBooleanField(const BSONObj& object,
63  const StringData& fieldName,
64  bool* out);
65 
76  Status bsonExtractIntegerField(const BSONObj& object,
77  const StringData& fieldName,
78  long long* out);
79 
88  Status bsonExtractStringField(const BSONObj& object,
89  const StringData& fieldName,
90  std::string* out);
91 
100  Status bsonExtractOIDField(const BSONObj& object,
101  const StringData& fieldName,
102  OID* out);
103 
114  Status bsonExtractBooleanFieldWithDefault(const BSONObj& object,
115  const StringData& fieldName,
116  bool defaultValue,
117  bool* out);
118 
129  Status bsonExtractIntegerFieldWithDefault(const BSONObj& object,
130  const StringData& fieldName,
131  long long defaultValue,
132  long long* out);
133 
144  Status bsonExtractStringFieldWithDefault(const BSONObj& object,
145  const StringData& fieldName,
146  const StringData& defaultValue,
147  std::string* out);
148 
157  Status bsonExtractOIDFieldWithDefault(const BSONObj& object,
158  const StringData& fieldName,
159  const OID& defaultValue,
160  OID* out);
161 
162 } // namespace mongo
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. ...
the main MongoDB namespace
Definition: bulk_operation_builder.h:24
Status bsonExtractBooleanFieldWithDefault(const BSONObj &object, const StringData &fieldName, bool defaultValue, bool *out)
Finds a bool-like element named "fieldName" in "object".
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.
Status bsonExtractBooleanField(const BSONObj &object, const StringData &fieldName, 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".
BSONType
the complete list of valid BSON types see also bsonspec.org
Definition: bsontypes.h:38
Status bsonExtractField(const BSONObj &object, const StringData &fieldName, BSONElement *outElement)
Finds an 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 bsonExtractOIDField(const BSONObj &object, const StringData &fieldName, OID *out)
Finds an OID-typed element named "fieldName" in "object" and stores its value in "out".
Status bsonExtractIntegerField(const BSONObj &object, const StringData &fieldName, long long *out)
Finds an element named "fieldName" in "object" that represents an integral value. ...
MONGO_CLIENT_API Status(MONGO_CLIENT_FUNC *saslClientAuthenticate)(DBClientWithCommands *client
Attempts to authenticate "client" using the SASL protocol.
Status bsonExtractStringFieldWithDefault(const BSONObj &object, const StringData &fieldName, const StringData &defaultValue, std::string *out)
Finds a string element named "fieldName" in "object".