TestTable.cs revision 1a161a8333ec1fa382a06485b7ffad955c001151
11a161a8333ec1fa382a06485b7ffad955c001151Wouter van Oortmerssen/*
21a161a8333ec1fa382a06485b7ffad955c001151Wouter van Oortmerssen * Copyright 2016 Google Inc. All rights reserved.
31a161a8333ec1fa382a06485b7ffad955c001151Wouter van Oortmerssen *
41a161a8333ec1fa382a06485b7ffad955c001151Wouter van Oortmerssen * Licensed under the Apache License, Version 2.0 (the "License");
51a161a8333ec1fa382a06485b7ffad955c001151Wouter van Oortmerssen * you may not use this file except in compliance with the License.
61a161a8333ec1fa382a06485b7ffad955c001151Wouter van Oortmerssen * You may obtain a copy of the License at
71a161a8333ec1fa382a06485b7ffad955c001151Wouter van Oortmerssen *
81a161a8333ec1fa382a06485b7ffad955c001151Wouter van Oortmerssen *     http://www.apache.org/licenses/LICENSE-2.0
91a161a8333ec1fa382a06485b7ffad955c001151Wouter van Oortmerssen *
101a161a8333ec1fa382a06485b7ffad955c001151Wouter van Oortmerssen * Unless required by applicable law or agreed to in writing, software
111a161a8333ec1fa382a06485b7ffad955c001151Wouter van Oortmerssen * distributed under the License is distributed on an "AS IS" BASIS,
121a161a8333ec1fa382a06485b7ffad955c001151Wouter van Oortmerssen * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
131a161a8333ec1fa382a06485b7ffad955c001151Wouter van Oortmerssen * See the License for the specific language governing permissions and
141a161a8333ec1fa382a06485b7ffad955c001151Wouter van Oortmerssen * limitations under the License.
151a161a8333ec1fa382a06485b7ffad955c001151Wouter van Oortmerssen */
161a161a8333ec1fa382a06485b7ffad955c001151Wouter van Oortmerssen
179d66af6efc0498e90e2757659761ae0c4f797eeeevolutionalnamespace FlatBuffers.Test
189d66af6efc0498e90e2757659761ae0c4f797eeeevolutional{
199d66af6efc0498e90e2757659761ae0c4f797eeeevolutional    /// <summary>
209d66af6efc0498e90e2757659761ae0c4f797eeeevolutional    /// A test Table object that gives easy access to the slot data
219d66af6efc0498e90e2757659761ae0c4f797eeeevolutional    /// </summary>
229d66af6efc0498e90e2757659761ae0c4f797eeeevolutional    internal class TestTable : Table
239d66af6efc0498e90e2757659761ae0c4f797eeeevolutional    {
249d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        public TestTable(ByteBuffer bb, int pos)
259d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        {
269d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            base.bb = bb;
279d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            base.bb_pos = pos;
289d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        }
299d66af6efc0498e90e2757659761ae0c4f797eeeevolutional
309d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        public bool GetSlot(int slot, bool def)
319d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        {
329d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            var off = base.__offset(slot);
339d66af6efc0498e90e2757659761ae0c4f797eeeevolutional
349d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            if (off == 0)
359d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            {
369d66af6efc0498e90e2757659761ae0c4f797eeeevolutional                return def;
379d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            }
389d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            return bb.GetSbyte(bb_pos + off) != 0;
399d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        }
409d66af6efc0498e90e2757659761ae0c4f797eeeevolutional
419d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        public sbyte GetSlot(int slot, sbyte def)
429d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        {
439d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            var off = base.__offset(slot);
449d66af6efc0498e90e2757659761ae0c4f797eeeevolutional
459d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            if (off == 0)
469d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            {
479d66af6efc0498e90e2757659761ae0c4f797eeeevolutional                return def;
489d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            }
499d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            return bb.GetSbyte(bb_pos + off);
509d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        }
519d66af6efc0498e90e2757659761ae0c4f797eeeevolutional
529d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        public byte GetSlot(int slot, byte def)
539d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        {
549d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            var off = base.__offset(slot);
559d66af6efc0498e90e2757659761ae0c4f797eeeevolutional
569d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            if (off == 0)
579d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            {
589d66af6efc0498e90e2757659761ae0c4f797eeeevolutional                return def;
599d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            }
609d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            return bb.Get(bb_pos + off);
619d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        }
629d66af6efc0498e90e2757659761ae0c4f797eeeevolutional
639d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        public short GetSlot(int slot, short def)
649d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        {
659d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            var off = base.__offset(slot);
669d66af6efc0498e90e2757659761ae0c4f797eeeevolutional
679d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            if (off == 0)
689d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            {
699d66af6efc0498e90e2757659761ae0c4f797eeeevolutional                return def;
709d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            }
719d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            return bb.GetShort(bb_pos + off);
729d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        }
739d66af6efc0498e90e2757659761ae0c4f797eeeevolutional
749d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        public ushort GetSlot(int slot, ushort def)
759d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        {
769d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            var off = base.__offset(slot);
779d66af6efc0498e90e2757659761ae0c4f797eeeevolutional
789d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            if (off == 0)
799d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            {
809d66af6efc0498e90e2757659761ae0c4f797eeeevolutional                return def;
819d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            }
829d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            return bb.GetUshort(bb_pos + off);
839d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        }
849d66af6efc0498e90e2757659761ae0c4f797eeeevolutional
859d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        public int GetSlot(int slot, int def)
869d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        {
879d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            var off = base.__offset(slot);
889d66af6efc0498e90e2757659761ae0c4f797eeeevolutional
899d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            if (off == 0)
909d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            {
919d66af6efc0498e90e2757659761ae0c4f797eeeevolutional                return def;
929d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            }
939d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            return bb.GetInt(bb_pos + off);
949d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        }
959d66af6efc0498e90e2757659761ae0c4f797eeeevolutional
969d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        public uint GetSlot(int slot, uint def)
979d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        {
989d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            var off = base.__offset(slot);
999d66af6efc0498e90e2757659761ae0c4f797eeeevolutional
1009d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            if (off == 0)
1019d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            {
1029d66af6efc0498e90e2757659761ae0c4f797eeeevolutional                return def;
1039d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            }
1049d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            return bb.GetUint(bb_pos + off);
1059d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        }
1069d66af6efc0498e90e2757659761ae0c4f797eeeevolutional
1079d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        public long GetSlot(int slot, long def)
1089d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        {
1099d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            var off = base.__offset(slot);
1109d66af6efc0498e90e2757659761ae0c4f797eeeevolutional
1119d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            if (off == 0)
1129d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            {
1139d66af6efc0498e90e2757659761ae0c4f797eeeevolutional                return def;
1149d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            }
1159d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            return bb.GetLong(bb_pos + off);
1169d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        }
1179d66af6efc0498e90e2757659761ae0c4f797eeeevolutional
1189d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        public ulong GetSlot(int slot, ulong def)
1199d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        {
1209d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            var off = base.__offset(slot);
1219d66af6efc0498e90e2757659761ae0c4f797eeeevolutional
1229d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            if (off == 0)
1239d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            {
1249d66af6efc0498e90e2757659761ae0c4f797eeeevolutional                return def;
1259d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            }
1269d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            return bb.GetUlong(bb_pos + off);
1279d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        }
1289d66af6efc0498e90e2757659761ae0c4f797eeeevolutional
1299d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        public float GetSlot(int slot, float def)
1309d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        {
1319d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            var off = base.__offset(slot);
1329d66af6efc0498e90e2757659761ae0c4f797eeeevolutional
1339d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            if (off == 0)
1349d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            {
1359d66af6efc0498e90e2757659761ae0c4f797eeeevolutional                return def;
1369d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            }
1379d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            return bb.GetFloat(bb_pos + off);
1389d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        }
1399d66af6efc0498e90e2757659761ae0c4f797eeeevolutional
1409d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        public double GetSlot(int slot, double def)
1419d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        {
1429d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            var off = base.__offset(slot);
1439d66af6efc0498e90e2757659761ae0c4f797eeeevolutional
1449d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            if (off == 0)
1459d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            {
1469d66af6efc0498e90e2757659761ae0c4f797eeeevolutional                return def;
1479d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            }
1489d66af6efc0498e90e2757659761ae0c4f797eeeevolutional            return bb.GetDouble(bb_pos + off);
1499d66af6efc0498e90e2757659761ae0c4f797eeeevolutional        }
1509d66af6efc0498e90e2757659761ae0c4f797eeeevolutional    }
1519d66af6efc0498e90e2757659761ae0c4f797eeeevolutional}