diff options
author | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-05-18 16:03:05 +0200 |
---|---|---|
committer | LaG1924 <12997935+LaG1924@users.noreply.github.com> | 2017-05-18 16:03:05 +0200 |
commit | 4d7b1da29e0957ac798ee8e6da8288cbd4ae5c79 (patch) | |
tree | 548911d4e341fd5717acff3b5bc752c7b5650bf4 /code/FieldParser.cpp | |
parent | 2017-05-13 (diff) | |
download | AltCraft-4d7b1da29e0957ac798ee8e6da8288cbd4ae5c79.tar AltCraft-4d7b1da29e0957ac798ee8e6da8288cbd4ae5c79.tar.gz AltCraft-4d7b1da29e0957ac798ee8e6da8288cbd4ae5c79.tar.bz2 AltCraft-4d7b1da29e0957ac798ee8e6da8288cbd4ae5c79.tar.lz AltCraft-4d7b1da29e0957ac798ee8e6da8288cbd4ae5c79.tar.xz AltCraft-4d7b1da29e0957ac798ee8e6da8288cbd4ae5c79.tar.zst AltCraft-4d7b1da29e0957ac798ee8e6da8288cbd4ae5c79.zip |
Diffstat (limited to '')
-rw-r--r-- | code/FieldParser.cpp | 106 |
1 files changed, 0 insertions, 106 deletions
diff --git a/code/FieldParser.cpp b/code/FieldParser.cpp deleted file mode 100644 index 500a973..0000000 --- a/code/FieldParser.cpp +++ /dev/null @@ -1,106 +0,0 @@ -#include "FieldParser.hpp" - -Field FieldParser::Parse(FieldType type, byte *data, size_t len) { - switch (type) { - case VarInt: - return ParseVarInt(data, len); - case Boolean: - return ParseBool(data, len); - case String: - return ParseString(data, len); - case Long: - return ParseLong(data, len); - case Int: - return ParseInt(data, len); - case UnsignedByte: - return ParseUByte(data, len); - case Byte8_t: - return ParseByte(data, len); - case Float: - return ParseFloat(data, len); - case Position: - return ParsePosition(data, len); - case Double: - return ParseDouble(data, len); - case ByteArray: - return ParseByteArray(data, len); - default: - throw 105; - } -} - -Field FieldParser::ParseString(byte *data, size_t len) { - Field fLen = ParseVarInt(data, 0); - Field f; - f.SetRaw(data, fLen.GetLength() + fLen.GetVarInt(), String); - return f; -} - -Field FieldParser::ParseBool(byte *data, size_t len) { - 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, VarInt); - return f; - } - int val = VarIntRead(data, len); - Field f; - f.SetVarInt(val); - return f; -} - -Field FieldParser::ParseLong(byte *data, size_t len) { - Field f; - f.SetRaw(data, 8, Long); - return f; -} - -Field FieldParser::ParseInt(byte *data, size_t len) { - Field f; - f.SetRaw(data, 4, Int); - return f; -} - -Field FieldParser::ParseUByte(byte *data, size_t len) { - Field f; - f.SetRaw(data, 1, UnsignedByte); - return f; -} - -Field FieldParser::ParseByte(byte *data, size_t len) { - Field f; - f.SetRaw(data, 1, Byte8_t); - return f; -} - -Field FieldParser::ParseFloat(byte *data, size_t len) { - Field f; - f.SetRaw(data, 4, Float); - return f; -} - -Field FieldParser::ParsePosition(byte *data, size_t len) { - Field f; - f.SetRaw(data, 8, Position); - return f; -} - -Field FieldParser::ParseDouble(byte *data, size_t len) { - 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); - //f.SetRaw(data, len, ByteArray); - return f; -} |