blob: f4c662277cf9c985c707883e0edbb4b44e80e9a1 [file] [log] [blame]
csharptest17699c22011-06-03 21:57:15 -05001using System;
2using System.Collections.Generic;
3using Google.ProtocolBuffers.Descriptors;
4
5//Disable warning CS3010: CLS-compliant interfaces must have only CLS-compliant members
6#pragma warning disable 3010
7
8namespace Google.ProtocolBuffers
9{
10 public interface ICodedInputStream
11 {
12 /// <summary>
13 /// Attempt to read a field tag, returning false if we have reached the end
14 /// of the input data.
15 /// </summary>
16 /// <remarks>
17 /// <para>
18 /// If fieldTag is non-zero and ReadTag returns true then the value in fieldName
19 /// may or may not be populated. However, if fieldTag is zero and ReadTag returns
20 /// true, then fieldName should be populated with a non-null field name.
21 /// </para><para>
22 /// In other words if ReadTag returns true then either fieldTag will be non-zero OR
23 /// fieldName will be non-zero. In some cases both may be populated, however the
24 /// builders will always prefer the fieldTag over fieldName.
25 /// </para>
26 /// </remarks>
27 [CLSCompliant(false)]
28 bool ReadTag(out uint fieldTag, out string fieldName);
29
30 /// <summary>
31 /// Read a double field from the stream.
32 /// </summary>
33 bool ReadDouble(ref double value);
34
35 /// <summary>
36 /// Read a float field from the stream.
37 /// </summary>
38 bool ReadFloat(ref float value);
39
40 /// <summary>
41 /// Read a uint64 field from the stream.
42 /// </summary>
43 [CLSCompliant(false)]
44 bool ReadUInt64(ref ulong value);
45
46 /// <summary>
47 /// Read an int64 field from the stream.
48 /// </summary>
49 bool ReadInt64(ref long value);
50
51 /// <summary>
52 /// Read an int32 field from the stream.
53 /// </summary>
54 bool ReadInt32(ref int value);
55
56 /// <summary>
57 /// Read a fixed64 field from the stream.
58 /// </summary>
59 [CLSCompliant(false)]
60 bool ReadFixed64(ref ulong value);
61
62 /// <summary>
63 /// Read a fixed32 field from the stream.
64 /// </summary>
65 [CLSCompliant(false)]
66 bool ReadFixed32(ref uint value);
67
68 /// <summary>
69 /// Read a bool field from the stream.
70 /// </summary>
71 bool ReadBool(ref bool value);
72
73 /// <summary>
74 /// Reads a string field from the stream.
75 /// </summary>
76 bool ReadString(ref string value);
77
78 /// <summary>
79 /// Reads a group field value from the stream.
80 /// </summary>
81 void ReadGroup(int fieldNumber, IBuilderLite builder,
82 ExtensionRegistry extensionRegistry);
83
84 /// <summary>
85 /// Reads a group field value from the stream and merges it into the given
86 /// UnknownFieldSet.
87 /// </summary>
88 [Obsolete]
89 void ReadUnknownGroup(int fieldNumber, IBuilderLite builder);
90
91 /// <summary>
92 /// Reads an embedded message field value from the stream.
93 /// </summary>
94 void ReadMessage(IBuilderLite builder, ExtensionRegistry extensionRegistry);
95
96 /// <summary>
97 /// Reads a bytes field value from the stream.
98 /// </summary>
99 bool ReadBytes(ref ByteString value);
100
101 /// <summary>
102 /// Reads a uint32 field value from the stream.
103 /// </summary>
104 [CLSCompliant(false)]
105 bool ReadUInt32(ref uint value);
106
107 /// <summary>
108 /// Reads an enum field value from the stream. The caller is responsible
109 /// for converting the numeric value to an actual enum.
110 /// </summary>
111 bool ReadEnum(ref IEnumLite value, out object unknown, IEnumLiteMap mapping);
112
113 /// <summary>
114 /// Reads an enum field value from the stream. If the enum is valid for type T,
115 /// then the ref value is set and it returns true. Otherwise the unkown output
116 /// value is set and this method returns false.
117 /// </summary>
118 [CLSCompliant(false)]
119 bool ReadEnum<T>(ref T value, out object unknown)
120 where T : struct, IComparable, IFormattable, IConvertible;
121
122 /// <summary>
123 /// Reads an sfixed32 field value from the stream.
124 /// </summary>
125 bool ReadSFixed32(ref int value);
126
127 /// <summary>
128 /// Reads an sfixed64 field value from the stream.
129 /// </summary>
130 bool ReadSFixed64(ref long value);
131
132 /// <summary>
133 /// Reads an sint32 field value from the stream.
134 /// </summary>
135 bool ReadSInt32(ref int value);
136
137 /// <summary>
138 /// Reads an sint64 field value from the stream.
139 /// </summary>
140 bool ReadSInt64(ref long value);
141
142 /// <summary>
143 /// Reads an array of primitive values into the list, if the wire-type of fieldTag is length-prefixed and the
144 /// type is numberic, it will read a packed array.
145 /// </summary>
146 [CLSCompliant(false)]
csharptestced18e12011-06-09 19:47:56 -0500147 void ReadPrimitiveArray(FieldType fieldType, uint fieldTag, string fieldName, ICollection<object> list);
148
149 /// <summary>
150 /// Reads an array of primitive values into the list, if the wire-type of fieldTag is length-prefixed and the
151 /// type is numberic, it will read a packed array.
152 /// </summary>
153 [CLSCompliant(false)]
csharptest17699c22011-06-03 21:57:15 -0500154 void ReadPrimitiveArray<T>(FieldType fieldType, uint fieldTag, string fieldName, ICollection<T> list);
155
156 /// <summary>
157 /// Reads an array of primitive values into the list, if the wire-type of fieldTag is length-prefixed, it will
158 /// read a packed array.
159 /// </summary>
160 [CLSCompliant(false)]
161 void ReadEnumArray(uint fieldTag, string fieldName, ICollection<IEnumLite> list, out ICollection<object> unknown, IEnumLiteMap mapping);
162
163 /// <summary>
164 /// Reads an array of primitive values into the list, if the wire-type of fieldTag is length-prefixed, it will
165 /// read a packed array.
166 /// </summary>
167 [CLSCompliant(false)]
168 void ReadEnumArray<T>(uint fieldTag, string fieldName, ICollection<T> list, out ICollection<object> unknown)
169 where T : struct, IComparable, IFormattable, IConvertible;
170
171 /// <summary>
172 /// Reads a set of messages using the <paramref name="messageType"/> as a template. T is not guaranteed to be
173 /// the most derived type, it is only the type specifier for the collection.
174 /// </summary>
175 [CLSCompliant(false)]
176 void ReadMessageArray<T>(uint fieldTag, string fieldName, ICollection<T> list, T messageType, ExtensionRegistry registry) where T : IMessageLite;
177
178 /// <summary>
179 /// Reads a set of messages using the <paramref name="messageType"/> as a template.
180 /// </summary>
181 [CLSCompliant(false)]
182 void ReadGroupArray<T>(uint fieldTag, string fieldName, ICollection<T> list, T messageType, ExtensionRegistry registry) where T : IMessageLite;
183
184 /// <summary>
185 /// Reads a field of any primitive type. Enums, groups and embedded
186 /// messages are not handled by this method.
187 /// </summary>
188 bool ReadPrimitiveField(FieldType fieldType, ref object value);
189
190 /// <summary>
191 /// Returns true if the stream has reached the end of the input. This is the
192 /// case if either the end of the underlying input source has been reached or
193 /// the stream has reached a limit created using PushLimit.
194 /// </summary>
195 bool IsAtEnd { get; }
196
197 /// <summary>
198 /// Reads and discards a single field, given its tag value.
199 /// </summary>
200 /// <returns>false if the tag is an end-group tag, in which case
201 /// nothing is skipped. Otherwise, returns true.</returns>
202 [CLSCompliant(false)]
203 bool SkipField();
204 }
205}