diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-06-17 16:23:53 +0200 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-06-17 16:23:53 +0200 |
commit | 789f70b6f1a9067843dfc1ff73d86b645efe1da9 (patch) | |
tree | f3db085f2ac1ec5fd6ad0869a63e77a7f0fb1a17 /src/packet/FieldParser.cpp | |
parent | 2017-06-14 (diff) | |
download | AltCraft-789f70b6f1a9067843dfc1ff73d86b645efe1da9.tar AltCraft-789f70b6f1a9067843dfc1ff73d86b645efe1da9.tar.gz AltCraft-789f70b6f1a9067843dfc1ff73d86b645efe1da9.tar.bz2 AltCraft-789f70b6f1a9067843dfc1ff73d86b645efe1da9.tar.lz AltCraft-789f70b6f1a9067843dfc1ff73d86b645efe1da9.tar.xz AltCraft-789f70b6f1a9067843dfc1ff73d86b645efe1da9.tar.zst AltCraft-789f70b6f1a9067843dfc1ff73d86b645efe1da9.zip |
Diffstat (limited to '')
-rw-r--r-- | src/packet/FieldParser.cpp | 105 |
1 files changed, 0 insertions, 105 deletions
diff --git a/src/packet/FieldParser.cpp b/src/packet/FieldParser.cpp deleted file mode 100644 index 295e78f..0000000 --- a/src/packet/FieldParser.cpp +++ /dev/null @@ -1,105 +0,0 @@ -#include "FieldParser.hpp" - -Field FieldParser::Parse(FieldType type, byte *data, size_t len) { - switch (type) { - case VarIntType: - return ParseVarInt(data, len); - case Boolean: - return ParseBool(data); - case String: - return ParseString(data); - case Long: - return ParseLong(data); - case Int: - return ParseInt(data); - case UnsignedByte: - return ParseUByte(data); - case Byte8_t: - return ParseByte(data); - case Float: - return ParseFloat(data); - case Position: - return ParsePosition(data); - case Double: - return ParseDouble(data); - case ByteArray: - return ParseByteArray(data, len); - default: - throw 105; - } -} - -Field FieldParser::ParseString(byte *data) { - Field fLen = ParseVarInt(data, 0); - Field f; - f.SetRaw(data, fLen.GetLength() + fLen.GetVarInt(), String); - return f; -} - -Field FieldParser::ParseBool(byte *data) { - Field f; - f.SetRaw(data, 1, Boolean); - return f; -} - -Field FieldParser::ParseVarInt(byte *data, size_t len) { - if (len != 0) { - Field f; - f.SetRaw(data, len, VarIntType); - return f; - } - int val = VarIntRead(data, len); - Field f; - f.SetVarInt(val); - return f; -} - -Field FieldParser::ParseLong(byte *data) { - Field f; - f.SetRaw(data, 8, Long); - return f; -} - -Field FieldParser::ParseInt(byte *data) { - Field f; - f.SetRaw(data, 4, Int); - return f; -} - -Field FieldParser::ParseUByte(byte *data) { - Field f; - f.SetRaw(data, 1, UnsignedByte); - return f; -} - -Field FieldParser::ParseByte(byte *data) { - Field f; - f.SetRaw(data, 1, Byte8_t); - return f; -} - -Field FieldParser::ParseFloat(byte *data) { - Field f; - f.SetRaw(data, 4, Float); - return f; -} - -Field FieldParser::ParsePosition(byte *data) { - Field f; - f.SetRaw(data, 8, Position); - return f; -} - -Field FieldParser::ParseDouble(byte *data) { - Field f; - f.SetRaw(data, 8, Double); - return f; -} - -Field FieldParser::ParseByteArray(byte *data, size_t len) { - if (len == 0) - throw 119; - Field f; - f.SetRaw(data, len, Byte8_t); - return f; -} |