| 1 | <?php |
| 2 | /************************************************************* |
| 3 | # 076 License |
| 4 | |
| 5 | Copyright (c) テクニカル諏訪子 |
| 6 | |
| 7 | Permission is hereby granted to any person obtaining a copy of the software |
| 8 | Little Beast (the "Software") to use, modify, merge, copy, publish, distribute, |
| 9 | sublicense, and/or sell copies of the Software, subject to the following conditions: |
| 10 | |
| 11 | 1. **Origin Attribution**: |
| 12 | - You must not misrepresent the origin of the Software; you must not claim |
| 13 | you created the original Software. |
| 14 | - If the Software is used in a product, you must either: |
| 15 | a. Provide clear attribution in the product's documentation, user interface, |
| 16 | or other visible areas, **OR** |
| 17 | b. Pay the original developers a fee they specify in writing. |
| 18 | 2. **Usage Restriction**: |
| 19 | - The Software, or any derivative works, dependencies, or libraries |
| 20 | incorporating it, must not be used for censorship or to suppress freedom of |
| 21 | speech, expression, or creativity. Prohibited uses include, but are not |
| 22 | limited to: |
| 23 | - Censorship of so-called "hate speech", visuals, non-mainstream opinions, |
| 24 | ideas, or objective reality. |
| 25 | - Tools or systems designed to restrict access to information or |
| 26 | artistic works. |
| 27 | 3. **Notice Preservation**: |
| 28 | - This license and the above copyright notice must remain intact in all copies |
| 29 | of the source code. |
| 30 | |
| 31 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, |
| 32 | INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A |
| 33 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
| 34 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF |
| 35 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE |
| 36 | OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
| 37 | */ |
| 38 | namespace Std\Lib\Db\Sqlite; |
| 39 | |
| 40 | /** |
| 41 | * Bツリーのページ(Btreeが使う) |
| 42 | */ |
| 43 | final class Page { |
| 44 | /** 種類:2(インデックスの内部)、5(テーブルの内部)、10(インデックスの葉)、13(テーブルの葉) */ |
| 45 | public int $type = 13; |
| 46 | /** セル(内部のページは左の子のページ番号を除く) */ |
| 47 | public array $cells = []; |
| 48 | /** 内部のページ:セル毎の左の子 */ |
| 49 | public array $left = []; |
| 50 | /** 内部のページ:一番右の子 */ |
| 51 | public int $right = 0; |
| 52 | /** テーブル:セル毎のrowid */ |
| 53 | public array $keys = []; |
| 54 | /** インデックス:セル毎のデコードしたキー(まだならnull) */ |
| 55 | public array $dec = []; |
| 56 | /** セルの大きさの合計(セルのポインターも含む) */ |
| 57 | public int $size = 0; |
| 58 | |
| 59 | public function __construct(public readonly int $pgno) {} |
| 60 | |
| 61 | public function isLeaf(): bool { |
| 62 | return $this->type === 10 || $this->type === 13; |
| 63 | } |
| 64 | |
| 65 | public function isTable(): bool { |
| 66 | return $this->type === 5 || $this->type === 13; |
| 67 | } |
| 68 | } |