A parser for a specific message type.
This delegates most behavior to the IMessage.MergeFrom implementation within the original type, but provides convenient overloads to parse from a variety of sources.
Most applications will never need to create their own instances of this type; instead, use the static Parser
property of a generated message type to obtain a parser for that type.
Details | |||
---|---|---|---|
Template Parameters |
|
Public functions |
|
---|---|
MessageParser(Func< T > factory)
|
Creates a new parser.
|
ParseDelimitedFrom(Stream input)
|
new T
Parses a length-delimited message from the given stream.
|
ParseFrom(byte[] data)
|
new T
Parses a message from a byte array.
|
ParseFrom(ByteString data)
|
new T
Parses a message from the given byte string.
|
ParseFrom(Stream input)
|
new T
Parses a message from the given stream.
|
ParseFrom(CodedInputStream input)
|
new T
Parses a message from the given coded input stream.
|
ParseJson(string json)
|
new T
Parses a message from the given JSON.
|
MessageParser( Func< T > factory )
Creates a new parser.
The factory method is effectively an optimization over using a generic constraint to require a parameterless constructor: delegates are significantly faster to execute.
Details | |||
---|---|---|---|
Parameters |
|
new T ParseDelimitedFrom( Stream input )
Parses a length-delimited message from the given stream.
The stream is expected to contain a length and then the data. Only the amount of data specified by the length will be consumed.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The parsed message.
|
new T ParseFrom( byte[] data )
Parses a message from a byte array.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The newly parsed message.
|
new T ParseFrom( ByteString data )
Parses a message from the given byte string.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The parsed message.
|
new T ParseFrom( Stream input )
Parses a message from the given stream.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The parsed message.
|
new T ParseFrom( CodedInputStream input )
Parses a message from the given coded input stream.
Details | |||
---|---|---|---|
Parameters |
|
||
Returns |
The parsed message.
|
new T ParseJson( string json )
Parses a message from the given JSON.
Details | |||||
---|---|---|---|---|---|
Parameters |
|
||||
Exceptions |
|
||||
Returns |
The parsed message.
|