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.Decoder;
13 
14 import hunt.proton.amqp.messaging.Section;
15 import hunt.proton.codec.FastPathDescribedTypeConstructor;
16 import hunt.proton.codec.DescribedTypeConstructor;
17 import hunt.proton.codec.Encoder;
18 import hunt.proton.amqp.Binary;
19 import hunt.proton.amqp.Decimal128;
20 import hunt.proton.amqp.Decimal32;
21 import hunt.proton.amqp.Decimal64;
22 import hunt.proton.amqp.Symbol;
23 import hunt.proton.amqp.UnsignedByte;
24 import hunt.proton.amqp.UnsignedInteger;
25 import hunt.proton.amqp.UnsignedLong;
26 import hunt.proton.amqp.UnsignedShort;
27 import hunt.Object;
28 
29 import hunt.time.LocalDateTime;
30 import hunt.collection.List;
31 import hunt.collection.Map;
32 import hunt.Boolean;
33 import hunt.Byte;
34 import hunt.Short;
35 import hunt.Integer;
36 import hunt.Long;
37 import hunt.Char;
38 import hunt.Double;
39 import hunt.Float;
40 import hunt.String;
41 import std.uuid;
42 
43 
44 alias Date = hunt.time.LocalDateTime.LocalDateTime;
45 
46 interface Decoder
47 {
48     interface ListProcessor(T)
49     {
50         T process(int count, Encoder encoder);
51     }
52 
53 
54     Boolean readBoolean();
55     Boolean readBoolean(Boolean defaultVal);
56     bool readBoolean(bool defaultVal);
57 
58     Byte readByte();
59     Byte readByte(Byte defaultVal);
60     byte readByte(byte defaultVal);
61 
62     Short readShort();
63     Short readShort(Short defaultVal);
64     short readShort(short defaultVal);
65 
66     Integer readInteger();
67     Integer readInteger(Integer defaultVal);
68     int readInteger(int defaultVal);
69 
70     Long readLong();
71     Long readLong(Long defaultVal);
72     long readLong(long defaultVal);
73 
74     UnsignedByte readUnsignedByte();
75     UnsignedByte readUnsignedByte(UnsignedByte defaultVal);
76 
77     UnsignedShort readUnsignedShort();
78     UnsignedShort readUnsignedShort(UnsignedShort defaultVal);
79 
80     UnsignedInteger readUnsignedInteger();
81     UnsignedInteger readUnsignedInteger(UnsignedInteger defaultVal);
82 
83     UnsignedLong readUnsignedLong();
84     UnsignedLong readUnsignedLong(UnsignedLong defaultVal);
85 
86     Char readCharacter();
87     Char readCharacter(Char defaultVal);
88     char readCharacter(char defaultVal);
89 
90     Float readFloat();
91     Float readFloat(Float defaultVal);
92     float readFloat(float defaultVal);
93 
94     Double readDouble();
95     Double readDouble(Double defaultVal);
96     double readDouble(double defaultVal);
97 
98     UUID readUUID();
99     UUID readUUID(UUID defaultValue);
100 
101     Decimal32 readDecimal32();
102     Decimal32 readDecimal32(Decimal32 defaultValue);
103 
104     Decimal64 readDecimal64();
105     Decimal64 readDecimal64(Decimal64 defaultValue);
106 
107     Decimal128 readDecimal128();
108     Decimal128 readDecimal128(Decimal128 defaultValue);
109 
110     Date readTimestamp();
111     Date readTimestamp(Date defaultValue);
112 
113     Binary readBinary();
114     Binary readBinary(Binary defaultValue);
115 
116     Symbol readSymbol();
117     Symbol readSymbol(Symbol defaultValue);
118 
119     String readString();
120     String readString(String defaultValue);
121 
122    // List readList();
123     //void readList(T)(ListProcessor!(T) processor);
124 
125   //  IObject readMap();
126 
127   //  <T> T[] readArray(Class!(T) clazz);
128 
129   //  Object[] readArray();
130 
131     //bool[] readBooleanArray();
132     //byte[] readByteArray();
133     //short[] readShortArray();
134     //int[] readIntegerArray();
135     //long[] readLongArray();
136     //float[] readFloatArray();
137     //double[] readDoubleArray();
138     //char[] readCharacterArray();
139 
140    // <T> T[] readMultiple(Class!(T) clazz);
141 
142     //Object[] readMultiple();
143     //byte[] readByteMultiple();
144     //short[] readShortMultiple();
145     //int[] readIntegerMultiple();
146     //long[] readLongMultiple();
147     //float[] readFloatMultiple();
148     //double[] readDoubleMultiple();
149     //char[] readCharacterMultiple();
150 
151     Object readObject();
152     Object readObject(Object defaultValue);
153 
154     void registerDynamic(Object descriptor, Object dtc);
155 
156     void registerFastPath(Object descriptor, Object dtc);
157 
158 }