From 9f16090f901c30f872422f60db21a0370dde8bbf Mon Sep 17 00:00:00 2001 From: TGIshib Date: Mon, 22 Aug 2016 18:10:52 +0300 Subject: Improve `LookupByKey` , update docs --- net/FlatBuffers/Table.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'net') diff --git a/net/FlatBuffers/Table.cs b/net/FlatBuffers/Table.cs index 2a452e3e..20f41f6f 100644 --- a/net/FlatBuffers/Table.cs +++ b/net/FlatBuffers/Table.cs @@ -48,6 +48,11 @@ namespace FlatBuffers { return offset + bb.GetInt(offset); } + + protected static int __indirect(int offset, ByteBuffer bb) + { + return offset + bb.GetInt(offset); + } // Create a .NET String from UTF-8 data stored inside the flatbuffer. protected string __string(int offset) @@ -128,6 +133,23 @@ namespace FlatBuffers if (len_1 > len_2) return 1; return 0; } + + // Compare string from the ByteBuffer with the string object + protected static int CompareStrings(int offset_1, string key, ByteBuffer bb) + { + offset_1 += bb.GetInt(offset_1); + var len_1 = bb.GetInt(offset_1); + var len_2 = key.Length; + var startPos_1 = offset_1 + sizeof(int); + var len = Math.Min(len_1, len_2); + for (int i = 0; i < len; i++) { + if (bb.Data[i + startPos_1] != key[i]) + return bb.Data[i + startPos_1] - key[i]; + } + if (len_1 < len_2) return -1; + if (len_1 > len_2) return 1; + return 0; + } } } -- cgit v1.2.3