1 /* 2 * hunt-proton: AMQP Protocol library for D programming language. 3 * 4 * Copyright (C) 2018-2019 HuntLabs 5 * 6 * Website: https://www.huntlabs.net/ 7 * 8 * Licensed under the Apache-2.0 License. 9 * 10 */ 11 12 module hunt.proton.codec.impl.Decimal128Element; 13 14 /* 15 import hunt.io.ByteBuffer; 16 17 import hunt.proton.amqp.Decimal128; 18 import hunt.proton.codec.Data; 19 20 class Decimal128Element : AtomicElement!(Decimal128) 21 { 22 23 private Decimal128 _value; 24 25 Decimal128Element(Element parent, Element prev, Decimal128 d) 26 { 27 super(parent, prev); 28 _value = d; 29 } 30 31 override 32 public int size() 33 { 34 return isElementOfArray() ? 16 : 17; 35 } 36 37 override 38 public Decimal128 getValue() 39 { 40 return _value; 41 } 42 43 override 44 public Data.DataType getDataType() 45 { 46 return Data.DataType.DECIMAL128; 47 } 48 49 override 50 public int encode(ByteBuffer b) 51 { 52 int size = size(); 53 if(b.remaining()>=size) 54 { 55 if(size == 17) 56 { 57 b.put((byte)0x94); 58 } 59 b.putLong(_value.getMostSignificantBits()); 60 b.putLong(_value.getLeastSignificantBits()); 61 return size; 62 } 63 else 64 { 65 return 0; 66 } 67 } 68 } 69 */