cheatah
Source

stdlib/parsers/json/boolean.hpp

1// Copyright (c) 2026 BigBrain LLC. MIT-licensed (see LICENSE).
2// Original work; see ACKNOWLEDGMENTS.md for the open-source ideas we build upon.
3#pragma once
5// cheatah::parsers::json — the JSON boolean token (`true` / `false`). See json.hpp.
7namespace cheatah::parsers::json {
9/** @brief A JSON `true` / `false` token, constructed from its bool: Boolean{true}. */
10class Boolean {
11private:
13 bool value_ {false};
15public:
16 /**
17 * Construct from a bool.
18 * @param value the boolean value (`true` or `false`).
19 * @complexity O(1).
20 * @alloc none.
21 * @test CheatahParsersJson.TokenClassesAndNodeVariant
22 */
23 Boolean(bool value) : value_(value) {}
25 /**
26 * Read the boolean value (fixed for the token's lifetime; no setter).
27 * @return the stored bool.
28 * @complexity O(1).
29 * @alloc none.
30 * @test CheatahParsersJson.TokenClassesAndNodeVariant
31 */
32 [[nodiscard]] bool value() const noexcept { return value_; }
33};
35} // namespace cheatah::parsers::json