1
0
mirror of https://github.com/msgpack/msgpack-c.git synced 2025-03-22 16:33:49 +01:00

csharp: add type check helper

This commit is contained in:
Kazuki Oikawa 2011-04-09 21:22:15 +09:00
parent 1d1a9d7933
commit 0b45e9442b
2 changed files with 45 additions and 4 deletions

@ -28,6 +28,47 @@ namespace msgpack
public float ValueFloat { 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 ()
{
byte[] tmp0 = _tmp0, tmp1 = _tmp1;

@ -15,7 +15,7 @@ namespace msgpack
_strm = strm;
}
public void Write (byte x)
void Write (byte x)
{
if (x < 128) {
_strm.WriteByte (x);
@ -27,7 +27,7 @@ namespace msgpack
}
}
public void Write (ushort x)
void Write (ushort x)
{
if (x < 0x100) {
Write ((byte)x);
@ -74,7 +74,7 @@ namespace msgpack
}
}
public void Write (sbyte x)
void Write (sbyte x)
{
if (x >= -32 && x <= -1) {
_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) {
Write ((sbyte)x);