public static CheckedRet <object> Deserial(ByteList bytes) { var size = bytes.DropInt32(); if (bytes.Count != size) { return(CheckedRet <object> .Fail()); } var ret = new Trfm(); for (int i = 0; i < 3; i++) { var _size = bytes.DropInt32(); var _bytes = bytes.DropRange(0, _size); var _obj = Serializer.Deserialize <Vec3>(_bytes); if (_obj.Key == false) { return(CheckedRet <object> .Fail()); } ret.mVal [i] = _obj.Value; } // 小数点に関わるため、ハッシュチェックはしない(できない) return(CheckedRet <object> .Gen(true, ret)); }
public CheckedRet <T> Pop() { if (Count < 1) { return(CheckedRet <T> .Fail()); } var r = this [0]; RemoveAt(0); return(CheckedRet <T> .Gen(true, r)); }
public static CheckedRet <T> ParseEnum <T> (this string str) where T : struct { var arr = StEnum.ToArray <T>(); foreach (var e in arr) { if (e.ToString() != str) { continue; } return(new CheckedRet <T>().Set(true, e)); } return(CheckedRet <T> .Fail()); }
public static CheckedRet <T> Deserialize <T> (ByteList bytes) { var v = Instance.Implement.Deserial(bytes); if (v.Key == false) { return(CheckedRet <T> .Fail()); } try { var val = (T)v.Value; return(CheckedRet <T> .Gen(true, val)); } catch (Exception e) { DebugLog.Error.Print("parse fail<{0}>{1}", typeof(T).Name, e); return(CheckedRet <T> .Fail()); } }
public static CheckedRet <object> Deserial(ByteList bytes) { var size = bytes.DropInt32(); if (bytes.Count != size) { return(CheckedRet <object> .Fail()); } var ret = new Vec3(); for (int i = 0; i < 3; i++) { ret.mVal [i] = bytes.DropFloat(); } int hash = bytes.DropInt32(); if (hash != ret.GetHashCode()) { return(CheckedRet <object> .Fail()); } return(CheckedRet <object> .Gen(true, ret)); }
public static CheckedRet <object> Deserial(ByteList bytes) { var size = bytes.DropInt32(); if (bytes.Count != size) { throw new Exception("1"); // return CheckedRet<object>.Fail(); } var ret = new Msg(); var dic_size = bytes.DropInt32(); for (int i = 0; i < dic_size; i++) { var k_l = bytes.DropInt32(); var k = Serializer.Deserialize <string>(bytes.DropRange(0, k_l)); if (k.Key == false) { throw new Exception("5"); } var v_l = bytes.DropInt32(); var v = Serializer.Deserialize <string>(bytes.DropRange(0, v_l)); if (v.Key == false) { throw new Exception("6"); } ret.Set(k.Value, v.Value); } var data_size = bytes.DropInt32(); var h_s = 0; if (data_size < 4) { h_s = bytes.DropInt32(); if (ret.GetHashCode() != h_s) { throw new Exception("2:" + ret.ToJson()); } return((ret.GetHashCode() != h_s) ? CheckedRet <object> .Fail() : CheckedRet <object> .Gen(true, ret)); } var data_bytes = bytes.DropRange(0, data_size); var obj = Serializer.Deserialize <object>(data_bytes); if (obj.Key == false) { throw new Exception("3"); //return CheckedRet<object>.Fail(); } ret.mObjectData = obj.Value; h_s = bytes.DropInt32(); if (ret.GetHashCode() != h_s) { throw new Exception("4"); } return((ret.GetHashCode() != h_s) ? CheckedRet <object> .Fail() : CheckedRet <object> .Gen(true, ret)); }