cheatah
Source

stdlib/parsers/json/number.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 number token (one numeric type: IEEE-754 double). See json.hpp.
7namespace cheatah::parsers::json {
9/** @brief A JSON number token (one numeric type: IEEE-754 double), e.g. Number{3.5}. */
10class Number {
11private:
12 double value_ {0.0};
14public:
15 /**
16 * Construct from a double.
17 * @param value the numeric value.
18 * @complexity O(1).
19 * @alloc none.
20 * @test CheatahParsersJson.TokenClassesAndNodeVariant
21 */
22 Number(double value) : value_(value) {}
25 /**
26 * Read the numeric value (fixed for the token's lifetime; no setter).
27 * @return the stored double.
28 * @complexity O(1).
29 * @alloc none.
30 * @test CheatahParsersJson.TokenClassesAndNodeVariant
31 */
32 [[nodiscard]] double value() const noexcept { return value_; }
33};
35} // namespace cheatah::parsers::json