blob: 683968ee5ec1b3e4b9d30cb804faac73279e11be [file] [log] [blame]
csharptestff628f62011-06-11 12:32:36 -05001#region Copyright notice and license
2
3// Protocol Buffers - Google's data interchange format
4// Copyright 2008 Google Inc. All rights reserved.
5// http://github.com/jskeet/dotnet-protobufs/
6// Original C++/Java/Python code:
7// http://code.google.com/p/protobuf/
8//
9// Redistribution and use in source and binary forms, with or without
10// modification, are permitted provided that the following conditions are
11// met:
12//
13// * Redistributions of source code must retain the above copyright
14// notice, this list of conditions and the following disclaimer.
15// * Redistributions in binary form must reproduce the above
16// copyright notice, this list of conditions and the following disclaimer
17// in the documentation and/or other materials provided with the
18// distribution.
19// * Neither the name of Google Inc. nor the names of its
20// contributors may be used to endorse or promote products derived from
21// this software without specific prior written permission.
22//
23// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34
35#endregion
36
csharptest17699c22011-06-03 21:57:15 -050037using System;
38using System.Collections.Generic;
39using Google.ProtocolBuffers.Descriptors;
40
41//Disable warning CS3010: CLS-compliant interfaces must have only CLS-compliant members
42#pragma warning disable 3010
43
44namespace Google.ProtocolBuffers
45{
46 public interface ICodedInputStream
47 {
48 /// <summary>
49 /// Attempt to read a field tag, returning false if we have reached the end
50 /// of the input data.
51 /// </summary>
52 /// <remarks>
53 /// <para>
54 /// If fieldTag is non-zero and ReadTag returns true then the value in fieldName
55 /// may or may not be populated. However, if fieldTag is zero and ReadTag returns
56 /// true, then fieldName should be populated with a non-null field name.
57 /// </para><para>
58 /// In other words if ReadTag returns true then either fieldTag will be non-zero OR
59 /// fieldName will be non-zero. In some cases both may be populated, however the
60 /// builders will always prefer the fieldTag over fieldName.
61 /// </para>
62 /// </remarks>
63 [CLSCompliant(false)]
64 bool ReadTag(out uint fieldTag, out string fieldName);
65
66 /// <summary>
67 /// Read a double field from the stream.
68 /// </summary>
69 bool ReadDouble(ref double value);
70
71 /// <summary>
72 /// Read a float field from the stream.
73 /// </summary>
74 bool ReadFloat(ref float value);
75
76 /// <summary>
77 /// Read a uint64 field from the stream.
78 /// </summary>
79 [CLSCompliant(false)]
80 bool ReadUInt64(ref ulong value);
81
82 /// <summary>
83 /// Read an int64 field from the stream.
84 /// </summary>
85 bool ReadInt64(ref long value);
86
87 /// <summary>
88 /// Read an int32 field from the stream.
89 /// </summary>
90 bool ReadInt32(ref int value);
91
92 /// <summary>
93 /// Read a fixed64 field from the stream.
94 /// </summary>
95 [CLSCompliant(false)]
96 bool ReadFixed64(ref ulong value);
97
98 /// <summary>
99 /// Read a fixed32 field from the stream.
100 /// </summary>
101 [CLSCompliant(false)]
102 bool ReadFixed32(ref uint value);
103
104 /// <summary>
105 /// Read a bool field from the stream.
106 /// </summary>
107 bool ReadBool(ref bool value);
108
109 /// <summary>
110 /// Reads a string field from the stream.
111 /// </summary>
112 bool ReadString(ref string value);
113
114 /// <summary>
115 /// Reads a group field value from the stream.
116 /// </summary>
117 void ReadGroup(int fieldNumber, IBuilderLite builder,
csharptest74c5e0c2011-07-14 13:06:22 -0500118 ExtensionRegistry extensionRegistry);
csharptest17699c22011-06-03 21:57:15 -0500119
120 /// <summary>
121 /// Reads a group field value from the stream and merges it into the given
122 /// UnknownFieldSet.
123 /// </summary>
124 [Obsolete]
125 void ReadUnknownGroup(int fieldNumber, IBuilderLite builder);
126
127 /// <summary>
128 /// Reads an embedded message field value from the stream.
129 /// </summary>
130 void ReadMessage(IBuilderLite builder, ExtensionRegistry extensionRegistry);
131
132 /// <summary>
133 /// Reads a bytes field value from the stream.
134 /// </summary>
135 bool ReadBytes(ref ByteString value);
136
137 /// <summary>
138 /// Reads a uint32 field value from the stream.
139 /// </summary>
140 [CLSCompliant(false)]
141 bool ReadUInt32(ref uint value);
142
143 /// <summary>
144 /// Reads an enum field value from the stream. The caller is responsible
145 /// for converting the numeric value to an actual enum.
146 /// </summary>
147 bool ReadEnum(ref IEnumLite value, out object unknown, IEnumLiteMap mapping);
148
149 /// <summary>
150 /// Reads an enum field value from the stream. If the enum is valid for type T,
151 /// then the ref value is set and it returns true. Otherwise the unkown output
152 /// value is set and this method returns false.
153 /// </summary>
154 [CLSCompliant(false)]
155 bool ReadEnum<T>(ref T value, out object unknown)
156 where T : struct, IComparable, IFormattable, IConvertible;
157
158 /// <summary>
159 /// Reads an sfixed32 field value from the stream.
160 /// </summary>
161 bool ReadSFixed32(ref int value);
162
163 /// <summary>
164 /// Reads an sfixed64 field value from the stream.
165 /// </summary>
166 bool ReadSFixed64(ref long value);
167
168 /// <summary>
169 /// Reads an sint32 field value from the stream.
170 /// </summary>
171 bool ReadSInt32(ref int value);
172
173 /// <summary>
174 /// Reads an sint64 field value from the stream.
175 /// </summary>
176 bool ReadSInt64(ref long value);
177
178 /// <summary>
179 /// Reads an array of primitive values into the list, if the wire-type of fieldTag is length-prefixed and the
180 /// type is numberic, it will read a packed array.
181 /// </summary>
182 [CLSCompliant(false)]
csharptestced18e12011-06-09 19:47:56 -0500183 void ReadPrimitiveArray(FieldType fieldType, uint fieldTag, string fieldName, ICollection<object> list);
184
185 /// <summary>
csharptest17699c22011-06-03 21:57:15 -0500186 /// Reads an array of primitive values into the list, if the wire-type of fieldTag is length-prefixed, it will
187 /// read a packed array.
188 /// </summary>
189 [CLSCompliant(false)]
csharptest74c5e0c2011-07-14 13:06:22 -0500190 void ReadEnumArray(uint fieldTag, string fieldName, ICollection<IEnumLite> list, out ICollection<object> unknown,
191 IEnumLiteMap mapping);
csharptest17699c22011-06-03 21:57:15 -0500192
193 /// <summary>
194 /// Reads an array of primitive values into the list, if the wire-type of fieldTag is length-prefixed, it will
195 /// read a packed array.
196 /// </summary>
197 [CLSCompliant(false)]
198 void ReadEnumArray<T>(uint fieldTag, string fieldName, ICollection<T> list, out ICollection<object> unknown)
199 where T : struct, IComparable, IFormattable, IConvertible;
200
201 /// <summary>
202 /// Reads a set of messages using the <paramref name="messageType"/> as a template. T is not guaranteed to be
203 /// the most derived type, it is only the type specifier for the collection.
204 /// </summary>
205 [CLSCompliant(false)]
csharptest74c5e0c2011-07-14 13:06:22 -0500206 void ReadMessageArray<T>(uint fieldTag, string fieldName, ICollection<T> list, T messageType,
207 ExtensionRegistry registry) where T : IMessageLite;
csharptest17699c22011-06-03 21:57:15 -0500208
209 /// <summary>
210 /// Reads a set of messages using the <paramref name="messageType"/> as a template.
211 /// </summary>
212 [CLSCompliant(false)]
csharptest74c5e0c2011-07-14 13:06:22 -0500213 void ReadGroupArray<T>(uint fieldTag, string fieldName, ICollection<T> list, T messageType,
214 ExtensionRegistry registry) where T : IMessageLite;
csharptest17699c22011-06-03 21:57:15 -0500215
216 /// <summary>
217 /// Reads a field of any primitive type. Enums, groups and embedded
218 /// messages are not handled by this method.
219 /// </summary>
220 bool ReadPrimitiveField(FieldType fieldType, ref object value);
221
222 /// <summary>
223 /// Returns true if the stream has reached the end of the input. This is the
224 /// case if either the end of the underlying input source has been reached or
225 /// the stream has reached a limit created using PushLimit.
226 /// </summary>
227 bool IsAtEnd { get; }
228
229 /// <summary>
230 /// Reads and discards a single field, given its tag value.
231 /// </summary>
232 /// <returns>false if the tag is an end-group tag, in which case
233 /// nothing is skipped. Otherwise, returns true.</returns>
234 [CLSCompliant(false)]
235 bool SkipField();
csharptestb00ea132011-06-10 01:09:57 -0500236
237 [CLSCompliant(false)]
238 void ReadStringArray(uint fieldTag, string fieldName, ICollection<string> list);
239
240 [CLSCompliant(false)]
241 void ReadBytesArray(uint fieldTag, string fieldName, ICollection<ByteString> list);
242
243 [CLSCompliant(false)]
244 void ReadBoolArray(uint fieldTag, string fieldName, ICollection<bool> list);
245
246 [CLSCompliant(false)]
247 void ReadInt32Array(uint fieldTag, string fieldName, ICollection<int> list);
248
249 [CLSCompliant(false)]
250 void ReadSInt32Array(uint fieldTag, string fieldName, ICollection<int> list);
251
252 [CLSCompliant(false)]
253 void ReadUInt32Array(uint fieldTag, string fieldName, ICollection<uint> list);
254
255 [CLSCompliant(false)]
256 void ReadFixed32Array(uint fieldTag, string fieldName, ICollection<uint> list);
257
258 [CLSCompliant(false)]
259 void ReadSFixed32Array(uint fieldTag, string fieldName, ICollection<int> list);
260
261 [CLSCompliant(false)]
262 void ReadInt64Array(uint fieldTag, string fieldName, ICollection<long> list);
263
264 [CLSCompliant(false)]
265 void ReadSInt64Array(uint fieldTag, string fieldName, ICollection<long> list);
266
267 [CLSCompliant(false)]
268 void ReadUInt64Array(uint fieldTag, string fieldName, ICollection<ulong> list);
269
270 [CLSCompliant(false)]
271 void ReadFixed64Array(uint fieldTag, string fieldName, ICollection<ulong> list);
272
273 [CLSCompliant(false)]
274 void ReadSFixed64Array(uint fieldTag, string fieldName, ICollection<long> list);
275
276 [CLSCompliant(false)]
277 void ReadDoubleArray(uint fieldTag, string fieldName, ICollection<double> list);
278
279 [CLSCompliant(false)]
280 void ReadFloatArray(uint fieldTag, string fieldName, ICollection<float> list);
csharptest17699c22011-06-03 21:57:15 -0500281 }
282}