MongoDB C++ Driver legacy-1.1.2
Loading...
Searching...
No Matches
bsontypes.h
1// bsontypes.h
2
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#pragma once
19
20#include "mongo/util/assert_util.h"
21
22namespace mongo {
23
24class BSONArrayBuilder;
25class BSONElement;
26class BSONObj;
27class BSONObjBuilder;
28class BSONObjBuilderValueStream;
29class BSONObjIterator;
30class Ordering;
31struct BSONArray; // empty subclass of BSONObj useful for overloading
32struct BSONElementCmpWithoutField;
33
40 MinKey = -1,
42 EOO = 0,
46 String = 2,
48 Object = 3,
50 Array = 4,
56 jstOID = 7,
58 Bool = 8,
60 Date = 9,
62 jstNULL = 10,
64 RegEx = 11,
66 DBRef = 12,
68 Code = 13,
70 Symbol = 14,
82 MaxKey = 127
83};
84
88const char* typeName(BSONType type);
89
90/* subtypes of BinData.
91 bdtCustom and above are ones that the JS compiler understands, but are
92 opaque to the database.
93*/
94enum BinDataType {
95 BinDataGeneral = 0,
96 Function = 1,
97 ByteArrayDeprecated = 2, /* use BinGeneral instead */
98 bdtUUID = 3, /* deprecated */
99 newUUID = 4, /* language-independent UUID format across all drivers */
100 MD5Type = 5,
101 bdtCustom = 128
102};
103
110 switch (type) {
111 case MinKey:
112 case MaxKey:
113 return type;
114 case EOO:
115 case Undefined:
116 return 0;
117 case jstNULL:
118 return 5;
119 case NumberDouble:
120 case NumberInt:
121 case NumberLong:
122 return 10;
123 case mongo::String:
124 case Symbol:
125 return 15;
126 case Object:
127 return 20;
128 case mongo::Array:
129 return 25;
130 case BinData:
131 return 30;
132 case jstOID:
133 return 35;
134 case mongo::Bool:
135 return 40;
136 case mongo::Date:
137 return 45;
138 case Timestamp:
139 return 47;
140 case RegEx:
141 return 50;
142 case DBRef:
143 return 55;
144 case Code:
145 return 60;
146 case CodeWScope:
147 return 65;
148 default:
149 verify(0);
150 return -1;
151 }
152}
153}
Utility functions for parsing numbers from strings.
Definition compare_numbers.h:20
int canonicalizeBSONType(BSONType type)
Returns a number for where a given type falls in the sort order.
Definition bsontypes.h:109
const char * typeName(BSONType type)
returns the name of the argument's type
BSONType
the complete list of valid BSON types see also bsonspec.org
Definition bsontypes.h:38
@ CodeWScope
javascript code that can execute on the database server, with SavedContext
Definition bsontypes.h:72
@ Symbol
a programming language (e.g., Python) symbol
Definition bsontypes.h:70
@ String
character string, stored in utf8
Definition bsontypes.h:46
@ BinData
binary data
Definition bsontypes.h:52
@ Array
an embedded array
Definition bsontypes.h:50
@ Bool
boolean type
Definition bsontypes.h:58
@ MaxKey
larger than all other types
Definition bsontypes.h:82
@ Timestamp
Updated to a Date with value next OpTime on insert.
Definition bsontypes.h:76
@ Code
deprecated / use CodeWScope
Definition bsontypes.h:68
@ RegEx
regular expression, a pattern with options
Definition bsontypes.h:64
@ jstOID
ObjectId.
Definition bsontypes.h:56
@ Undefined
Undefined type.
Definition bsontypes.h:54
@ JSTypeMax
max type that is not MaxKey
Definition bsontypes.h:80
@ EOO
end of object
Definition bsontypes.h:42
@ Object
an embedded object
Definition bsontypes.h:48
@ NumberLong
64 bit integer
Definition bsontypes.h:78
@ jstNULL
null type
Definition bsontypes.h:62
@ NumberInt
32 bit signed integer
Definition bsontypes.h:74
@ DBRef
deprecated / will be redesigned
Definition bsontypes.h:66
@ NumberDouble
double precision floating point value
Definition bsontypes.h:44
@ MinKey
smaller than all other types
Definition bsontypes.h:40
@ Date
date type
Definition bsontypes.h:60