csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 1 | #region Copyright notice and license
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 2 |
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 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.
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 34 |
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 35 | #endregion
|
| 36 |
|
| 37 | using System;
|
| 38 | using System.Collections.Generic;
|
| 39 | using System.IO;
|
| 40 | using Google.ProtocolBuffers.Collections;
|
| 41 | using Google.ProtocolBuffers.Descriptors;
|
| 42 | using Google.ProtocolBuffers.DescriptorProtos;
|
| 43 |
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 44 | namespace Google.ProtocolBuffers
|
| 45 | {
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 46 | /// <summary>
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 47 | /// Used to keep track of fields which were seen when parsing a protocol message
|
| 48 | /// but whose field numbers or types are unrecognized. This most frequently
|
| 49 | /// occurs when new fields are added to a message type and then messages containing
|
| 50 | /// those fields are read by old software that was built before the new types were
|
| 51 | /// added.
|
| 52 | ///
|
| 53 | /// Every message contains an UnknownFieldSet.
|
| 54 | ///
|
| 55 | /// Most users will never need to use this class directly.
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 56 | /// </summary>
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 57 | public sealed class UnknownFieldSet : IMessageLite
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 58 | {
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 59 | private static readonly UnknownFieldSet defaultInstance =
|
| 60 | new UnknownFieldSet(new Dictionary<int, UnknownField>());
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 61 |
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 62 | private readonly IDictionary<int, UnknownField> fields;
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 63 |
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 64 | private UnknownFieldSet(IDictionary<int, UnknownField> fields)
|
| 65 | {
|
| 66 | this.fields = fields;
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 67 | }
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 68 |
|
| 69 | /// <summary>
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 70 | /// Creates a new unknown field set builder.
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 71 | /// </summary>
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 72 | public static Builder CreateBuilder()
|
| 73 | {
|
| 74 | return new Builder();
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 75 | }
|
| 76 |
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 77 | /// <summary>
|
| 78 | /// Creates a new unknown field set builder
|
| 79 | /// and initialize it from <paramref name="original"/>.
|
| 80 | /// </summary>
|
| 81 | public static Builder CreateBuilder(UnknownFieldSet original)
|
| 82 | {
|
| 83 | return new Builder().MergeFrom(original);
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 84 | }
|
| 85 |
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 86 | public static UnknownFieldSet DefaultInstance
|
| 87 | {
|
| 88 | get { return defaultInstance; }
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 89 | }
|
| 90 |
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 91 | /// <summary>
|
| 92 | /// Returns a read-only view of the mapping from field numbers to values.
|
| 93 | /// </summary>
|
| 94 | public IDictionary<int, UnknownField> FieldDictionary
|
| 95 | {
|
| 96 | get { return Dictionaries.AsReadOnly(fields); }
|
| 97 | }
|
| 98 |
|
| 99 | /// <summary>
|
| 100 | /// Checks whether or not the given field number is present in the set.
|
| 101 | /// </summary>
|
| 102 | public bool HasField(int field)
|
| 103 | {
|
| 104 | return fields.ContainsKey(field);
|
| 105 | }
|
| 106 |
|
| 107 | /// <summary>
|
| 108 | /// Fetches a field by number, returning an empty field if not present.
|
| 109 | /// Never returns null.
|
| 110 | /// </summary>
|
| 111 | public UnknownField this[int number]
|
| 112 | {
|
| 113 | get
|
| 114 | {
|
| 115 | UnknownField ret;
|
| 116 | if (!fields.TryGetValue(number, out ret))
|
| 117 | {
|
| 118 | ret = UnknownField.DefaultInstance;
|
| 119 | }
|
| 120 | return ret;
|
| 121 | }
|
| 122 | }
|
| 123 |
|
| 124 | /// <summary>
|
| 125 | /// Serializes the set and writes it to <paramref name="output"/>.
|
| 126 | /// </summary>
|
csharptest | ffafdaa | 2011-06-03 12:58:14 -0500 | [diff] [blame] | 127 | public void WriteTo(ICodedOutputStream output)
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 128 | {
|
| 129 | foreach (KeyValuePair<int, UnknownField> entry in fields)
|
| 130 | {
|
| 131 | entry.Value.WriteTo(entry.Key, output);
|
| 132 | }
|
| 133 | }
|
| 134 |
|
| 135 | /// <summary>
|
| 136 | /// Gets the number of bytes required to encode this set.
|
| 137 | /// </summary>
|
| 138 | public int SerializedSize
|
| 139 | {
|
| 140 | get
|
| 141 | {
|
| 142 | int result = 0;
|
| 143 | foreach (KeyValuePair<int, UnknownField> entry in fields)
|
| 144 | {
|
| 145 | result += entry.Value.GetSerializedSize(entry.Key);
|
| 146 | }
|
| 147 | return result;
|
| 148 | }
|
| 149 | }
|
| 150 |
|
| 151 | /// <summary>
|
| 152 | /// Converts the set to a string in protocol buffer text format. This
|
| 153 | /// is just a trivial wrapper around TextFormat.PrintToString.
|
| 154 | /// </summary>
|
| 155 | public override String ToString()
|
| 156 | {
|
| 157 | return TextFormat.PrintToString(this);
|
| 158 | }
|
| 159 |
|
| 160 | /// <summary>
|
| 161 | /// Converts the set to a string in protocol buffer text format. This
|
| 162 | /// is just a trivial wrapper around TextFormat.PrintToString.
|
| 163 | /// </summary>
|
| 164 | public void PrintTo(TextWriter writer)
|
| 165 | {
|
| 166 | TextFormat.Print(this, writer);
|
| 167 | }
|
| 168 |
|
| 169 | /// <summary>
|
| 170 | /// Serializes the message to a ByteString and returns it. This is
|
csharptest | ffafdaa | 2011-06-03 12:58:14 -0500 | [diff] [blame] | 171 | /// just a trivial wrapper around WriteTo(ICodedOutputStream).
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 172 | /// </summary>
|
| 173 | /// <returns></returns>
|
| 174 | public ByteString ToByteString()
|
| 175 | {
|
| 176 | ByteString.CodedBuilder codedBuilder = new ByteString.CodedBuilder(SerializedSize);
|
| 177 | WriteTo(codedBuilder.CodedOutput);
|
| 178 | return codedBuilder.Build();
|
| 179 | }
|
| 180 |
|
| 181 | /// <summary>
|
| 182 | /// Serializes the message to a byte array and returns it. This is
|
csharptest | ffafdaa | 2011-06-03 12:58:14 -0500 | [diff] [blame] | 183 | /// just a trivial wrapper around WriteTo(ICodedOutputStream).
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 184 | /// </summary>
|
| 185 | /// <returns></returns>
|
| 186 | public byte[] ToByteArray()
|
| 187 | {
|
| 188 | byte[] data = new byte[SerializedSize];
|
| 189 | CodedOutputStream output = CodedOutputStream.CreateInstance(data);
|
| 190 | WriteTo(output);
|
| 191 | output.CheckNoSpaceLeft();
|
| 192 | return data;
|
| 193 | }
|
| 194 |
|
| 195 | /// <summary>
|
| 196 | /// Serializes the message and writes it to <paramref name="output"/>. This is
|
csharptest | ffafdaa | 2011-06-03 12:58:14 -0500 | [diff] [blame] | 197 | /// just a trivial wrapper around WriteTo(ICodedOutputStream).
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 198 | /// </summary>
|
| 199 | /// <param name="output"></param>
|
| 200 | public void WriteTo(Stream output)
|
| 201 | {
|
| 202 | CodedOutputStream codedOutput = CodedOutputStream.CreateInstance(output);
|
| 203 | WriteTo(codedOutput);
|
| 204 | codedOutput.Flush();
|
| 205 | }
|
| 206 |
|
| 207 | /// <summary>
|
| 208 | /// Serializes the set and writes it to <paramref name="output"/> using
|
| 209 | /// the MessageSet wire format.
|
| 210 | /// </summary>
|
csharptest | ffafdaa | 2011-06-03 12:58:14 -0500 | [diff] [blame] | 211 | public void WriteAsMessageSetTo(ICodedOutputStream output)
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 212 | {
|
| 213 | foreach (KeyValuePair<int, UnknownField> entry in fields)
|
| 214 | {
|
| 215 | entry.Value.WriteAsMessageSetExtensionTo(entry.Key, output);
|
| 216 | }
|
| 217 | }
|
| 218 |
|
| 219 | /// <summary>
|
| 220 | /// Gets the number of bytes required to encode this set using the MessageSet
|
| 221 | /// wire format.
|
| 222 | /// </summary>
|
| 223 | public int SerializedSizeAsMessageSet
|
| 224 | {
|
| 225 | get
|
| 226 | {
|
| 227 | int result = 0;
|
| 228 | foreach (KeyValuePair<int, UnknownField> entry in fields)
|
| 229 | {
|
| 230 | result += entry.Value.GetSerializedSizeAsMessageSetExtension(entry.Key);
|
| 231 | }
|
| 232 | return result;
|
| 233 | }
|
| 234 | }
|
| 235 |
|
| 236 | public override bool Equals(object other)
|
| 237 | {
|
| 238 | if (ReferenceEquals(this, other))
|
| 239 | {
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 240 | return true;
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 241 | }
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 242 | UnknownFieldSet otherSet = other as UnknownFieldSet;
|
| 243 | return otherSet != null && Dictionaries.Equals(fields, otherSet.fields);
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 244 | }
|
| 245 |
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 246 | public override int GetHashCode()
|
| 247 | {
|
| 248 | return Dictionaries.GetHashCode(fields);
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 249 | }
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 250 |
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 251 | /// <summary>
|
| 252 | /// Parses an UnknownFieldSet from the given input.
|
| 253 | /// </summary>
|
| 254 | public static UnknownFieldSet ParseFrom(CodedInputStream input)
|
| 255 | {
|
| 256 | return CreateBuilder().MergeFrom(input).Build();
|
| 257 | }
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 258 |
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 259 | /// <summary>
|
| 260 | /// Parses an UnknownFieldSet from the given data.
|
| 261 | /// </summary>
|
| 262 | public static UnknownFieldSet ParseFrom(ByteString data)
|
| 263 | {
|
| 264 | return CreateBuilder().MergeFrom(data).Build();
|
| 265 | }
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 266 |
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 267 | /// <summary>
|
| 268 | /// Parses an UnknownFieldSet from the given data.
|
| 269 | /// </summary>
|
| 270 | public static UnknownFieldSet ParseFrom(byte[] data)
|
| 271 | {
|
| 272 | return CreateBuilder().MergeFrom(data).Build();
|
| 273 | }
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 274 |
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 275 | /// <summary>
|
| 276 | /// Parses an UnknownFieldSet from the given input.
|
| 277 | /// </summary>
|
| 278 | public static UnknownFieldSet ParseFrom(Stream input)
|
| 279 | {
|
| 280 | return CreateBuilder().MergeFrom(input).Build();
|
| 281 | }
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 282 |
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 283 | #region IMessageLite Members
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 284 |
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 285 | public bool IsInitialized
|
| 286 | {
|
| 287 | get { return fields != null; }
|
| 288 | }
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 289 |
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 290 | public void WriteDelimitedTo(Stream output)
|
| 291 | {
|
| 292 | CodedOutputStream codedOutput = CodedOutputStream.CreateInstance(output);
|
| 293 | codedOutput.WriteRawVarint32((uint) SerializedSize);
|
| 294 | WriteTo(codedOutput);
|
| 295 | codedOutput.Flush();
|
| 296 | }
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 297 |
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 298 | public IBuilderLite WeakCreateBuilderForType()
|
| 299 | {
|
| 300 | return new Builder();
|
| 301 | }
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 302 |
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 303 | public IBuilderLite WeakToBuilder()
|
| 304 | {
|
| 305 | return new Builder(fields);
|
| 306 | }
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 307 |
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 308 | public IMessageLite WeakDefaultInstanceForType
|
| 309 | {
|
| 310 | get { return defaultInstance; }
|
| 311 | }
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 312 |
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 313 | #endregion
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 314 |
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 315 | /// <summary>
|
| 316 | /// Builder for UnknownFieldSets.
|
| 317 | /// </summary>
|
| 318 | public sealed class Builder : IBuilderLite
|
| 319 | {
|
| 320 | /// <summary>
|
| 321 | /// Mapping from number to field. Note that by using a SortedList we ensure
|
| 322 | /// that the fields will be serialized in ascending order.
|
| 323 | /// </summary>
|
| 324 | private IDictionary<int, UnknownField> fields;
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 325 |
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 326 | // Optimization: We keep around a builder for the last field that was
|
| 327 | // modified so that we can efficiently add to it multiple times in a
|
| 328 | // row (important when parsing an unknown repeated field).
|
| 329 | private int lastFieldNumber;
|
| 330 | private UnknownField.Builder lastField;
|
| 331 |
|
| 332 | internal Builder()
|
| 333 | {
|
| 334 | fields = new SortedList<int, UnknownField>();
|
| 335 | }
|
| 336 |
|
| 337 | internal Builder(IDictionary<int, UnknownField> dictionary)
|
| 338 | {
|
| 339 | fields = new SortedList<int, UnknownField>(dictionary);
|
| 340 | }
|
| 341 |
|
| 342 | /// <summary>
|
| 343 | /// Returns a field builder for the specified field number, including any values
|
| 344 | /// which already exist.
|
| 345 | /// </summary>
|
| 346 | private UnknownField.Builder GetFieldBuilder(int number)
|
| 347 | {
|
| 348 | if (lastField != null)
|
| 349 | {
|
| 350 | if (number == lastFieldNumber)
|
| 351 | {
|
| 352 | return lastField;
|
| 353 | }
|
| 354 | // Note: AddField() will reset lastField and lastFieldNumber.
|
| 355 | AddField(lastFieldNumber, lastField.Build());
|
| 356 | }
|
| 357 | if (number == 0)
|
| 358 | {
|
| 359 | return null;
|
| 360 | }
|
| 361 |
|
| 362 | lastField = UnknownField.CreateBuilder();
|
| 363 | UnknownField existing;
|
| 364 | if (fields.TryGetValue(number, out existing))
|
| 365 | {
|
| 366 | lastField.MergeFrom(existing);
|
| 367 | }
|
| 368 | lastFieldNumber = number;
|
| 369 | return lastField;
|
| 370 | }
|
| 371 |
|
| 372 | /// <summary>
|
| 373 | /// Build the UnknownFieldSet and return it. Once this method has been called,
|
| 374 | /// this instance will no longer be usable. Calling any method after this
|
| 375 | /// will throw a NullReferenceException.
|
| 376 | /// </summary>
|
| 377 | public UnknownFieldSet Build()
|
| 378 | {
|
| 379 | GetFieldBuilder(0); // Force lastField to be built.
|
| 380 | UnknownFieldSet result = fields.Count == 0 ? DefaultInstance : new UnknownFieldSet(fields);
|
| 381 | fields = null;
|
| 382 | return result;
|
| 383 | }
|
| 384 |
|
| 385 | /// <summary>
|
| 386 | /// Adds a field to the set. If a field with the same number already exists, it
|
| 387 | /// is replaced.
|
| 388 | /// </summary>
|
| 389 | public Builder AddField(int number, UnknownField field)
|
| 390 | {
|
| 391 | if (number == 0)
|
| 392 | {
|
| 393 | throw new ArgumentOutOfRangeException("number", "Zero is not a valid field number.");
|
| 394 | }
|
| 395 | if (lastField != null && lastFieldNumber == number)
|
| 396 | {
|
| 397 | // Discard this.
|
| 398 | lastField = null;
|
| 399 | lastFieldNumber = 0;
|
| 400 | }
|
| 401 | fields[number] = field;
|
| 402 | return this;
|
| 403 | }
|
| 404 |
|
| 405 | /// <summary>
|
| 406 | /// Resets the builder to an empty set.
|
| 407 | /// </summary>
|
| 408 | public Builder Clear()
|
| 409 | {
|
| 410 | fields.Clear();
|
| 411 | lastFieldNumber = 0;
|
| 412 | lastField = null;
|
| 413 | return this;
|
| 414 | }
|
| 415 |
|
| 416 | /// <summary>
|
| 417 | /// Parse an entire message from <paramref name="input"/> and merge
|
| 418 | /// its fields into this set.
|
| 419 | /// </summary>
|
| 420 | public Builder MergeFrom(CodedInputStream input)
|
| 421 | {
|
csharptest | 123e534 | 2011-06-03 14:15:21 -0500 | [diff] [blame] | 422 | uint tag;
|
| 423 | string name;
|
| 424 | while (input.ReadTag(out tag, out name))
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 425 | {
|
csharptest | 123e534 | 2011-06-03 14:15:21 -0500 | [diff] [blame] | 426 | if (tag == 0)
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 427 | {
|
csharptest | 123e534 | 2011-06-03 14:15:21 -0500 | [diff] [blame] | 428 | if (input.SkipField())
|
| 429 | continue; //can't merge unknown without field tag
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 430 | break;
|
| 431 | }
|
csharptest | 123e534 | 2011-06-03 14:15:21 -0500 | [diff] [blame] | 432 |
|
| 433 | if(!MergeFieldFrom(tag, input))
|
| 434 | break;
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 435 | }
|
| 436 | return this;
|
| 437 | }
|
| 438 |
|
| 439 | /// <summary>
|
| 440 | /// Parse a single field from <paramref name="input"/> and merge it
|
| 441 | /// into this set.
|
| 442 | /// </summary>
|
| 443 | /// <param name="tag">The field's tag number, which was already parsed.</param>
|
| 444 | /// <param name="input">The coded input stream containing the field</param>
|
| 445 | /// <returns>false if the tag is an "end group" tag, true otherwise</returns>
|
| 446 | [CLSCompliant(false)]
|
| 447 | public bool MergeFieldFrom(uint tag, CodedInputStream input)
|
| 448 | {
|
| 449 | int number = WireFormat.GetTagFieldNumber(tag);
|
| 450 | switch (WireFormat.GetTagWireType(tag))
|
| 451 | {
|
| 452 | case WireFormat.WireType.Varint:
|
csharptest | d2af9e9 | 2011-06-03 21:35:02 -0500 | [diff] [blame^] | 453 | {
|
| 454 | ulong uint64 = 0;
|
| 455 | if(input.ReadUInt64(ref uint64))
|
| 456 | GetFieldBuilder(number).AddVarint(uint64);
|
| 457 | return true;
|
| 458 | }
|
| 459 | case WireFormat.WireType.Fixed32:
|
| 460 | {
|
| 461 | uint uint32 = 0;
|
| 462 | if (input.ReadFixed32(ref uint32))
|
| 463 | GetFieldBuilder(number).AddFixed32(uint32);
|
| 464 | return true;
|
| 465 | }
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 466 | case WireFormat.WireType.Fixed64:
|
csharptest | d2af9e9 | 2011-06-03 21:35:02 -0500 | [diff] [blame^] | 467 | {
|
| 468 | ulong uint64 = 0;
|
| 469 | if (input.ReadFixed64(ref uint64))
|
| 470 | GetFieldBuilder(number).AddFixed64(uint64);
|
| 471 | return true;
|
| 472 | }
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 473 | case WireFormat.WireType.LengthDelimited:
|
csharptest | d2af9e9 | 2011-06-03 21:35:02 -0500 | [diff] [blame^] | 474 | {
|
| 475 | ByteString bytes = null;
|
| 476 | if (input.ReadBytes(ref bytes))
|
| 477 | GetFieldBuilder(number).AddLengthDelimited(bytes);
|
| 478 | return true;
|
| 479 | }
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 480 | case WireFormat.WireType.StartGroup:
|
| 481 | {
|
| 482 | Builder subBuilder = CreateBuilder();
|
| 483 | #pragma warning disable 0612
|
| 484 | input.ReadUnknownGroup(number, subBuilder);
|
| 485 | #pragma warning restore 0612
|
| 486 | GetFieldBuilder(number).AddGroup(subBuilder.Build());
|
| 487 | return true;
|
| 488 | }
|
| 489 | case WireFormat.WireType.EndGroup:
|
| 490 | return false;
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 491 | default:
|
| 492 | throw InvalidProtocolBufferException.InvalidWireType();
|
| 493 | }
|
| 494 | }
|
| 495 |
|
| 496 | /// <summary>
|
| 497 | /// Parses <paramref name="input"/> as an UnknownFieldSet and merge it
|
| 498 | /// with the set being built. This is just a small wrapper around
|
| 499 | /// MergeFrom(CodedInputStream).
|
| 500 | /// </summary>
|
| 501 | public Builder MergeFrom(Stream input)
|
| 502 | {
|
| 503 | CodedInputStream codedInput = CodedInputStream.CreateInstance(input);
|
| 504 | MergeFrom(codedInput);
|
| 505 | codedInput.CheckLastTagWas(0);
|
| 506 | return this;
|
| 507 | }
|
| 508 |
|
| 509 | /// <summary>
|
| 510 | /// Parses <paramref name="data"/> as an UnknownFieldSet and merge it
|
| 511 | /// with the set being built. This is just a small wrapper around
|
| 512 | /// MergeFrom(CodedInputStream).
|
| 513 | /// </summary>
|
| 514 | public Builder MergeFrom(ByteString data)
|
| 515 | {
|
| 516 | CodedInputStream input = data.CreateCodedInput();
|
| 517 | MergeFrom(input);
|
| 518 | input.CheckLastTagWas(0);
|
| 519 | return this;
|
| 520 | }
|
| 521 |
|
| 522 | /// <summary>
|
| 523 | /// Parses <paramref name="data"/> as an UnknownFieldSet and merge it
|
| 524 | /// with the set being built. This is just a small wrapper around
|
| 525 | /// MergeFrom(CodedInputStream).
|
| 526 | /// </summary>
|
| 527 | public Builder MergeFrom(byte[] data)
|
| 528 | {
|
| 529 | CodedInputStream input = CodedInputStream.CreateInstance(data);
|
| 530 | MergeFrom(input);
|
| 531 | input.CheckLastTagWas(0);
|
| 532 | return this;
|
| 533 | }
|
| 534 |
|
| 535 | /// <summary>
|
| 536 | /// Convenience method for merging a new field containing a single varint
|
| 537 | /// value. This is used in particular when an unknown enum value is
|
| 538 | /// encountered.
|
| 539 | /// </summary>
|
| 540 | [CLSCompliant(false)]
|
| 541 | public Builder MergeVarintField(int number, ulong value)
|
| 542 | {
|
| 543 | if (number == 0)
|
| 544 | {
|
| 545 | throw new ArgumentOutOfRangeException("number", "Zero is not a valid field number.");
|
| 546 | }
|
| 547 | GetFieldBuilder(number).AddVarint(value);
|
| 548 | return this;
|
| 549 | }
|
| 550 |
|
| 551 | /// <summary>
|
| 552 | /// Merges the fields from <paramref name="other"/> into this set.
|
| 553 | /// If a field number exists in both sets, the values in <paramref name="other"/>
|
| 554 | /// will be appended to the values in this set.
|
| 555 | /// </summary>
|
| 556 | public Builder MergeFrom(UnknownFieldSet other)
|
| 557 | {
|
| 558 | if (other != DefaultInstance)
|
| 559 | {
|
| 560 | foreach (KeyValuePair<int, UnknownField> entry in other.fields)
|
| 561 | {
|
| 562 | MergeField(entry.Key, entry.Value);
|
| 563 | }
|
| 564 | }
|
| 565 | return this;
|
| 566 | }
|
| 567 |
|
| 568 | /// <summary>
|
| 569 | /// Checks if the given field number is present in the set.
|
| 570 | /// </summary>
|
| 571 | public bool HasField(int number)
|
| 572 | {
|
| 573 | if (number == 0)
|
| 574 | {
|
| 575 | throw new ArgumentOutOfRangeException("number", "Zero is not a valid field number.");
|
| 576 | }
|
| 577 | return number == lastFieldNumber || fields.ContainsKey(number);
|
| 578 | }
|
| 579 |
|
| 580 | /// <summary>
|
| 581 | /// Adds a field to the unknown field set. If a field with the same
|
| 582 | /// number already exists, the two are merged.
|
| 583 | /// </summary>
|
| 584 | public Builder MergeField(int number, UnknownField field)
|
| 585 | {
|
| 586 | if (number == 0)
|
| 587 | {
|
| 588 | throw new ArgumentOutOfRangeException("number", "Zero is not a valid field number.");
|
| 589 | }
|
| 590 | if (HasField(number))
|
| 591 | {
|
| 592 | GetFieldBuilder(number).MergeFrom(field);
|
| 593 | }
|
| 594 | else
|
| 595 | {
|
| 596 | // Optimization: We could call getFieldBuilder(number).mergeFrom(field)
|
| 597 | // in this case, but that would create a copy of the Field object.
|
| 598 | // We'd rather reuse the one passed to us, so call AddField() instead.
|
| 599 | AddField(number, field);
|
| 600 | }
|
| 601 | return this;
|
| 602 | }
|
| 603 |
|
| 604 | internal void MergeFrom(CodedInputStream input, ExtensionRegistry extensionRegistry, IBuilder builder)
|
| 605 | {
|
csharptest | 123e534 | 2011-06-03 14:15:21 -0500 | [diff] [blame] | 606 | uint tag;
|
| 607 | string name;
|
| 608 | while (input.ReadTag(out tag, out name))
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 609 | {
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 610 | if (tag == 0)
|
| 611 | {
|
csharptest | 123e534 | 2011-06-03 14:15:21 -0500 | [diff] [blame] | 612 | if (input.SkipField())
|
| 613 | continue; //can't merge unknown without field tag
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 614 | break;
|
| 615 | }
|
| 616 |
|
csharptest | d2af9e9 | 2011-06-03 21:35:02 -0500 | [diff] [blame^] | 617 | if (!MergeFieldFrom(input, extensionRegistry, builder, tag, name))
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 618 | {
|
| 619 | // end group tag
|
| 620 | break;
|
| 621 | }
|
| 622 | }
|
| 623 | }
|
| 624 |
|
| 625 | /// <summary>
|
| 626 | /// Like <see cref="MergeFrom(CodedInputStream, ExtensionRegistry, IBuilder)" />
|
| 627 | /// but parses a single field.
|
| 628 | /// </summary>
|
| 629 | /// <param name="input">The input to read the field from</param>
|
| 630 | /// <param name="extensionRegistry">Registry to use when an extension field is encountered</param>
|
| 631 | /// <param name="builder">Builder to merge field into, if it's a known field</param>
|
| 632 | /// <param name="tag">The tag, which should already have been read from the input</param>
|
| 633 | /// <returns>true unless the tag is an end-group tag</returns>
|
| 634 | internal bool MergeFieldFrom(CodedInputStream input,
|
csharptest | d2af9e9 | 2011-06-03 21:35:02 -0500 | [diff] [blame^] | 635 | ExtensionRegistry extensionRegistry, IBuilder builder, uint tag, string fieldName)
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 636 | {
|
| 637 | MessageDescriptor type = builder.DescriptorForType;
|
| 638 | if (type.Options.MessageSetWireFormat && tag == WireFormat.MessageSetTag.ItemStart)
|
| 639 | {
|
| 640 | MergeMessageSetExtensionFromCodedStream(input, extensionRegistry, builder);
|
| 641 | return true;
|
| 642 | }
|
| 643 |
|
| 644 | WireFormat.WireType wireType = WireFormat.GetTagWireType(tag);
|
| 645 | int fieldNumber = WireFormat.GetTagFieldNumber(tag);
|
| 646 |
|
| 647 | FieldDescriptor field;
|
| 648 | IMessageLite defaultFieldInstance = null;
|
| 649 |
|
| 650 | if (type.IsExtensionNumber(fieldNumber))
|
| 651 | {
|
| 652 | ExtensionInfo extension = extensionRegistry[type, fieldNumber];
|
| 653 | if (extension == null)
|
| 654 | {
|
| 655 | field = null;
|
| 656 | }
|
| 657 | else
|
| 658 | {
|
| 659 | field = extension.Descriptor;
|
| 660 | defaultFieldInstance = extension.DefaultInstance;
|
| 661 | }
|
| 662 | }
|
| 663 | else
|
| 664 | {
|
| 665 | field = type.FindFieldByNumber(fieldNumber);
|
| 666 | }
|
| 667 |
|
| 668 | // Unknown field or wrong wire type. Skip.
|
| 669 | if (field == null || wireType != WireFormat.GetWireType(field))
|
| 670 | {
|
| 671 | return MergeFieldFrom(tag, input);
|
| 672 | }
|
| 673 |
|
csharptest | d2af9e9 | 2011-06-03 21:35:02 -0500 | [diff] [blame^] | 674 | switch (field.FieldType)
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 675 | {
|
csharptest | d2af9e9 | 2011-06-03 21:35:02 -0500 | [diff] [blame^] | 676 | case FieldType.Group:
|
| 677 | case FieldType.Message:
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 678 | {
|
csharptest | d2af9e9 | 2011-06-03 21:35:02 -0500 | [diff] [blame^] | 679 | IBuilderLite subBuilder = (defaultFieldInstance != null) ? defaultFieldInstance.WeakCreateBuilderForType() : builder.CreateBuilderForField(field);
|
| 680 | if (!field.IsRepeated)
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 681 | {
|
csharptest | d2af9e9 | 2011-06-03 21:35:02 -0500 | [diff] [blame^] | 682 | subBuilder.WeakMergeFrom((IMessageLite)builder[field]);
|
| 683 | if (field.FieldType == FieldType.Group)
|
| 684 | input.ReadGroup(field.FieldNumber, subBuilder, extensionRegistry);
|
| 685 | else
|
| 686 | input.ReadMessage(subBuilder, extensionRegistry);
|
| 687 | builder[field] = subBuilder.WeakBuild();
|
| 688 | }
|
| 689 | else
|
| 690 | {
|
| 691 | List<IMessageLite> list = new List<IMessageLite>();
|
| 692 | if (field.FieldType == FieldType.Group)
|
| 693 | input.ReadGroupArray(tag, fieldName, list, subBuilder.WeakDefaultInstanceForType, extensionRegistry);
|
| 694 | else
|
| 695 | input.ReadMessageArray(tag, fieldName, list, subBuilder.WeakDefaultInstanceForType, extensionRegistry);
|
| 696 |
|
| 697 | foreach (IMessageLite m in list)
|
| 698 | builder.WeakAddRepeatedField(field, m);
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 699 | return true;
|
| 700 | }
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 701 | break;
|
csharptest | d2af9e9 | 2011-06-03 21:35:02 -0500 | [diff] [blame^] | 702 | }
|
| 703 | case FieldType.Enum:
|
| 704 | {
|
| 705 | if (!field.IsRepeated)
|
| 706 | {
|
| 707 | object unknown;
|
| 708 | IEnumLite value = null;
|
| 709 | if (input.ReadEnum(ref value, out unknown, field.EnumType))
|
| 710 | builder[field] = value;
|
| 711 | else if(unknown is int)
|
| 712 | MergeVarintField(fieldNumber, (ulong)(int)unknown);
|
| 713 | }
|
| 714 | else
|
| 715 | {
|
| 716 | ICollection<object> unknown;
|
| 717 | List<IEnumLite> list = new List<IEnumLite>();
|
| 718 | input.ReadEnumArray(tag, fieldName, list, out unknown, field.EnumType);
|
| 719 |
|
| 720 | foreach (IEnumLite en in list)
|
| 721 | builder.WeakAddRepeatedField(field, en);
|
| 722 |
|
| 723 | if (unknown != null)
|
| 724 | {
|
| 725 | foreach (object oval in unknown)
|
| 726 | if (oval is int)
|
| 727 | MergeVarintField(fieldNumber, (ulong)(int)oval);
|
| 728 | }
|
| 729 | }
|
| 730 | break;
|
| 731 | }
|
| 732 | default:
|
| 733 | {
|
| 734 | if (!field.IsRepeated)
|
| 735 | {
|
| 736 | object value = null;
|
| 737 | if (input.ReadPrimitiveField(field.FieldType, ref value))
|
| 738 | builder[field] = value;
|
| 739 | }
|
| 740 | else
|
| 741 | {
|
| 742 | List<object> list = new List<object>();
|
| 743 | input.ReadPrimitiveArray(field.FieldType, tag, fieldName, list);
|
| 744 | foreach (object oval in list)
|
| 745 | builder.WeakAddRepeatedField(field, oval);
|
| 746 | }
|
| 747 | break;
|
| 748 | }
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 749 | }
|
| 750 | return true;
|
| 751 | }
|
| 752 |
|
| 753 | /// <summary>
|
| 754 | /// Called by MergeFieldFrom to parse a MessageSet extension.
|
| 755 | /// </summary>
|
| 756 | private void MergeMessageSetExtensionFromCodedStream(CodedInputStream input,
|
| 757 | ExtensionRegistry extensionRegistry, IBuilder builder)
|
| 758 | {
|
| 759 | MessageDescriptor type = builder.DescriptorForType;
|
| 760 |
|
| 761 | // The wire format for MessageSet is:
|
| 762 | // message MessageSet {
|
| 763 | // repeated group Item = 1 {
|
| 764 | // required int32 typeId = 2;
|
| 765 | // required bytes message = 3;
|
| 766 | // }
|
| 767 | // }
|
| 768 | // "typeId" is the extension's field number. The extension can only be
|
| 769 | // a message type, where "message" contains the encoded bytes of that
|
| 770 | // message.
|
| 771 | //
|
| 772 | // In practice, we will probably never see a MessageSet item in which
|
| 773 | // the message appears before the type ID, or where either field does not
|
| 774 | // appear exactly once. However, in theory such cases are valid, so we
|
| 775 | // should be prepared to accept them.
|
| 776 |
|
| 777 | int typeId = 0;
|
| 778 | ByteString rawBytes = null; // If we encounter "message" before "typeId"
|
| 779 | IBuilderLite subBuilder = null;
|
| 780 | FieldDescriptor field = null;
|
| 781 |
|
csharptest | 123e534 | 2011-06-03 14:15:21 -0500 | [diff] [blame] | 782 | uint tag;
|
| 783 | string name;
|
| 784 | while (input.ReadTag(out tag, out name))
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 785 | {
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 786 | if (tag == 0)
|
| 787 | {
|
csharptest | 123e534 | 2011-06-03 14:15:21 -0500 | [diff] [blame] | 788 | if (input.SkipField())
|
| 789 | continue; //can't merge unknown without field tag
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 790 | break;
|
| 791 | }
|
| 792 |
|
| 793 | if (tag == WireFormat.MessageSetTag.TypeID)
|
| 794 | {
|
csharptest | d2af9e9 | 2011-06-03 21:35:02 -0500 | [diff] [blame^] | 795 | typeId = 0;
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 796 | // Zero is not a valid type ID.
|
csharptest | d2af9e9 | 2011-06-03 21:35:02 -0500 | [diff] [blame^] | 797 | if (input.ReadInt32(ref typeId) && typeId != 0)
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 798 | {
|
| 799 | ExtensionInfo extension = extensionRegistry[type, typeId];
|
| 800 | if (extension != null)
|
| 801 | {
|
| 802 | field = extension.Descriptor;
|
| 803 | subBuilder = extension.DefaultInstance.WeakCreateBuilderForType();
|
| 804 | IMessageLite originalMessage = (IMessageLite) builder[field];
|
| 805 | if (originalMessage != null)
|
| 806 | {
|
| 807 | subBuilder.WeakMergeFrom(originalMessage);
|
| 808 | }
|
| 809 | if (rawBytes != null)
|
| 810 | {
|
| 811 | // We already encountered the message. Parse it now.
|
| 812 | // TODO(jonskeet): Check this is okay. It's subtly different from the Java, as it doesn't create an input stream from rawBytes.
|
| 813 | // In fact, why don't we just call MergeFrom(rawBytes)? And what about the extension registry?
|
| 814 | subBuilder.WeakMergeFrom(rawBytes.CreateCodedInput());
|
| 815 | rawBytes = null;
|
| 816 | }
|
| 817 | }
|
| 818 | else
|
| 819 | {
|
| 820 | // Unknown extension number. If we already saw data, put it
|
| 821 | // in rawBytes.
|
| 822 | if (rawBytes != null)
|
| 823 | {
|
| 824 | MergeField(typeId, UnknownField.CreateBuilder().AddLengthDelimited(rawBytes).Build());
|
| 825 | rawBytes = null;
|
| 826 | }
|
| 827 | }
|
| 828 | }
|
| 829 | }
|
| 830 | else if (tag == WireFormat.MessageSetTag.Message)
|
| 831 | {
|
csharptest | d2af9e9 | 2011-06-03 21:35:02 -0500 | [diff] [blame^] | 832 | if(subBuilder != null)
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 833 | {
|
| 834 | // We already know the type, so we can parse directly from the input
|
| 835 | // with no copying. Hooray!
|
| 836 | input.ReadMessage(subBuilder, extensionRegistry);
|
| 837 | }
|
csharptest | d2af9e9 | 2011-06-03 21:35:02 -0500 | [diff] [blame^] | 838 | else if (input.ReadBytes(ref rawBytes))
|
| 839 | {
|
| 840 | if (typeId != 0)
|
| 841 | {
|
| 842 | // We don't know how to parse this. Ignore it.
|
| 843 | MergeField(typeId,
|
| 844 | UnknownField.CreateBuilder().AddLengthDelimited(rawBytes).Build());
|
| 845 | }
|
| 846 | }
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 847 | }
|
| 848 | else
|
| 849 | {
|
| 850 | // Unknown tag. Skip it.
|
csharptest | 123e534 | 2011-06-03 14:15:21 -0500 | [diff] [blame] | 851 | if (!input.SkipField())
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 852 | {
|
| 853 | break; // end of group
|
| 854 | }
|
| 855 | }
|
| 856 | }
|
| 857 |
|
| 858 | input.CheckLastTagWas(WireFormat.MessageSetTag.ItemEnd);
|
| 859 |
|
| 860 | if (subBuilder != null)
|
| 861 | {
|
| 862 | builder[field] = subBuilder.WeakBuild();
|
| 863 | }
|
| 864 | }
|
| 865 |
|
| 866 | #region IBuilderLite Members
|
| 867 |
|
| 868 | bool IBuilderLite.IsInitialized
|
| 869 | {
|
| 870 | get { return fields != null; }
|
| 871 | }
|
| 872 |
|
| 873 | IBuilderLite IBuilderLite.WeakClear()
|
| 874 | {
|
| 875 | return Clear();
|
| 876 | }
|
| 877 |
|
| 878 | IBuilderLite IBuilderLite.WeakMergeFrom(IMessageLite message)
|
| 879 | {
|
| 880 | return MergeFrom((UnknownFieldSet) message);
|
| 881 | }
|
| 882 |
|
| 883 | IBuilderLite IBuilderLite.WeakMergeFrom(ByteString data)
|
| 884 | {
|
| 885 | return MergeFrom(data);
|
| 886 | }
|
| 887 |
|
| 888 | IBuilderLite IBuilderLite.WeakMergeFrom(ByteString data, ExtensionRegistry registry)
|
| 889 | {
|
| 890 | return MergeFrom(data);
|
| 891 | }
|
| 892 |
|
| 893 | IBuilderLite IBuilderLite.WeakMergeFrom(CodedInputStream input)
|
| 894 | {
|
| 895 | return MergeFrom(input);
|
| 896 | }
|
| 897 |
|
| 898 | IBuilderLite IBuilderLite.WeakMergeFrom(CodedInputStream input, ExtensionRegistry registry)
|
| 899 | {
|
| 900 | return MergeFrom(input);
|
| 901 | }
|
| 902 |
|
| 903 | IMessageLite IBuilderLite.WeakBuild()
|
| 904 | {
|
| 905 | return Build();
|
| 906 | }
|
| 907 |
|
| 908 | IMessageLite IBuilderLite.WeakBuildPartial()
|
| 909 | {
|
| 910 | return Build();
|
| 911 | }
|
| 912 |
|
| 913 | IBuilderLite IBuilderLite.WeakClone()
|
| 914 | {
|
| 915 | return Build().WeakToBuilder();
|
| 916 | }
|
| 917 |
|
| 918 | IMessageLite IBuilderLite.WeakDefaultInstanceForType
|
| 919 | {
|
| 920 | get { return DefaultInstance; }
|
| 921 | }
|
| 922 |
|
| 923 | #endregion
|
| 924 | }
|
csharptest | d965c66 | 2011-05-20 13:57:07 -0500 | [diff] [blame] | 925 | }
|
csharptest | 71f662c | 2011-05-20 15:15:34 -0500 | [diff] [blame] | 926 | } |