diff options
author | TGIshib <justzeddicus@gmail.com> | 2016-08-22 18:10:52 +0300 |
---|---|---|
committer | TGIshib <justzeddicus@gmail.com> | 2016-08-22 18:10:52 +0300 |
commit | 9f16090f901c30f872422f60db21a0370dde8bbf (patch) | |
tree | dc7e384727f8a4ac7d920b74e44576ee3dd0e03f /net | |
parent | fa74ce6d162cc25fbf3af153b8067363049de7c3 (diff) | |
download | flatbuffers-9f16090f901c30f872422f60db21a0370dde8bbf.tar.gz flatbuffers-9f16090f901c30f872422f60db21a0370dde8bbf.tar.bz2 flatbuffers-9f16090f901c30f872422f60db21a0370dde8bbf.zip |
Improve `LookupByKey` , update docs
Diffstat (limited to 'net')
-rw-r--r-- | net/FlatBuffers/Table.cs | 22 |
1 files changed, 22 insertions, 0 deletions
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; + } } } |