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 once5
// cheatah::parsers::json — the JSON number token (one numeric type: IEEE-754 double). See json.hpp.7
namespace cheatah::parsers::json {9
/** @brief A JSON number token (one numeric type: IEEE-754 double), e.g. Number{3.5}. */10
class Number {11
private:12
double value_ {0.0};14
public:15
/**16
* Construct from a double.17
* @param value the numeric value.18
* @complexity O(1).19
* @alloc none.20
* @test CheatahParsersJson.TokenClassesAndNodeVariant21
*/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.TokenClassesAndNodeVariant32
*/33
[[nodiscard]] double value() const noexcept { return value_; }34
};36
} // namespace cheatah::parsers::json