From 71f203a1a0dc249a5dd241603192495badaca212 Mon Sep 17 00:00:00 2001 From: Charles Stanhope Date: Tue, 23 Nov 2010 05:47:32 +0800 Subject: Added CodedInputStream ctor symmetrical with CodedOutputStream. committer: Arnold Zokas --- src/ProtocolBuffers/CodedInputStream.cs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/ProtocolBuffers/CodedInputStream.cs') diff --git a/src/ProtocolBuffers/CodedInputStream.cs b/src/ProtocolBuffers/CodedInputStream.cs index a929df23..e20ad0bb 100644 --- a/src/ProtocolBuffers/CodedInputStream.cs +++ b/src/ProtocolBuffers/CodedInputStream.cs @@ -105,13 +105,22 @@ namespace Google.ProtocolBuffers { /// byte array. /// public static CodedInputStream CreateInstance(byte[] buf) { - return new CodedInputStream(buf); + return new CodedInputStream(buf, 0, buf.Length); } - private CodedInputStream(byte[] buffer) { - this.buffer = buffer; - this.bufferSize = buffer.Length; - this.input = null; + /// + /// Creates a new CodedInputStream that reads from the given + /// byte array slice. + /// + public static CodedInputStream CreateInstance(byte[] buf, int offset, int length) { + return new CodedInputStream(buf, offset, length); + } + + private CodedInputStream(byte[] buffer, int offset, int length) { + this.buffer = buffer; + this.bufferPos = offset; + this.bufferSize = offset + length; + this.input = null; } private CodedInputStream(Stream input) { -- cgit v1.2.3 From be4b86aeae26ef068ff7dc9df880e81dc28dab1c Mon Sep 17 00:00:00 2001 From: Jon Skeet Date: Tue, 23 Nov 2010 05:47:50 +0800 Subject: Fixed spacing committer: Arnold Zokas --- src/ProtocolBuffers/CodedInputStream.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/ProtocolBuffers/CodedInputStream.cs') diff --git a/src/ProtocolBuffers/CodedInputStream.cs b/src/ProtocolBuffers/CodedInputStream.cs index e20ad0bb..3306f309 100644 --- a/src/ProtocolBuffers/CodedInputStream.cs +++ b/src/ProtocolBuffers/CodedInputStream.cs @@ -113,14 +113,14 @@ namespace Google.ProtocolBuffers { /// byte array slice. /// public static CodedInputStream CreateInstance(byte[] buf, int offset, int length) { - return new CodedInputStream(buf, offset, length); + return new CodedInputStream(buf, offset, length); } private CodedInputStream(byte[] buffer, int offset, int length) { - this.buffer = buffer; - this.bufferPos = offset; - this.bufferSize = offset + length; - this.input = null; + this.buffer = buffer; + this.bufferPos = offset; + this.bufferSize = offset + length; + this.input = null; } private CodedInputStream(Stream input) { -- cgit v1.2.3