Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebJobManager/HeuristicLab.ExtLibs/HeuristicLab.ProtobufCS/2.4.1/ProtobufCS/src/ProtocolBuffers/IBuilderLite.cs @ 13656

Last change on this file since 13656 was 8295, checked in by abeham, 12 years ago

#1897:

  • Removed protocol buffers 0.9.1
  • Added protocol buffers 2.4.1
  • Updated proto processing command
File size: 9.7 KB
Line 
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
37using System.IO;
38
39namespace Google.ProtocolBuffers
40{
41    /// <summary>
42    /// Non-generic interface for all members whose signatures don't require knowledge of
43    /// the type being built. The generic interface extends this one. Some methods return
44    /// either an IBuilder or an IMessage; in these cases the generic interface redeclares
45    /// the same method with a type-specific signature. Implementations are encouraged to
46    /// use explicit interface implemenation for the non-generic form. This mirrors
47    /// how IEnumerable and IEnumerable&lt;T&gt; work.
48    /// </summary>
49    public partial interface IBuilderLite
50    {
51        /// <summary>
52        /// Returns true iff all required fields in the message and all
53        /// embedded messages are set.
54        /// </summary>
55        bool IsInitialized { get; }
56
57        IBuilderLite WeakClear();
58        IBuilderLite WeakMergeFrom(IMessageLite message);
59        IBuilderLite WeakMergeFrom(ByteString data);
60        IBuilderLite WeakMergeFrom(ByteString data, ExtensionRegistry registry);
61        IBuilderLite WeakMergeFrom(ICodedInputStream input);
62        IBuilderLite WeakMergeFrom(ICodedInputStream input, ExtensionRegistry registry);
63        IMessageLite WeakBuild();
64        IMessageLite WeakBuildPartial();
65        IBuilderLite WeakClone();
66        IMessageLite WeakDefaultInstanceForType { get; }
67    }
68
69    /// <summary>
70    /// Interface implemented by Protocol Message builders.
71    /// TODO(jonskeet): Consider "SetXXX" methods returning the builder, as well as the properties.
72    /// </summary>
73    /// <typeparam name="TMessage">Type of message</typeparam>
74    /// <typeparam name="TBuilder">Type of builder</typeparam>
75    public interface IBuilderLite<TMessage, TBuilder> : IBuilderLite
76        where TMessage : IMessageLite<TMessage, TBuilder>
77        where TBuilder : IBuilderLite<TMessage, TBuilder>
78    {
79        /// <summary>
80        /// Resets all fields to their default values.
81        /// </summary>
82        TBuilder Clear();
83
84        /// <summary>
85        /// Merge the specified other message which may be a different implementation of
86        /// the same message descriptor.
87        /// </summary>
88        TBuilder MergeFrom(IMessageLite other);
89
90        /// <summary>
91        /// Constructs the final message. Once this is called, this Builder instance
92        /// is no longer valid, and calling any other method may throw a
93        /// NullReferenceException. If you need to continue working with the builder
94        /// after calling Build, call Clone first.
95        /// </summary>
96        /// <exception cref="UninitializedMessageException">the message
97        /// is missing one or more required fields; use BuildPartial to bypass
98        /// this check</exception>
99        TMessage Build();
100
101        /// <summary>
102        /// Like Build(), but does not throw an exception if the message is missing
103        /// required fields. Instead, a partial message is returned.
104        /// </summary>
105        TMessage BuildPartial();
106
107        /// <summary>
108        /// Clones this builder.
109        /// TODO(jonskeet): Explain depth of clone.
110        /// </summary>
111        TBuilder Clone();
112
113        /// <summary>
114        /// Parses a message of this type from the input and merges it with this
115        /// message, as if using MergeFrom(IMessage&lt;T&gt;).
116        /// </summary>
117        /// <remarks>
118        /// Warning: This does not verify that all required fields are present
119        /// in the input message. If you call Build() without setting all
120        /// required fields, it will throw an UninitializedMessageException.
121        /// There are a few good ways to deal with this:
122        /// <list>
123        /// <item>Call IsInitialized to verify to verify that all required fields are
124        /// set before building.</item>
125        /// <item>Parse  the message separately using one of the static ParseFrom
126        /// methods, then use MergeFrom(IMessage&lt;T&gt;) to merge it with
127        /// this one. ParseFrom will throw an InvalidProtocolBufferException
128        /// (an IOException) if some required fields are missing.
129        /// Use BuildPartial to build, which ignores missing required fields.
130        /// </list>
131        /// </remarks>
132        TBuilder MergeFrom(ICodedInputStream input);
133
134        /// <summary>
135        /// Like MergeFrom(ICodedInputStream), but also parses extensions.
136        /// The extensions that you want to be able to parse must be registered
137        /// in <paramref name="extensionRegistry"/>. Extensions not in the registry
138        /// will be treated as unknown fields.
139        /// </summary>
140        TBuilder MergeFrom(ICodedInputStream input, ExtensionRegistry extensionRegistry);
141
142        /// <summary>
143        /// Get's the message's type's default instance.
144        /// <see cref="IMessageLite{TMessage}.DefaultInstanceForType" />
145        /// </summary>
146        TMessage DefaultInstanceForType { get; }
147
148        /// <summary>
149        /// Like MergeFrom(Stream), but does not read until the end of the file.
150        /// Instead, the size of the message (encoded as a varint) is read first,
151        /// then the message data. Use Message.WriteDelimitedTo(Stream) to
152        /// write messages in this format.
153        /// </summary>
154        /// <param name="input"></param>
155        TBuilder MergeDelimitedFrom(Stream input);
156
157        /// <summary>
158        /// Like MergeDelimitedFrom(Stream) but supporting extensions.
159        /// </summary>
160        TBuilder MergeDelimitedFrom(Stream input, ExtensionRegistry extensionRegistry);
161
162        #region Convenience methods
163
164        /// <summary>
165        /// Parse <paramref name="data"/> as a message of this type and merge
166        /// it with the message being built. This is just a small wrapper around
167        /// MergeFrom(ICodedInputStream).
168        /// </summary>
169        TBuilder MergeFrom(ByteString data);
170
171        /// <summary>
172        /// Parse <paramref name="data"/> as a message of this type and merge
173        /// it with the message being built. This is just a small wrapper around
174        /// MergeFrom(ICodedInputStream, ExtensionRegistry).
175        /// </summary>
176        TBuilder MergeFrom(ByteString data, ExtensionRegistry extensionRegistry);
177
178        /// <summary>
179        /// Parse <paramref name="data"/> as a message of this type and merge
180        /// it with the message being built. This is just a small wrapper around
181        /// MergeFrom(ICodedInputStream).
182        /// </summary>
183        TBuilder MergeFrom(byte[] data);
184
185        /// <summary>
186        /// Parse <paramref name="data"/> as a message of this type and merge
187        /// it with the message being built. This is just a small wrapper around
188        /// MergeFrom(ICodedInputStream, ExtensionRegistry).
189        /// </summary>
190        TBuilder MergeFrom(byte[] data, ExtensionRegistry extensionRegistry);
191
192        /// <summary>
193        /// Parse <paramref name="input"/> as a message of this type and merge
194        /// it with the message being built. This is just a small wrapper around
195        /// MergeFrom(ICodedInputStream). Note that this method always reads
196        /// the entire input (unless it throws an exception). If you want it to
197        /// stop earlier, you will need to wrap the input in a wrapper
198        /// stream which limits reading. Or, use IMessage.WriteDelimitedTo(Stream)
199        /// to write your message and MmergeDelimitedFrom(Stream) to read it.
200        /// Despite usually reading the entire stream, this method never closes the stream.
201        /// </summary>
202        TBuilder MergeFrom(Stream input);
203
204        /// <summary>
205        /// Parse <paramref name="input"/> as a message of this type and merge
206        /// it with the message being built. This is just a small wrapper around
207        /// MergeFrom(ICodedInputStream, ExtensionRegistry).
208        /// </summary>
209        TBuilder MergeFrom(Stream input, ExtensionRegistry extensionRegistry);
210
211        #endregion
212    }
213}
Note: See TracBrowser for help on using the repository browser.