Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private struct BytesReader
- {
- ubyte[] arr;
- size_t currIdx;
- this(ubyte[] a)
- {
- arr = a;
- }
- T read(T)() const
- {
- const incremented = currIdx + sizeof(T);
- // Malformed array?
- if(incremented > arr.length)
- throw new AnswerException(ExceptionType.FATAL_ERROR, null);
- auto ret = cast(T*) &arr[currIdx];
- currIdx = incremented;
- return ret;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement