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) {}
23 ~Number() = default;
26 /**
27 * Read the numeric value (fixed for the token's lifetime; no setter).
28 * @return the stored double.
29 * @complexity O(1).
30 * @alloc none.
31 * @test CheatahParsersJson.TokenClassesAndNodeVariant
32 */
33 [[nodiscard]] double value() const noexcept { return value_; }
34};
36} // namespace cheatah::parsers::json