Improve LookupByKey , update docs

This commit is contained in:
TGIshib
2016-08-22 18:10:52 +03:00
parent fa74ce6d16
commit 9f16090f90
9 changed files with 173 additions and 64 deletions

View File

@@ -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;
}
}
}