-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathIBsonReader.cs
259 lines (218 loc) · 7.63 KB
/
IBsonReader.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
/* Copyright 2010-present MongoDB Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
namespace MongoDB.Bson.IO
{
/// <summary>
/// Represents a BSON reader.
/// </summary>
public interface IBsonReader : IDisposable
{
// properties
/// <summary>
/// Gets the current BsonType.
/// </summary>
BsonType CurrentBsonType { get; }
/// <summary>
/// Gets the current state of the reader.
/// </summary>
BsonReaderState State { get; }
// methods
/// <summary>
/// Closes the reader.
/// </summary>
void Close();
/// <summary>
/// Gets a bookmark to the reader's current position and state.
/// </summary>
/// <returns>A bookmark.</returns>
BsonReaderBookmark GetBookmark();
/// <summary>
/// Gets the current BsonType (calls ReadBsonType if necessary).
/// </summary>
/// <returns>The current BsonType.</returns>
BsonType GetCurrentBsonType();
/// <summary>
/// Determines whether this reader is at end of file.
/// </summary>
/// <returns>
/// Whether this reader is at end of file.
/// </returns>
bool IsAtEndOfFile();
/// <summary>
/// Pops the settings.
/// </summary>
void PopSettings(); //TODO Why do we have push and pop methods? They are not used
/// <summary>
/// Pushes new settings for the reader.
/// </summary>
/// <param name="configurator">The settings configurator.</param>
void PushSettings(Action<BsonReaderSettings> configurator);
/// <summary>
/// Reads BSON binary data from the reader.
/// </summary>
/// <returns>A BsonBinaryData.</returns>
BsonBinaryData ReadBinaryData();
/// <summary>
/// Reads a BSON boolean from the reader.
/// </summary>
/// <returns>A Boolean.</returns>
bool ReadBoolean();
/// <summary>
/// Reads a BsonType from the reader.
/// </summary>
/// <returns>A BsonType.</returns>
BsonType ReadBsonType();
/// <summary>
/// Reads BSON binary data from the reader.
/// </summary>
/// <returns>A byte array.</returns>
byte[] ReadBytes();
/// <summary>
/// Reads a BSON DateTime from the reader.
/// </summary>
/// <returns>The number of milliseconds since the Unix epoch.</returns>
long ReadDateTime();
/// <summary>
/// Reads a BSON Decimal128 from the reader.
/// </summary>
/// <returns>A <see cref="Decimal128" />.</returns>
Decimal128 ReadDecimal128();
/// <summary>
/// Reads a BSON Double from the reader.
/// </summary>
/// <returns>A Double.</returns>
double ReadDouble();
/// <summary>
/// Reads the end of a BSON array from the reader.
/// </summary>
void ReadEndArray();
/// <summary>
/// Reads the end of a BSON document from the reader.
/// </summary>
void ReadEndDocument();
/// <summary>
/// Reads a Guid from the reader.
/// </summary>
/// <returns>A Guid.</returns>
public Guid ReadGuid();
/// <summary>
/// Reads a Guid with the specified representation from the reader.
/// </summary>
/// <param name="guidRepresentation">The Guid representation.</param>
/// <returns>A Guid.</returns>
public Guid ReadGuid(GuidRepresentation guidRepresentation);
/// <summary>
/// Reads a BSON Int32 from the reader.
/// </summary>
/// <returns>An Int32.</returns>
int ReadInt32();
/// <summary>
/// Reads a BSON Int64 from the reader.
/// </summary>
/// <returns>An Int64.</returns>
long ReadInt64();
/// <summary>
/// Reads a BSON JavaScript from the reader.
/// </summary>
/// <returns>A string.</returns>
string ReadJavaScript();
/// <summary>
/// Reads a BSON JavaScript with scope from the reader (call ReadStartDocument next to read the scope).
/// </summary>
/// <returns>A string.</returns>
string ReadJavaScriptWithScope();
/// <summary>
/// Reads a BSON MaxKey from the reader.
/// </summary>
void ReadMaxKey();
/// <summary>
/// Reads a BSON MinKey from the reader.
/// </summary>
void ReadMinKey();
/// <summary>
/// Reads the name of an element from the reader (using the provided name decoder).
/// </summary>
/// <param name="nameDecoder">The name decoder.</param>
/// <returns>
/// The name of the element.
/// </returns>
string ReadName(INameDecoder nameDecoder);
/// <summary>
/// Reads a BSON null from the reader.
/// </summary>
void ReadNull();
/// <summary>
/// Reads a BSON ObjectId from the reader.
/// </summary>
/// <returns>An ObjectId.</returns>
ObjectId ReadObjectId();
/// <summary>
/// Reads a raw BSON array.
/// </summary>
/// <returns>The raw BSON array.</returns>
IByteBuffer ReadRawBsonArray();
/// <summary>
/// Reads a raw BSON document.
/// </summary>
/// <returns>The raw BSON document.</returns>
IByteBuffer ReadRawBsonDocument();
/// <summary>
/// Reads a BSON regular expression from the reader.
/// </summary>
/// <returns>A BsonRegularExpression.</returns>
BsonRegularExpression ReadRegularExpression();
/// <summary>
/// Reads the start of a BSON array.
/// </summary>
void ReadStartArray();
/// <summary>
/// Reads the start of a BSON document.
/// </summary>
void ReadStartDocument();
/// <summary>
/// Reads a BSON string from the reader.
/// </summary>
/// <returns>A String.</returns>
string ReadString();
/// <summary>
/// Reads a BSON symbol from the reader.
/// </summary>
/// <returns>A string.</returns>
string ReadSymbol();
/// <summary>
/// Reads a BSON timestamp from the reader.
/// </summary>
/// <returns>The combined timestamp/increment.</returns>
long ReadTimestamp();
/// <summary>
/// Reads a BSON undefined from the reader.
/// </summary>
void ReadUndefined();
/// <summary>
/// Returns the reader to previously bookmarked position and state.
/// </summary>
/// <param name="bookmark">The bookmark.</param>
void ReturnToBookmark(BsonReaderBookmark bookmark);
/// <summary>
/// Skips the name (reader must be positioned on a name).
/// </summary>
void SkipName();
/// <summary>
/// Skips the value (reader must be positioned on a value).
/// </summary>
void SkipValue();
}
}