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.Decimal64Type; 13 14 /* 15 import hunt.proton.amqp.Decimal64; 16 17 import hunt.collection.Collection; 18 import hunt.collection.Collections; 19 20 class Decimal64Type : AbstractPrimitiveType!(Decimal64) 21 { 22 private Decimal64Encoding _decimal64Encoder; 23 24 Decimal64Type(EncoderImpl encoder, DecoderImpl decoder) 25 { 26 _decimal64Encoder = new Decimal64Encoding(encoder, decoder); 27 encoder.register(Decimal64.class, this); 28 decoder.register(this); 29 } 30 31 public Class!(Decimal64) getTypeClass() 32 { 33 return Decimal64.class; 34 } 35 36 public Decimal64Encoding getEncoding(Decimal64 val) 37 { 38 return _decimal64Encoder; 39 } 40 41 42 public Decimal64Encoding getCanonicalEncoding() 43 { 44 return _decimal64Encoder; 45 } 46 47 public Collection!(Decimal64Encoding) getAllEncodings() 48 { 49 return Collections.singleton(_decimal64Encoder); 50 } 51 52 private class Decimal64Encoding : FixedSizePrimitiveTypeEncoding!(Decimal64) 53 { 54 55 public Decimal64Encoding(EncoderImpl encoder, DecoderImpl decoder) 56 { 57 super(encoder, decoder); 58 } 59 60 override 61 protected int getFixedSize() 62 { 63 return 8; 64 } 65 66 override 67 public byte getEncodingCode() 68 { 69 return EncodingCodes.DECIMAL64; 70 } 71 72 public Decimal64Type getType() 73 { 74 return Decimal64Type.this; 75 } 76 77 public void writeValue(Decimal64 val) 78 { 79 getEncoder().writeRaw(val.getBits()); 80 } 81 82 public bool encodesSuperset(TypeEncoding!(Decimal64) encoding) 83 { 84 return (getType() == encoding.getType()); 85 } 86 87 public Decimal64 readValue() 88 { 89 return new Decimal64(getDecoder().readRawLong()); 90 } 91 } 92 } 93 */