| 1 | /* |
| 2 | Copyright(C) 2011-2016 Brazil |
| 3 | |
| 4 | This library is free software; you can redistribute it and/or |
| 5 | modify it under the terms of the GNU Lesser General Public |
| 6 | License as published by the Free Software Foundation; either |
| 7 | version 2.1 of the License, or (at your option) any later version. |
| 8 | |
| 9 | This library is distributed in the hope that it will be useful, |
| 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 12 | Lesser General Public License for more details. |
| 13 | |
| 14 | You should have received a copy of the GNU Lesser General Public |
| 15 | License along with this library; if not, write to the Free Software |
| 16 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 17 | */ |
| 18 | |
| 19 | #pragma once |
| 20 | |
| 21 | #include "dat.hpp"cxx . . $ `<file>/lib/dat/dat.hpp`/ |
| 22 | |
| 23 | namespace grncxx . . $ grn/ { |
| 24 | namespace datcxx . . $ grn/dat/ { |
| 25 | |
| 26 | // The most significant bit represents whether or not the node is a linker. |
| 27 | // BASE of a linker represents the position of its associated key and BASE of |
| 28 | // a non-linker represents the offset to its child nodes. |
| 29 | class GRN_DAT_APIcxx . . $ `lib/dat/dat.hpp:44:12`! Basecxx . . $ grn/dat/Base# { |
| 30 | public: |
| 31 | Basecxx . . $ grn/dat/Base#Base(49f6e7a06ebc5aa8).() : value_cxx . . $ grn/dat/Base#value_.(0) {} |
| 32 | |
| 33 | bool operatorcxx . . $ grn/dat/Base#`operator==`(67b2faf3baf417c5).==(const Basecxx . . $ grn/dat/Base# &rhs) const { |
| 34 | return value_cxx . . $ grn/dat/Base#value_. == rhs.value_cxx . . $ grn/dat/Base#value_.; |
| 35 | } |
| 36 | |
| 37 | bool is_linkercxx . . $ grn/dat/Base#is_linker(50ce9a9e25b4a850).() const { |
| 38 | return (value_cxx . . $ grn/dat/Base#value_. & IS_LINKER_FLAGcxx . . $ grn/dat/Base#IS_LINKER_FLAG.) == IS_LINKER_FLAGcxx . . $ grn/dat/Base#IS_LINKER_FLAG.; |
| 39 | } |
| 40 | UInt32cxx . . $ grn/dat/UInt32# offsetcxx . . $ grn/dat/Base#offset(ddd8539a2fcdd4ce).() const { |
| 41 | GRN_DAT_DEBUG_THROW_IFcxx . . $ `lib/dat/dat.hpp:242:10`!(is_linker()); |
| 42 | return value_cxx . . $ grn/dat/Base#value_.; |
| 43 | } |
| 44 | UInt32cxx . . $ grn/dat/UInt32# key_poscxx . . $ grn/dat/Base#key_pos(ddd8539a2fcdd4ce).() const { |
| 45 | GRN_DAT_DEBUG_THROW_IFcxx . . $ `lib/dat/dat.hpp:242:10`!(!is_linker()); |
| 46 | return value_cxx . . $ grn/dat/Base#value_. & ~IS_LINKER_FLAGcxx . . $ grn/dat/Base#IS_LINKER_FLAG.; |
| 47 | } |
| 48 | |
| 49 | void set_offsetcxx . . $ grn/dat/Base#set_offset(cb2f890c2fdad230).(UInt32cxx . . $ grn/dat/UInt32# x) { |
| 50 | GRN_DAT_DEBUG_THROW_IFcxx . . $ `lib/dat/dat.hpp:242:10`!((x & IS_LINKER_FLAG) != 0); |
| 51 | GRN_DAT_DEBUG_THROW_IFcxx . . $ `lib/dat/dat.hpp:242:10`!(x > MAX_OFFSET); |
| 52 | value_cxx . . $ grn/dat/Base#value_. = x; |
| 53 | } |
| 54 | void set_key_poscxx . . $ grn/dat/Base#set_key_pos(cb2f890c2fdad230).(UInt32cxx . . $ grn/dat/UInt32# x) { |
| 55 | GRN_DAT_DEBUG_THROW_IFcxx . . $ `lib/dat/dat.hpp:242:10`!((x & IS_LINKER_FLAG) != 0); |
| 56 | GRN_DAT_DEBUG_THROW_IFcxx . . $ `lib/dat/dat.hpp:242:10`!(x > MAX_OFFSET); |
| 57 | value_cxx . . $ grn/dat/Base#value_. = IS_LINKER_FLAGcxx . . $ grn/dat/Base#IS_LINKER_FLAG. | x; |
| 58 | } |
| 59 | |
| 60 | private: |
| 61 | UInt32cxx . . $ grn/dat/UInt32# value_cxx . . $ grn/dat/Base#value_.; |
| 62 | |
| 63 | static const UInt32cxx . . $ grn/dat/UInt32# IS_LINKER_FLAGcxx . . $ grn/dat/Base#IS_LINKER_FLAG. = 0x80000000U; |
| 64 | }; |
| 65 | |
| 66 | } // namespace dat |
| 67 | } // namespace grn |