MongoDB  2.7.0
bson_builder_base.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 "mongo/base/string_data.h"
19 #include "mongo/bson/util/builder.h"
20 
21 namespace mongo {
22 
23  /*
24  * BSONBuilderBase contains the common interface between different types of BSON builders.
25  *
26  * Currently, this interface is not comprehensive. But we should work toward that goal. If
27  * you are maintaining the class, please make sure that all Builders behave coherently.
28  */
30  public:
31  virtual ~BSONBuilderBase() {}
32 
33  virtual BSONObj obj() = 0;
34 
35  virtual BufBuilder& subobjStart( const StringData& fieldName ) = 0;
36 
37  virtual BufBuilder& subarrayStart( const StringData& fieldName ) = 0;
38 
39  virtual BSONBuilderBase& append( const BSONElement& e) = 0;
40 
41  virtual BSONBuilderBase& append( const StringData& fieldName , int n ) = 0;
42 
43  virtual BSONBuilderBase& append( const StringData& fieldName , long long n ) = 0;
44 
45  virtual BSONBuilderBase& append( const StringData& fieldName , double n ) = 0;
46 
47  virtual BSONBuilderBase& appendArray( const StringData& fieldName , const BSONObj& subObj ) = 0;
48 
49  virtual BSONBuilderBase& appendAs( const BSONElement& e , const StringData& filedName ) = 0;
50 
51  virtual void appendNull( ) = 0;
52 
53  virtual BSONBuilderBase& operator<<( const BSONElement& e ) = 0;
54 
55  virtual bool isArray() const = 0;
56  };
57 
58 } // namespace mongo
BSONElement represents an "element" in a BSONObj.
Definition: bsonelement.h:62
C++ representation of a "BSON" object – that is, an extended JSON-style object in a binary representa...
Definition: bsonobj.h:77
Definition: bson_builder_base.h:29