MongoDB C++ Driver  legacy-1.1.2
bson_db.h
Go to the documentation of this file.
1 
3 /* Copyright 2009 10gen Inc.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 /*
19  This file contains the implementation of BSON-related methods that are required
20  by the MongoDB database server.
21 
22  Normally, for standalone BSON usage, you do not want this file - it will tend to
23  pull in some other files from the MongoDB project. Thus, bson.h (the main file
24  one would use) does not include this file.
25 */
26 
27 #pragma once
28 
29 #include "mongo/util/time_support.h"
30 
31 namespace mongo {
32 
33 inline BSONObjBuilder& BSONObjBuilderValueStream::operator<<(const DateNowLabeler& id) {
34  _builder->appendDate(_fieldName, jsTime());
35  _fieldName = StringData();
36  return *_builder;
37 }
38 
39 inline BSONObjBuilder& BSONObjBuilderValueStream::operator<<(const NullLabeler& id) {
40  _builder->appendNull(_fieldName);
41  _fieldName = StringData();
42  return *_builder;
43 }
44 
45 inline BSONObjBuilder& BSONObjBuilderValueStream::operator<<(const UndefinedLabeler& id) {
46  _builder->appendUndefined(_fieldName);
47  _fieldName = StringData();
48  return *_builder;
49 }
50 
51 
52 inline BSONObjBuilder& BSONObjBuilderValueStream::operator<<(const MinKeyLabeler& id) {
53  _builder->appendMinKey(_fieldName);
54  _fieldName = StringData();
55  return *_builder;
56 }
57 
58 inline BSONObjBuilder& BSONObjBuilderValueStream::operator<<(const MaxKeyLabeler& id) {
59  _builder->appendMaxKey(_fieldName);
60  _fieldName = StringData();
61  return *_builder;
62 }
63 }
Utility functions for parsing numbers from strings.
Definition: compare_numbers.h:20
MONGO_CLIENT_API Date_t MONGO_CLIENT_FUNC jsTime()
Date_t is milliseconds since epoch.
void appendNull()
Implements builder interface but no-op in ObjBuilder.
Definition: bsonobjbuilder.h:453
BSONObjBuilder & appendDate(const StringData &fieldName, Date_t dt)
Append a date.