mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-26 11:46:34 +01:00
csharp: add type check helper
This commit is contained in:
parent
1d1a9d7933
commit
0b45e9442b
@ -28,6 +28,47 @@ namespace msgpack
|
|||||||
public float ValueFloat { get; private set; }
|
public float ValueFloat { get; private set; }
|
||||||
public double ValueDouble { get; private set; }
|
public double ValueDouble { get; private set; }
|
||||||
|
|
||||||
|
public bool IsSigned ()
|
||||||
|
{
|
||||||
|
return this.Type == TypePrefixes.NegativeFixNum ||
|
||||||
|
this.Type == TypePrefixes.PositiveFixNum ||
|
||||||
|
this.Type == TypePrefixes.Int8 ||
|
||||||
|
this.Type == TypePrefixes.Int16 ||
|
||||||
|
this.Type == TypePrefixes.Int32;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsSigned64 ()
|
||||||
|
{
|
||||||
|
return this.Type == TypePrefixes.Int64;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsUnsigned ()
|
||||||
|
{
|
||||||
|
return this.Type == TypePrefixes.UInt8 ||
|
||||||
|
this.Type == TypePrefixes.UInt16 ||
|
||||||
|
this.Type == TypePrefixes.UInt32;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsUnsigned64 ()
|
||||||
|
{
|
||||||
|
return this.Type == TypePrefixes.UInt64;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsRaw ()
|
||||||
|
{
|
||||||
|
return this.Type == TypePrefixes.FixRaw || this.Type == TypePrefixes.Raw16 || this.Type == TypePrefixes.Raw32;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsArray ()
|
||||||
|
{
|
||||||
|
return this.Type == TypePrefixes.FixArray || this.Type == TypePrefixes.Array16 || this.Type == TypePrefixes.Array32;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsMap ()
|
||||||
|
{
|
||||||
|
return this.Type == TypePrefixes.FixMap || this.Type == TypePrefixes.Map16 || this.Type == TypePrefixes.Map32;
|
||||||
|
}
|
||||||
|
|
||||||
public bool Read ()
|
public bool Read ()
|
||||||
{
|
{
|
||||||
byte[] tmp0 = _tmp0, tmp1 = _tmp1;
|
byte[] tmp0 = _tmp0, tmp1 = _tmp1;
|
||||||
|
@ -15,7 +15,7 @@ namespace msgpack
|
|||||||
_strm = strm;
|
_strm = strm;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Write (byte x)
|
void Write (byte x)
|
||||||
{
|
{
|
||||||
if (x < 128) {
|
if (x < 128) {
|
||||||
_strm.WriteByte (x);
|
_strm.WriteByte (x);
|
||||||
@ -27,7 +27,7 @@ namespace msgpack
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Write (ushort x)
|
void Write (ushort x)
|
||||||
{
|
{
|
||||||
if (x < 0x100) {
|
if (x < 0x100) {
|
||||||
Write ((byte)x);
|
Write ((byte)x);
|
||||||
@ -74,7 +74,7 @@ namespace msgpack
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Write (sbyte x)
|
void Write (sbyte x)
|
||||||
{
|
{
|
||||||
if (x >= -32 && x <= -1) {
|
if (x >= -32 && x <= -1) {
|
||||||
_strm.WriteByte ((byte)(0xe0 | (byte)x));
|
_strm.WriteByte ((byte)(0xe0 | (byte)x));
|
||||||
@ -88,7 +88,7 @@ namespace msgpack
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Write (short x)
|
void Write (short x)
|
||||||
{
|
{
|
||||||
if (x >= sbyte.MinValue && x <= sbyte.MaxValue) {
|
if (x >= sbyte.MinValue && x <= sbyte.MaxValue) {
|
||||||
Write ((sbyte)x);
|
Write ((sbyte)x);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user