using System; using System.Text; namespace UniJSON { public struct MsgPackValue: IListTreeItem, IValue { public int ParentIndex { get; private set; } public ArraySegment Bytes { get; private set; } public MsgPackType Format { get { return (MsgPackType)Bytes.Get(0); } } public ValueNodeType ValueType { get { switch (Format) { case MsgPackType.NIL: return ValueNodeType.Null; case MsgPackType.TRUE: case MsgPackType.FALSE: return ValueNodeType.Boolean; default: if (Format.IsArray()) { return ValueNodeType.Array; } else if (Format.IsMap()) { return ValueNodeType.Object; } else if (Format.IsInteger()) { return ValueNodeType.Integer; } else if (Format.IsFloat()) { return ValueNodeType.Number; } else if (Format.IsString()) { return ValueNodeType.String; } else if (Format.IsBinary()) { return ValueNodeType.Binary; } else { throw new NotImplementedException(); } } } } public MsgPackValue(ArraySegment segment, int parentIndex) : this() { Bytes = segment; ParentIndex = parentIndex; } public MsgPackValue New(ArraySegment bytes, ValueNodeType valueType, int parentIndex) { throw new NotImplementedException(); } public MsgPackValue Key(Utf8String key, int parentIndex) { throw new NotImplementedException(); } /// /// ArrayとMap以外のタイプのペイロードを得る /// /// public ArraySegment GetBody() { var bytes = Bytes; var formatType = Format; switch (formatType) { case MsgPackType.FIX_STR: return bytes.Advance(1).Take(0); case MsgPackType.FIX_STR_0x01: return bytes.Advance(1).Take(1); case MsgPackType.FIX_STR_0x02: return bytes.Advance(1).Take(2); case MsgPackType.FIX_STR_0x03: return bytes.Advance(1).Take(3); case MsgPackType.FIX_STR_0x04: return bytes.Advance(1).Take(4); case MsgPackType.FIX_STR_0x05: return bytes.Advance(1).Take(5); case MsgPackType.FIX_STR_0x06: return bytes.Advance(1).Take(6); case MsgPackType.FIX_STR_0x07: return bytes.Advance(1).Take(7); case MsgPackType.FIX_STR_0x08: return bytes.Advance(1).Take(8); case MsgPackType.FIX_STR_0x09: return bytes.Advance(1).Take(9); case MsgPackType.FIX_STR_0x0A: return bytes.Advance(1).Take(10); case MsgPackType.FIX_STR_0x0B: return bytes.Advance(1).Take(11); case MsgPackType.FIX_STR_0x0C: return bytes.Advance(1).Take(12); case MsgPackType.FIX_STR_0x0D: return bytes.Advance(1).Take(13); case MsgPackType.FIX_STR_0x0E: return bytes.Advance(1).Take(14); case MsgPackType.FIX_STR_0x0F: return bytes.Advance(1).Take(15); case MsgPackType.FIX_STR_0x10: return bytes.Advance(1).Take(16); case MsgPackType.FIX_STR_0x11: return bytes.Advance(1).Take(17); case MsgPackType.FIX_STR_0x12: return bytes.Advance(1).Take(18); case MsgPackType.FIX_STR_0x13: return bytes.Advance(1).Take(19); case MsgPackType.FIX_STR_0x14: return bytes.Advance(1).Take(20); case MsgPackType.FIX_STR_0x15: return bytes.Advance(1).Take(21); case MsgPackType.FIX_STR_0x16: return bytes.Advance(1).Take(22); case MsgPackType.FIX_STR_0x17: return bytes.Advance(1).Take(23); case MsgPackType.FIX_STR_0x18: return bytes.Advance(1).Take(24); case MsgPackType.FIX_STR_0x19: return bytes.Advance(1).Take(25); case MsgPackType.FIX_STR_0x1A: return bytes.Advance(1).Take(26); case MsgPackType.FIX_STR_0x1B: return bytes.Advance(1).Take(27); case MsgPackType.FIX_STR_0x1C: return bytes.Advance(1).Take(28); case MsgPackType.FIX_STR_0x1D: return bytes.Advance(1).Take(29); case MsgPackType.FIX_STR_0x1E: return bytes.Advance(1).Take(30); case MsgPackType.FIX_STR_0x1F: return bytes.Advance(1).Take(31); case MsgPackType.STR8: case MsgPackType.BIN8: { var count = bytes.Get(1); return bytes.Advance(1 + 1).Take(count); } case MsgPackType.STR16: case MsgPackType.BIN16: { var count = EndianConverter.NetworkByteWordToUnsignedNativeByteOrder(bytes.Advance(1)); return bytes.Advance(1 + 2).Take(count); } case MsgPackType.STR32: case MsgPackType.BIN32: { var count = EndianConverter.NetworkByteDWordToUnsignedNativeByteOrder(bytes.Advance(1)); return bytes.Advance(1 + 4).Take((int)count); } case MsgPackType.NIL: case MsgPackType.TRUE: case MsgPackType.FALSE: case MsgPackType.POSITIVE_FIXNUM: case MsgPackType.POSITIVE_FIXNUM_0x01: case MsgPackType.POSITIVE_FIXNUM_0x02: case MsgPackType.POSITIVE_FIXNUM_0x03: case MsgPackType.POSITIVE_FIXNUM_0x04: case MsgPackType.POSITIVE_FIXNUM_0x05: case MsgPackType.POSITIVE_FIXNUM_0x06: case MsgPackType.POSITIVE_FIXNUM_0x07: case MsgPackType.POSITIVE_FIXNUM_0x08: case MsgPackType.POSITIVE_FIXNUM_0x09: case MsgPackType.POSITIVE_FIXNUM_0x0A: case MsgPackType.POSITIVE_FIXNUM_0x0B: case MsgPackType.POSITIVE_FIXNUM_0x0C: case MsgPackType.POSITIVE_FIXNUM_0x0D: case MsgPackType.POSITIVE_FIXNUM_0x0E: case MsgPackType.POSITIVE_FIXNUM_0x0F: case MsgPackType.POSITIVE_FIXNUM_0x10: case MsgPackType.POSITIVE_FIXNUM_0x11: case MsgPackType.POSITIVE_FIXNUM_0x12: case MsgPackType.POSITIVE_FIXNUM_0x13: case MsgPackType.POSITIVE_FIXNUM_0x14: case MsgPackType.POSITIVE_FIXNUM_0x15: case MsgPackType.POSITIVE_FIXNUM_0x16: case MsgPackType.POSITIVE_FIXNUM_0x17: case MsgPackType.POSITIVE_FIXNUM_0x18: case MsgPackType.POSITIVE_FIXNUM_0x19: case MsgPackType.POSITIVE_FIXNUM_0x1A: case MsgPackType.POSITIVE_FIXNUM_0x1B: case MsgPackType.POSITIVE_FIXNUM_0x1C: case MsgPackType.POSITIVE_FIXNUM_0x1D: case MsgPackType.POSITIVE_FIXNUM_0x1E: case MsgPackType.POSITIVE_FIXNUM_0x1F: case MsgPackType.POSITIVE_FIXNUM_0x20: case MsgPackType.POSITIVE_FIXNUM_0x21: case MsgPackType.POSITIVE_FIXNUM_0x22: case MsgPackType.POSITIVE_FIXNUM_0x23: case MsgPackType.POSITIVE_FIXNUM_0x24: case MsgPackType.POSITIVE_FIXNUM_0x25: case MsgPackType.POSITIVE_FIXNUM_0x26: case MsgPackType.POSITIVE_FIXNUM_0x27: case MsgPackType.POSITIVE_FIXNUM_0x28: case MsgPackType.POSITIVE_FIXNUM_0x29: case MsgPackType.POSITIVE_FIXNUM_0x2A: case MsgPackType.POSITIVE_FIXNUM_0x2B: case MsgPackType.POSITIVE_FIXNUM_0x2C: case MsgPackType.POSITIVE_FIXNUM_0x2D: case MsgPackType.POSITIVE_FIXNUM_0x2E: case MsgPackType.POSITIVE_FIXNUM_0x2F: case MsgPackType.POSITIVE_FIXNUM_0x30: case MsgPackType.POSITIVE_FIXNUM_0x31: case MsgPackType.POSITIVE_FIXNUM_0x32: case MsgPackType.POSITIVE_FIXNUM_0x33: case MsgPackType.POSITIVE_FIXNUM_0x34: case MsgPackType.POSITIVE_FIXNUM_0x35: case MsgPackType.POSITIVE_FIXNUM_0x36: case MsgPackType.POSITIVE_FIXNUM_0x37: case MsgPackType.POSITIVE_FIXNUM_0x38: case MsgPackType.POSITIVE_FIXNUM_0x39: case MsgPackType.POSITIVE_FIXNUM_0x3A: case MsgPackType.POSITIVE_FIXNUM_0x3B: case MsgPackType.POSITIVE_FIXNUM_0x3C: case MsgPackType.POSITIVE_FIXNUM_0x3D: case MsgPackType.POSITIVE_FIXNUM_0x3E: case MsgPackType.POSITIVE_FIXNUM_0x3F: case MsgPackType.POSITIVE_FIXNUM_0x40: case MsgPackType.POSITIVE_FIXNUM_0x41: case MsgPackType.POSITIVE_FIXNUM_0x42: case MsgPackType.POSITIVE_FIXNUM_0x43: case MsgPackType.POSITIVE_FIXNUM_0x44: case MsgPackType.POSITIVE_FIXNUM_0x45: case MsgPackType.POSITIVE_FIXNUM_0x46: case MsgPackType.POSITIVE_FIXNUM_0x47: case MsgPackType.POSITIVE_FIXNUM_0x48: case MsgPackType.POSITIVE_FIXNUM_0x49: case MsgPackType.POSITIVE_FIXNUM_0x4A: case MsgPackType.POSITIVE_FIXNUM_0x4B: case MsgPackType.POSITIVE_FIXNUM_0x4C: case MsgPackType.POSITIVE_FIXNUM_0x4D: case MsgPackType.POSITIVE_FIXNUM_0x4E: case MsgPackType.POSITIVE_FIXNUM_0x4F: case MsgPackType.POSITIVE_FIXNUM_0x50: case MsgPackType.POSITIVE_FIXNUM_0x51: case MsgPackType.POSITIVE_FIXNUM_0x52: case MsgPackType.POSITIVE_FIXNUM_0x53: case MsgPackType.POSITIVE_FIXNUM_0x54: case MsgPackType.POSITIVE_FIXNUM_0x55: case MsgPackType.POSITIVE_FIXNUM_0x56: case MsgPackType.POSITIVE_FIXNUM_0x57: case MsgPackType.POSITIVE_FIXNUM_0x58: case MsgPackType.POSITIVE_FIXNUM_0x59: case MsgPackType.POSITIVE_FIXNUM_0x5A: case MsgPackType.POSITIVE_FIXNUM_0x5B: case MsgPackType.POSITIVE_FIXNUM_0x5C: case MsgPackType.POSITIVE_FIXNUM_0x5D: case MsgPackType.POSITIVE_FIXNUM_0x5E: case MsgPackType.POSITIVE_FIXNUM_0x5F: case MsgPackType.POSITIVE_FIXNUM_0x60: case MsgPackType.POSITIVE_FIXNUM_0x61: case MsgPackType.POSITIVE_FIXNUM_0x62: case MsgPackType.POSITIVE_FIXNUM_0x63: case MsgPackType.POSITIVE_FIXNUM_0x64: case MsgPackType.POSITIVE_FIXNUM_0x65: case MsgPackType.POSITIVE_FIXNUM_0x66: case MsgPackType.POSITIVE_FIXNUM_0x67: case MsgPackType.POSITIVE_FIXNUM_0x68: case MsgPackType.POSITIVE_FIXNUM_0x69: case MsgPackType.POSITIVE_FIXNUM_0x6A: case MsgPackType.POSITIVE_FIXNUM_0x6B: case MsgPackType.POSITIVE_FIXNUM_0x6C: case MsgPackType.POSITIVE_FIXNUM_0x6D: case MsgPackType.POSITIVE_FIXNUM_0x6E: case MsgPackType.POSITIVE_FIXNUM_0x6F: case MsgPackType.POSITIVE_FIXNUM_0x70: case MsgPackType.POSITIVE_FIXNUM_0x71: case MsgPackType.POSITIVE_FIXNUM_0x72: case MsgPackType.POSITIVE_FIXNUM_0x73: case MsgPackType.POSITIVE_FIXNUM_0x74: case MsgPackType.POSITIVE_FIXNUM_0x75: case MsgPackType.POSITIVE_FIXNUM_0x76: case MsgPackType.POSITIVE_FIXNUM_0x77: case MsgPackType.POSITIVE_FIXNUM_0x78: case MsgPackType.POSITIVE_FIXNUM_0x79: case MsgPackType.POSITIVE_FIXNUM_0x7A: case MsgPackType.POSITIVE_FIXNUM_0x7B: case MsgPackType.POSITIVE_FIXNUM_0x7C: case MsgPackType.POSITIVE_FIXNUM_0x7D: case MsgPackType.POSITIVE_FIXNUM_0x7E: case MsgPackType.POSITIVE_FIXNUM_0x7F: case MsgPackType.NEGATIVE_FIXNUM: case MsgPackType.NEGATIVE_FIXNUM_0x01: case MsgPackType.NEGATIVE_FIXNUM_0x02: case MsgPackType.NEGATIVE_FIXNUM_0x03: case MsgPackType.NEGATIVE_FIXNUM_0x04: case MsgPackType.NEGATIVE_FIXNUM_0x05: case MsgPackType.NEGATIVE_FIXNUM_0x06: case MsgPackType.NEGATIVE_FIXNUM_0x07: case MsgPackType.NEGATIVE_FIXNUM_0x08: case MsgPackType.NEGATIVE_FIXNUM_0x09: case MsgPackType.NEGATIVE_FIXNUM_0x0A: case MsgPackType.NEGATIVE_FIXNUM_0x0B: case MsgPackType.NEGATIVE_FIXNUM_0x0C: case MsgPackType.NEGATIVE_FIXNUM_0x0D: case MsgPackType.NEGATIVE_FIXNUM_0x0E: case MsgPackType.NEGATIVE_FIXNUM_0x0F: case MsgPackType.NEGATIVE_FIXNUM_0x10: case MsgPackType.NEGATIVE_FIXNUM_0x11: case MsgPackType.NEGATIVE_FIXNUM_0x12: case MsgPackType.NEGATIVE_FIXNUM_0x13: case MsgPackType.NEGATIVE_FIXNUM_0x14: case MsgPackType.NEGATIVE_FIXNUM_0x15: case MsgPackType.NEGATIVE_FIXNUM_0x16: case MsgPackType.NEGATIVE_FIXNUM_0x17: case MsgPackType.NEGATIVE_FIXNUM_0x18: case MsgPackType.NEGATIVE_FIXNUM_0x19: case MsgPackType.NEGATIVE_FIXNUM_0x1A: case MsgPackType.NEGATIVE_FIXNUM_0x1B: case MsgPackType.NEGATIVE_FIXNUM_0x1C: case MsgPackType.NEGATIVE_FIXNUM_0x1D: case MsgPackType.NEGATIVE_FIXNUM_0x1E: case MsgPackType.NEGATIVE_FIXNUM_0x1F: return bytes.Advance(1).Take(0); case MsgPackType.UINT8: case MsgPackType.INT8: return bytes.Advance(1).Take(1); case MsgPackType.UINT16: case MsgPackType.INT16: return bytes.Advance(1).Take(2); case MsgPackType.UINT32: case MsgPackType.INT32: case MsgPackType.FLOAT: return bytes.Advance(1).Take(4); case MsgPackType.UINT64: case MsgPackType.INT64: case MsgPackType.DOUBLE: return bytes.Advance(1).Take(8); case MsgPackType.FIX_EXT_1: return bytes.Advance(2).Take(1); case MsgPackType.FIX_EXT_2: return bytes.Advance(2).Take(2); case MsgPackType.FIX_EXT_4: return bytes.Advance(2).Take(4); case MsgPackType.FIX_EXT_8: return bytes.Advance(2).Take(8); case MsgPackType.FIX_EXT_16: return bytes.Advance(2).Take(16); case MsgPackType.EXT8: { var count = bytes.Get(1); return bytes.Advance(1 + 1 + 1).Take(count); } case MsgPackType.EXT16: { var count = EndianConverter.NetworkByteWordToUnsignedNativeByteOrder(bytes.Advance(1)); return bytes.Advance(1 + 2 + 1).Take(count); } case MsgPackType.EXT32: { var count = EndianConverter.NetworkByteDWordToUnsignedNativeByteOrder(bytes.Advance(1)); return bytes.Advance(1 + 4 + 1).Take((int)count); } default: throw new ArgumentException("unknown type: " + formatType); } } public SByte GetExtType() { var formatType = Format; switch (formatType) { case MsgPackType.FIX_EXT_4: return (SByte)Bytes.Get(1); } throw new NotImplementedException(); } /// /// ArrayとMap以外のタイプの値を得る /// /// public T GetValue() { var formatType = Format; switch (formatType) { case MsgPackType.NIL: return GenericCast.Null(); case MsgPackType.TRUE: return GenericCast.Const(true)(); case MsgPackType.FALSE: return GenericCast.Const(false)(); case MsgPackType.POSITIVE_FIXNUM: return GenericCast.Const(0)(); case MsgPackType.POSITIVE_FIXNUM_0x01: return GenericCast.Const(1)(); case MsgPackType.POSITIVE_FIXNUM_0x02: return GenericCast.Const(2)(); case MsgPackType.POSITIVE_FIXNUM_0x03: return GenericCast.Const(3)(); case MsgPackType.POSITIVE_FIXNUM_0x04: return GenericCast.Const(4)(); case MsgPackType.POSITIVE_FIXNUM_0x05: return GenericCast.Const(5)(); case MsgPackType.POSITIVE_FIXNUM_0x06: return GenericCast.Const(6)(); case MsgPackType.POSITIVE_FIXNUM_0x07: return GenericCast.Const(7)(); case MsgPackType.POSITIVE_FIXNUM_0x08: return GenericCast.Const(8)(); case MsgPackType.POSITIVE_FIXNUM_0x09: return GenericCast.Const(9)(); case MsgPackType.POSITIVE_FIXNUM_0x0A: return GenericCast.Const(10)(); case MsgPackType.POSITIVE_FIXNUM_0x0B: return GenericCast.Const(11)(); case MsgPackType.POSITIVE_FIXNUM_0x0C: return GenericCast.Const(12)(); case MsgPackType.POSITIVE_FIXNUM_0x0D: return GenericCast.Const(13)(); case MsgPackType.POSITIVE_FIXNUM_0x0E: return GenericCast.Const(14)(); case MsgPackType.POSITIVE_FIXNUM_0x0F: return GenericCast.Const(15)(); case MsgPackType.POSITIVE_FIXNUM_0x10: return GenericCast.Const(16)(); case MsgPackType.POSITIVE_FIXNUM_0x11: return GenericCast.Const(17)(); case MsgPackType.POSITIVE_FIXNUM_0x12: return GenericCast.Const(18)(); case MsgPackType.POSITIVE_FIXNUM_0x13: return GenericCast.Const(19)(); case MsgPackType.POSITIVE_FIXNUM_0x14: return GenericCast.Const(20)(); case MsgPackType.POSITIVE_FIXNUM_0x15: return GenericCast.Const(21)(); case MsgPackType.POSITIVE_FIXNUM_0x16: return GenericCast.Const(22)(); case MsgPackType.POSITIVE_FIXNUM_0x17: return GenericCast.Const(23)(); case MsgPackType.POSITIVE_FIXNUM_0x18: return GenericCast.Const(24)(); case MsgPackType.POSITIVE_FIXNUM_0x19: return GenericCast.Const(25)(); case MsgPackType.POSITIVE_FIXNUM_0x1A: return GenericCast.Const(26)(); case MsgPackType.POSITIVE_FIXNUM_0x1B: return GenericCast.Const(27)(); case MsgPackType.POSITIVE_FIXNUM_0x1C: return GenericCast.Const(28)(); case MsgPackType.POSITIVE_FIXNUM_0x1D: return GenericCast.Const(29)(); case MsgPackType.POSITIVE_FIXNUM_0x1E: return GenericCast.Const(30)(); case MsgPackType.POSITIVE_FIXNUM_0x1F: return GenericCast.Const(31)(); case MsgPackType.POSITIVE_FIXNUM_0x20: return GenericCast.Const(32)(); case MsgPackType.POSITIVE_FIXNUM_0x21: return GenericCast.Const(33)(); case MsgPackType.POSITIVE_FIXNUM_0x22: return GenericCast.Const(34)(); case MsgPackType.POSITIVE_FIXNUM_0x23: return GenericCast.Const(35)(); case MsgPackType.POSITIVE_FIXNUM_0x24: return GenericCast.Const(36)(); case MsgPackType.POSITIVE_FIXNUM_0x25: return GenericCast.Const(37)(); case MsgPackType.POSITIVE_FIXNUM_0x26: return GenericCast.Const(38)(); case MsgPackType.POSITIVE_FIXNUM_0x27: return GenericCast.Const(39)(); case MsgPackType.POSITIVE_FIXNUM_0x28: return GenericCast.Const(40)(); case MsgPackType.POSITIVE_FIXNUM_0x29: return GenericCast.Const(41)(); case MsgPackType.POSITIVE_FIXNUM_0x2A: return GenericCast.Const(42)(); case MsgPackType.POSITIVE_FIXNUM_0x2B: return GenericCast.Const(43)(); case MsgPackType.POSITIVE_FIXNUM_0x2C: return GenericCast.Const(44)(); case MsgPackType.POSITIVE_FIXNUM_0x2D: return GenericCast.Const(45)(); case MsgPackType.POSITIVE_FIXNUM_0x2E: return GenericCast.Const(46)(); case MsgPackType.POSITIVE_FIXNUM_0x2F: return GenericCast.Const(47)(); case MsgPackType.POSITIVE_FIXNUM_0x30: return GenericCast.Const(48)(); case MsgPackType.POSITIVE_FIXNUM_0x31: return GenericCast.Const(49)(); case MsgPackType.POSITIVE_FIXNUM_0x32: return GenericCast.Const(50)(); case MsgPackType.POSITIVE_FIXNUM_0x33: return GenericCast.Const(51)(); case MsgPackType.POSITIVE_FIXNUM_0x34: return GenericCast.Const(52)(); case MsgPackType.POSITIVE_FIXNUM_0x35: return GenericCast.Const(53)(); case MsgPackType.POSITIVE_FIXNUM_0x36: return GenericCast.Const(54)(); case MsgPackType.POSITIVE_FIXNUM_0x37: return GenericCast.Const(55)(); case MsgPackType.POSITIVE_FIXNUM_0x38: return GenericCast.Const(56)(); case MsgPackType.POSITIVE_FIXNUM_0x39: return GenericCast.Const(57)(); case MsgPackType.POSITIVE_FIXNUM_0x3A: return GenericCast.Const(58)(); case MsgPackType.POSITIVE_FIXNUM_0x3B: return GenericCast.Const(59)(); case MsgPackType.POSITIVE_FIXNUM_0x3C: return GenericCast.Const(60)(); case MsgPackType.POSITIVE_FIXNUM_0x3D: return GenericCast.Const(61)(); case MsgPackType.POSITIVE_FIXNUM_0x3E: return GenericCast.Const(62)(); case MsgPackType.POSITIVE_FIXNUM_0x3F: return GenericCast.Const(63)(); case MsgPackType.POSITIVE_FIXNUM_0x40: return GenericCast.Const(64)(); case MsgPackType.POSITIVE_FIXNUM_0x41: return GenericCast.Const(65)(); case MsgPackType.POSITIVE_FIXNUM_0x42: return GenericCast.Const(66)(); case MsgPackType.POSITIVE_FIXNUM_0x43: return GenericCast.Const(67)(); case MsgPackType.POSITIVE_FIXNUM_0x44: return GenericCast.Const(68)(); case MsgPackType.POSITIVE_FIXNUM_0x45: return GenericCast.Const(69)(); case MsgPackType.POSITIVE_FIXNUM_0x46: return GenericCast.Const(70)(); case MsgPackType.POSITIVE_FIXNUM_0x47: return GenericCast.Const(71)(); case MsgPackType.POSITIVE_FIXNUM_0x48: return GenericCast.Const(72)(); case MsgPackType.POSITIVE_FIXNUM_0x49: return GenericCast.Const(73)(); case MsgPackType.POSITIVE_FIXNUM_0x4A: return GenericCast.Const(74)(); case MsgPackType.POSITIVE_FIXNUM_0x4B: return GenericCast.Const(75)(); case MsgPackType.POSITIVE_FIXNUM_0x4C: return GenericCast.Const(76)(); case MsgPackType.POSITIVE_FIXNUM_0x4D: return GenericCast.Const(77)(); case MsgPackType.POSITIVE_FIXNUM_0x4E: return GenericCast.Const(78)(); case MsgPackType.POSITIVE_FIXNUM_0x4F: return GenericCast.Const(79)(); case MsgPackType.POSITIVE_FIXNUM_0x50: return GenericCast.Const(80)(); case MsgPackType.POSITIVE_FIXNUM_0x51: return GenericCast.Const(81)(); case MsgPackType.POSITIVE_FIXNUM_0x52: return GenericCast.Const(82)(); case MsgPackType.POSITIVE_FIXNUM_0x53: return GenericCast.Const(83)(); case MsgPackType.POSITIVE_FIXNUM_0x54: return GenericCast.Const(84)(); case MsgPackType.POSITIVE_FIXNUM_0x55: return GenericCast.Const(85)(); case MsgPackType.POSITIVE_FIXNUM_0x56: return GenericCast.Const(86)(); case MsgPackType.POSITIVE_FIXNUM_0x57: return GenericCast.Const(87)(); case MsgPackType.POSITIVE_FIXNUM_0x58: return GenericCast.Const(88)(); case MsgPackType.POSITIVE_FIXNUM_0x59: return GenericCast.Const(89)(); case MsgPackType.POSITIVE_FIXNUM_0x5A: return GenericCast.Const(90)(); case MsgPackType.POSITIVE_FIXNUM_0x5B: return GenericCast.Const(91)(); case MsgPackType.POSITIVE_FIXNUM_0x5C: return GenericCast.Const(92)(); case MsgPackType.POSITIVE_FIXNUM_0x5D: return GenericCast.Const(93)(); case MsgPackType.POSITIVE_FIXNUM_0x5E: return GenericCast.Const(94)(); case MsgPackType.POSITIVE_FIXNUM_0x5F: return GenericCast.Const(95)(); case MsgPackType.POSITIVE_FIXNUM_0x60: return GenericCast.Const(96)(); case MsgPackType.POSITIVE_FIXNUM_0x61: return GenericCast.Const(97)(); case MsgPackType.POSITIVE_FIXNUM_0x62: return GenericCast.Const(98)(); case MsgPackType.POSITIVE_FIXNUM_0x63: return GenericCast.Const(99)(); case MsgPackType.POSITIVE_FIXNUM_0x64: return GenericCast.Const(100)(); case MsgPackType.POSITIVE_FIXNUM_0x65: return GenericCast.Const(101)(); case MsgPackType.POSITIVE_FIXNUM_0x66: return GenericCast.Const(102)(); case MsgPackType.POSITIVE_FIXNUM_0x67: return GenericCast.Const(103)(); case MsgPackType.POSITIVE_FIXNUM_0x68: return GenericCast.Const(104)(); case MsgPackType.POSITIVE_FIXNUM_0x69: return GenericCast.Const(105)(); case MsgPackType.POSITIVE_FIXNUM_0x6A: return GenericCast.Const(106)(); case MsgPackType.POSITIVE_FIXNUM_0x6B: return GenericCast.Const(107)(); case MsgPackType.POSITIVE_FIXNUM_0x6C: return GenericCast.Const(108)(); case MsgPackType.POSITIVE_FIXNUM_0x6D: return GenericCast.Const(109)(); case MsgPackType.POSITIVE_FIXNUM_0x6E: return GenericCast.Const(110)(); case MsgPackType.POSITIVE_FIXNUM_0x6F: return GenericCast.Const(111)(); case MsgPackType.POSITIVE_FIXNUM_0x70: return GenericCast.Const(112)(); case MsgPackType.POSITIVE_FIXNUM_0x71: return GenericCast.Const(113)(); case MsgPackType.POSITIVE_FIXNUM_0x72: return GenericCast.Const(114)(); case MsgPackType.POSITIVE_FIXNUM_0x73: return GenericCast.Const(115)(); case MsgPackType.POSITIVE_FIXNUM_0x74: return GenericCast.Const(116)(); case MsgPackType.POSITIVE_FIXNUM_0x75: return GenericCast.Const(117)(); case MsgPackType.POSITIVE_FIXNUM_0x76: return GenericCast.Const(118)(); case MsgPackType.POSITIVE_FIXNUM_0x77: return GenericCast.Const(119)(); case MsgPackType.POSITIVE_FIXNUM_0x78: return GenericCast.Const(120)(); case MsgPackType.POSITIVE_FIXNUM_0x79: return GenericCast.Const(121)(); case MsgPackType.POSITIVE_FIXNUM_0x7A: return GenericCast.Const(122)(); case MsgPackType.POSITIVE_FIXNUM_0x7B: return GenericCast.Const(123)(); case MsgPackType.POSITIVE_FIXNUM_0x7C: return GenericCast.Const(124)(); case MsgPackType.POSITIVE_FIXNUM_0x7D: return GenericCast.Const(125)(); case MsgPackType.POSITIVE_FIXNUM_0x7E: return GenericCast.Const(126)(); case MsgPackType.POSITIVE_FIXNUM_0x7F: return GenericCast.Const(127)(); case MsgPackType.NEGATIVE_FIXNUM: return GenericCast.Const(-32)(); case MsgPackType.NEGATIVE_FIXNUM_0x01: return GenericCast.Const(-1)(); case MsgPackType.NEGATIVE_FIXNUM_0x02: return GenericCast.Const(-2)(); case MsgPackType.NEGATIVE_FIXNUM_0x03: return GenericCast.Const(-3)(); case MsgPackType.NEGATIVE_FIXNUM_0x04: return GenericCast.Const(-4)(); case MsgPackType.NEGATIVE_FIXNUM_0x05: return GenericCast.Const(-5)(); case MsgPackType.NEGATIVE_FIXNUM_0x06: return GenericCast.Const(-6)(); case MsgPackType.NEGATIVE_FIXNUM_0x07: return GenericCast.Const(-7)(); case MsgPackType.NEGATIVE_FIXNUM_0x08: return GenericCast.Const(-8)(); case MsgPackType.NEGATIVE_FIXNUM_0x09: return GenericCast.Const(-9)(); case MsgPackType.NEGATIVE_FIXNUM_0x0A: return GenericCast.Const(-10)(); case MsgPackType.NEGATIVE_FIXNUM_0x0B: return GenericCast.Const(-11)(); case MsgPackType.NEGATIVE_FIXNUM_0x0C: return GenericCast.Const(-12)(); case MsgPackType.NEGATIVE_FIXNUM_0x0D: return GenericCast.Const(-13)(); case MsgPackType.NEGATIVE_FIXNUM_0x0E: return GenericCast.Const(-14)(); case MsgPackType.NEGATIVE_FIXNUM_0x0F: return GenericCast.Const(-15)(); case MsgPackType.NEGATIVE_FIXNUM_0x10: return GenericCast.Const(-16)(); case MsgPackType.NEGATIVE_FIXNUM_0x11: return GenericCast.Const(-17)(); case MsgPackType.NEGATIVE_FIXNUM_0x12: return GenericCast.Const(-18)(); case MsgPackType.NEGATIVE_FIXNUM_0x13: return GenericCast.Const(-19)(); case MsgPackType.NEGATIVE_FIXNUM_0x14: return GenericCast.Const(-20)(); case MsgPackType.NEGATIVE_FIXNUM_0x15: return GenericCast.Const(-21)(); case MsgPackType.NEGATIVE_FIXNUM_0x16: return GenericCast.Const(-22)(); case MsgPackType.NEGATIVE_FIXNUM_0x17: return GenericCast.Const(-23)(); case MsgPackType.NEGATIVE_FIXNUM_0x18: return GenericCast.Const(-24)(); case MsgPackType.NEGATIVE_FIXNUM_0x19: return GenericCast.Const(-25)(); case MsgPackType.NEGATIVE_FIXNUM_0x1A: return GenericCast.Const(-26)(); case MsgPackType.NEGATIVE_FIXNUM_0x1B: return GenericCast.Const(-27)(); case MsgPackType.NEGATIVE_FIXNUM_0x1C: return GenericCast.Const(-28)(); case MsgPackType.NEGATIVE_FIXNUM_0x1D: return GenericCast.Const(-29)(); case MsgPackType.NEGATIVE_FIXNUM_0x1E: return GenericCast.Const(-30)(); case MsgPackType.NEGATIVE_FIXNUM_0x1F: return GenericCast.Const(-31)(); case MsgPackType.INT8: return GenericCast.Cast((SByte)GetBody().Get(0)); case MsgPackType.INT16: return GenericCast.Cast(EndianConverter.NetworkByteWordToSignedNativeByteOrder(GetBody())); case MsgPackType.INT32: return GenericCast.Cast(EndianConverter.NetworkByteDWordToSignedNativeByteOrder(GetBody())); case MsgPackType.INT64: return GenericCast.Cast(EndianConverter.NetworkByteQWordToSignedNativeByteOrder(GetBody())); case MsgPackType.UINT8: return GenericCast.Cast(GetBody().Get(0)); case MsgPackType.UINT16: return GenericCast.Cast(EndianConverter.NetworkByteWordToUnsignedNativeByteOrder(GetBody())); case MsgPackType.UINT32: return GenericCast.Cast(EndianConverter.NetworkByteDWordToUnsignedNativeByteOrder(GetBody())); case MsgPackType.UINT64: return GenericCast.Cast(EndianConverter.NetworkByteQWordToUnsignedNativeByteOrder(GetBody())); case MsgPackType.FLOAT: return GenericCast.Cast(EndianConverter.NetworkByteDWordToFloatNativeByteOrder(GetBody())); case MsgPackType.DOUBLE: return GenericCast.Cast(EndianConverter.NetworkByteQWordToFloatNativeByteOrder(GetBody())); case MsgPackType.FIX_STR: return GenericCast.Const("")(); case MsgPackType.FIX_STR_0x01: case MsgPackType.FIX_STR_0x02: case MsgPackType.FIX_STR_0x03: case MsgPackType.FIX_STR_0x04: case MsgPackType.FIX_STR_0x05: case MsgPackType.FIX_STR_0x06: case MsgPackType.FIX_STR_0x07: case MsgPackType.FIX_STR_0x08: case MsgPackType.FIX_STR_0x09: case MsgPackType.FIX_STR_0x0A: case MsgPackType.FIX_STR_0x0B: case MsgPackType.FIX_STR_0x0C: case MsgPackType.FIX_STR_0x0D: case MsgPackType.FIX_STR_0x0E: case MsgPackType.FIX_STR_0x0F: case MsgPackType.FIX_STR_0x10: case MsgPackType.FIX_STR_0x11: case MsgPackType.FIX_STR_0x12: case MsgPackType.FIX_STR_0x13: case MsgPackType.FIX_STR_0x14: case MsgPackType.FIX_STR_0x15: case MsgPackType.FIX_STR_0x16: case MsgPackType.FIX_STR_0x17: case MsgPackType.FIX_STR_0x18: case MsgPackType.FIX_STR_0x19: case MsgPackType.FIX_STR_0x1A: case MsgPackType.FIX_STR_0x1B: case MsgPackType.FIX_STR_0x1C: case MsgPackType.FIX_STR_0x1D: case MsgPackType.FIX_STR_0x1E: case MsgPackType.FIX_STR_0x1F: case MsgPackType.STR8: case MsgPackType.STR16: case MsgPackType.STR32: { var body = GetBody(); var str = Encoding.UTF8.GetString(body.Array, body.Offset, body.Count); return GenericCast.Cast(str); } case MsgPackType.BIN8: case MsgPackType.BIN16: case MsgPackType.BIN32: { var body = GetBody(); return GenericCast, T>.Cast(body); } case MsgPackType.FIX_EXT_4: { if (GetExtType() == -1) { var unixtime = EndianConverter.NetworkByteDWordToUnsignedNativeByteOrder(GetBody()); var dt = new DateTimeOffset(unixtime * DateTimeOffsetExtensions.TicksPerSecond + DateTimeOffsetExtensions.EpochTime.Ticks, TimeSpan.Zero); return GenericCast.Cast(dt); } break; } } throw new ArgumentException("GetValue to array or map: " + formatType); } public bool GetBoolean() { switch (Format) { case MsgPackType.TRUE: return true; case MsgPackType.FALSE: return false; default: throw new MsgPackTypeException("Not boolean"); } } public ArraySegment GetBytes() { if (!Format.IsBinary()) { throw new MsgPackTypeException("Not bin"); } return GetBody(); } public string GetString() { if (!Format.IsString()) { throw new MsgPackTypeException("Not str"); } var bytes = GetBody(); return Encoding.UTF8.GetString(bytes.Array, bytes.Offset, bytes.Count); } public Utf8String GetUtf8String() { if (!Format.IsString()) { throw new MsgPackTypeException("Not str"); } var bytes = GetBody(); return new Utf8String(bytes); } public SByte GetSByte() { return GetValue(); } public Int16 GetInt16() { return GetValue(); } public Int32 GetInt32() { return GetValue(); } public Int64 GetInt64() { return GetValue(); } public Byte GetByte() { return GetValue(); } public UInt16 GetUInt16() { return GetValue(); } public UInt32 GetUInt32() { return GetValue(); } public UInt64 GetUInt64() { return GetValue(); } public float GetSingle() { return GetValue(); } public double GetDouble() { return GetValue(); } public void SetValue(Utf8String jsonPointer, T value) { throw new NotImplementedException(); } public void RemoveValue(Utf8String jsonPointer) { throw new NotImplementedException(); } public void AddKey(Utf8String key) { throw new NotImplementedException(); } public void AddValue(ArraySegment bytes, ValueNodeType valueType) { throw new NotImplementedException(); } } }