示例#1
0
		private bool Read( StreamingUnpacker unpacker, UnpackingMode unpackingMode )
		{
			while ( !this.IsInStreamTail() )
			{
				var data = unpacker.Unpack( this._currentSource.Stream, unpackingMode );
				if ( data != null )
				{
					this._data = data;
					return true;
				}
				else
				{
					this._mayInTail = true;
				}
			}

			return false;
		}
		private static bool ThrowInvalidHeaderException( StreamingUnpacker @this, int b, Stream source, UnpackingMode unpackingMode, out MessagePackObject? result )
		{
			throw new MessageTypeException( String.Format( CultureInfo.CurrentCulture, "Header '0x{0:x2}' is not available.", b ) );
		}
示例#3
0
		protected sealed override long? SkipCore()
		{
			if ( this._skipper == null )
			{
				this._skipper = new StreamingUnpacker();
			}

			if ( this.Read( this._skipper, UnpackingMode.SkipSubtree ) )
			{
				this._skipper = null;
				return this._data.Value.AsInt64();
			}
			else
			{
				return null;
			}
		}
		private static bool UnpackRawHeader( StreamingUnpacker @this, int b, Stream source, UnpackingMode unpackingMode, out MessagePackObject? result )
		{
			@this._next = @this._unpackRawLength;
			@this._isInCollection = false;
			@this._bytesBuffer = ( b % 2 ) == 0 ? BytesBuffer.TwoBytes : BytesBuffer.FourBytes;

			// Try to get length.
			return @this.UnpackRawLength( source, unpackingMode, out result );
		}
		private static bool UnpackArrayOrMapHeader( StreamingUnpacker @this, int b, Stream source, UnpackingMode unpackingMode, out MessagePackObject? result )
		{
			// Transit to UnpackCollectionLength
			@this._next = @this._unpackCollectionLength;
			@this._isInCollection = false;
			@this._bytesBuffer = ( b % 2 ) == 0 ? BytesBuffer.TwoBytes : BytesBuffer.FourBytes;

			if ( [email protected]( source, unpackingMode, out result ) )
			{
				// Need to get more data
				return false;
			}

			return true;
		}
		private static bool UnpackTrue( StreamingUnpacker @this, int b, Stream source, UnpackingMode unpackingMode, out MessagePackObject? result )
		{
			result = _true;
			return true;
		}
		private static bool UnpackScalarHeader( StreamingUnpacker @this, int b, Stream source, UnpackingMode unpackingMode, out MessagePackObject? result )
		{
			// Transit to UnpackScalar
			@this._next = @this._unpackScalar;
			@this._isInCollection = false;
			@this._bytesBuffer = _scalarBuffers[ b % 4 ];

			// Try to get body.
			if ( [email protected]( source, unpackingMode, out result ) )
			{
				// Need more data
				return false;
			}

			return true;
		}
		private static bool UnpackFixRawLength( StreamingUnpacker @this, int b, Stream source, UnpackingMode unpackingMode, out MessagePackObject? result )
		{
			@this.TransitToUnpackRawBytes( unchecked( ( uint )( b & 0x1f ) ) );
			// Try to get body.
			return @this.UnpackRawBytes( source, unpackingMode, out result );
		}
		private static bool UnpackEmptyRaw( StreamingUnpacker @this, int b, Stream source, UnpackingMode unpackingMode, out MessagePackObject? result )
		{
			result = _emptyBinary;
			@this._lastEmptyCollection = EmptyCollectionType.Raw;
			return true;
		}
示例#10
0
		private static bool UnpackFixArrayLength( StreamingUnpacker @this, int b, Stream source, UnpackingMode unpackingMode, out MessagePackObject? result )
		{
			var header = _headerArray[ b ];
			@this._collectionState.NewContextCollection( header, header.ValueOrLength );
			result = null;
			@this.TransitToUnpackContextCollection();
			return true;
		}
示例#11
0
		private static bool UnpackEmptyArray( StreamingUnpacker @this, int b, Stream source, UnpackingMode unpackingMode, out MessagePackObject? result )
		{
			result = new MessagePackObject( _emptyArray, true );
			@this._lastEmptyCollection = EmptyCollectionType.Array;
			return true;
		}
示例#12
0
		private static bool UnpackNegativeFixNum( StreamingUnpacker @this, int b, Stream source, UnpackingMode unpackingMode, out MessagePackObject? result )
		{
			result = _negavieFixNums[ b & 0x1f ];
			return true;
		}