csharptest | ff628f6 | 2011-06-11 12:32:36 -0500 | [diff] [blame^] | 1 | #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 |
|
csharptest | 17699c2 | 2011-06-03 21:57:15 -0500 | [diff] [blame] | 37 | using System;
|
| 38 | using System.Collections.Generic;
|
| 39 | using Google.ProtocolBuffers.Descriptors;
|
| 40 |
|
| 41 | //Disable warning CS3010: CLS-compliant interfaces must have only CLS-compliant members
|
| 42 | #pragma warning disable 3010
|
| 43 |
|
| 44 | namespace 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,
|
| 118 | ExtensionRegistry extensionRegistry);
|
| 119 |
|
| 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)]
|
csharptest | ced18e1 | 2011-06-09 19:47:56 -0500 | [diff] [blame] | 183 | void ReadPrimitiveArray(FieldType fieldType, uint fieldTag, string fieldName, ICollection<object> list);
|
| 184 |
|
| 185 | /// <summary>
|
csharptest | 17699c2 | 2011-06-03 21:57:15 -0500 | [diff] [blame] | 186 | /// 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)]
|
| 190 | void ReadEnumArray(uint fieldTag, string fieldName, ICollection<IEnumLite> list, out ICollection<object> unknown, IEnumLiteMap mapping);
|
| 191 |
|
| 192 | /// <summary>
|
| 193 | /// Reads an array of primitive values into the list, if the wire-type of fieldTag is length-prefixed, it will
|
| 194 | /// read a packed array.
|
| 195 | /// </summary>
|
| 196 | [CLSCompliant(false)]
|
| 197 | void ReadEnumArray<T>(uint fieldTag, string fieldName, ICollection<T> list, out ICollection<object> unknown)
|
| 198 | where T : struct, IComparable, IFormattable, IConvertible;
|
| 199 |
|
| 200 | /// <summary>
|
| 201 | /// Reads a set of messages using the <paramref name="messageType"/> as a template. T is not guaranteed to be
|
| 202 | /// the most derived type, it is only the type specifier for the collection.
|
| 203 | /// </summary>
|
| 204 | [CLSCompliant(false)]
|
| 205 | void ReadMessageArray<T>(uint fieldTag, string fieldName, ICollection<T> list, T messageType, ExtensionRegistry registry) where T : IMessageLite;
|
| 206 |
|
| 207 | /// <summary>
|
| 208 | /// Reads a set of messages using the <paramref name="messageType"/> as a template.
|
| 209 | /// </summary>
|
| 210 | [CLSCompliant(false)]
|
| 211 | void ReadGroupArray<T>(uint fieldTag, string fieldName, ICollection<T> list, T messageType, ExtensionRegistry registry) where T : IMessageLite;
|
| 212 |
|
| 213 | /// <summary>
|
| 214 | /// Reads a field of any primitive type. Enums, groups and embedded
|
| 215 | /// messages are not handled by this method.
|
| 216 | /// </summary>
|
| 217 | bool ReadPrimitiveField(FieldType fieldType, ref object value);
|
| 218 |
|
| 219 | /// <summary>
|
| 220 | /// Returns true if the stream has reached the end of the input. This is the
|
| 221 | /// case if either the end of the underlying input source has been reached or
|
| 222 | /// the stream has reached a limit created using PushLimit.
|
| 223 | /// </summary>
|
| 224 | bool IsAtEnd { get; }
|
| 225 |
|
| 226 | /// <summary>
|
| 227 | /// Reads and discards a single field, given its tag value.
|
| 228 | /// </summary>
|
| 229 | /// <returns>false if the tag is an end-group tag, in which case
|
| 230 | /// nothing is skipped. Otherwise, returns true.</returns>
|
| 231 | [CLSCompliant(false)]
|
| 232 | bool SkipField();
|
csharptest | b00ea13 | 2011-06-10 01:09:57 -0500 | [diff] [blame] | 233 |
|
| 234 | [CLSCompliant(false)]
|
| 235 | void ReadStringArray(uint fieldTag, string fieldName, ICollection<string> list);
|
| 236 |
|
| 237 | [CLSCompliant(false)]
|
| 238 | void ReadBytesArray(uint fieldTag, string fieldName, ICollection<ByteString> list);
|
| 239 |
|
| 240 | [CLSCompliant(false)]
|
| 241 | void ReadBoolArray(uint fieldTag, string fieldName, ICollection<bool> list);
|
| 242 |
|
| 243 | [CLSCompliant(false)]
|
| 244 | void ReadInt32Array(uint fieldTag, string fieldName, ICollection<int> list);
|
| 245 |
|
| 246 | [CLSCompliant(false)]
|
| 247 | void ReadSInt32Array(uint fieldTag, string fieldName, ICollection<int> list);
|
| 248 |
|
| 249 | [CLSCompliant(false)]
|
| 250 | void ReadUInt32Array(uint fieldTag, string fieldName, ICollection<uint> list);
|
| 251 |
|
| 252 | [CLSCompliant(false)]
|
| 253 | void ReadFixed32Array(uint fieldTag, string fieldName, ICollection<uint> list);
|
| 254 |
|
| 255 | [CLSCompliant(false)]
|
| 256 | void ReadSFixed32Array(uint fieldTag, string fieldName, ICollection<int> list);
|
| 257 |
|
| 258 | [CLSCompliant(false)]
|
| 259 | void ReadInt64Array(uint fieldTag, string fieldName, ICollection<long> list);
|
| 260 |
|
| 261 | [CLSCompliant(false)]
|
| 262 | void ReadSInt64Array(uint fieldTag, string fieldName, ICollection<long> list);
|
| 263 |
|
| 264 | [CLSCompliant(false)]
|
| 265 | void ReadUInt64Array(uint fieldTag, string fieldName, ICollection<ulong> list);
|
| 266 |
|
| 267 | [CLSCompliant(false)]
|
| 268 | void ReadFixed64Array(uint fieldTag, string fieldName, ICollection<ulong> list);
|
| 269 |
|
| 270 | [CLSCompliant(false)]
|
| 271 | void ReadSFixed64Array(uint fieldTag, string fieldName, ICollection<long> list);
|
| 272 |
|
| 273 | [CLSCompliant(false)]
|
| 274 | void ReadDoubleArray(uint fieldTag, string fieldName, ICollection<double> list);
|
| 275 |
|
| 276 | [CLSCompliant(false)]
|
| 277 | void ReadFloatArray(uint fieldTag, string fieldName, ICollection<float> list);
|
csharptest | 17699c2 | 2011-06-03 21:57:15 -0500 | [diff] [blame] | 278 | }
|
| 279 | } |