fson  1.0.2
A comment-preserving C++ library for FSON — a human-friendly superset of JSON / JSON5
fedem::fson::Number Class Referencefinal

#include <Number.hh>

+ Inheritance diagram for fedem::fson::Number:
+ Collaboration diagram for fedem::fson::Number:

Public Types

enum class  Kind {
  Decimal , Hex , Infinity , NegativeInfinity ,
  NaN
}
 
- Public Types inherited from fedem::fson::Value
enum class  Type {
  Null , Boolean , Number , String ,
  Array , Object
}
 

Public Member Functions

 Number (double value)
 
 Number (long long value)
 
 Number (double value, std::string lexeme, Kind kind=Kind::Decimal)
 
Type getType () const noexcept override
 
std::unique_ptr< Valueclone () const override
 
NumberasNumber () noexcept override
 
Number const * asNumber () const noexcept override
 
double asDouble () const noexcept
 
long long asInteger () const noexcept
 
bool isIntegral () const noexcept
 
Kind getKind () const noexcept
 
std::string const & getLexeme () const noexcept
 
void setValue (double value)
 
void setValue (long long value)
 
- Public Member Functions inherited from fedem::fson::Value
virtual ~Value ()
 
bool isNull () const noexcept
 
bool isBoolean () const noexcept
 
bool isNumber () const noexcept
 
bool isString () const noexcept
 
bool isArray () const noexcept
 
bool isObject () const noexcept
 
virtual NullasNull () noexcept
 
virtual Null const * asNull () const noexcept
 
virtual BooleanasBoolean () noexcept
 
virtual Boolean const * asBoolean () const noexcept
 
virtual StringasString () noexcept
 
virtual String const * asString () const noexcept
 
virtual ArrayasArray () noexcept
 
virtual Array const * asArray () const noexcept
 
virtual ObjectasObject () noexcept
 
virtual Object const * asObject () const noexcept
 

Private Attributes

double value
 
std::string lexeme
 
Kind kind
 

Additional Inherited Members

- Protected Member Functions inherited from fedem::fson::Value
 Value ()=default
 

Member Enumeration Documentation

◆ Kind

Enumerator
Decimal 
Hex 
Infinity 
NegativeInfinity 
NaN 

Constructor & Destructor Documentation

◆ Number() [1/3]

fedem::fson::Number::Number ( double  value)
explicit

References kind, lexeme, and value.

Referenced by clone().

+ Here is the caller graph for this function:

◆ Number() [2/3]

fedem::fson::Number::Number ( long long  value)
explicit

◆ Number() [3/3]

fedem::fson::Number::Number ( double  value,
std::string  lexeme,
Kind  kind = Kind::Decimal 
)

Member Function Documentation

◆ getType()

Value::Type fedem::fson::Number::getType ( ) const
inlineoverridevirtualnoexcept

◆ clone()

unique_ptr< Value > fedem::fson::Number::clone ( ) const
overridevirtual

Implements fedem::fson::Value.

References Number(), kind, lexeme, and value.

+ Here is the call graph for this function:

◆ asNumber() [1/2]

Number * fedem::fson::Number::asNumber ( )
inlineoverridevirtualnoexcept

Reimplemented from fedem::fson::Value.

◆ asNumber() [2/2]

Number const * fedem::fson::Number::asNumber ( ) const
inlineoverridevirtualnoexcept

Reimplemented from fedem::fson::Value.

◆ asDouble()

double fedem::fson::Number::asDouble ( ) const
inlinenoexcept

References value.

Referenced by fedem::fson::Object::getDouble(), and fedem::fson::FsonWriter::writeNumber().

+ Here is the caller graph for this function:

◆ asInteger()

long long fedem::fson::Number::asInteger ( ) const
inlinenoexcept

References value.

Referenced by fedem::fson::Object::getInteger().

+ Here is the caller graph for this function:

◆ isIntegral()

bool fedem::fson::Number::isIntegral ( ) const
noexcept

◆ getKind()

Number::Kind fedem::fson::Number::getKind ( ) const
inlinenoexcept

References kind.

Referenced by fedem::fson::FsonWriter::writeNumber().

+ Here is the caller graph for this function:

◆ getLexeme()

std::string const & fedem::fson::Number::getLexeme ( ) const
inlinenoexcept

References lexeme.

Referenced by fedem::fson::FsonWriter::writeNumber().

+ Here is the caller graph for this function:

◆ setValue() [1/2]

void fedem::fson::Number::setValue ( double  value)

References kind, lexeme, and value.

◆ setValue() [2/2]

void fedem::fson::Number::setValue ( long long  value)

References Decimal, kind, lexeme, and value.

Member Data Documentation

◆ value

double fedem::fson::Number::value
private

◆ lexeme

std::string fedem::fson::Number::lexeme
private

◆ kind

Kind fedem::fson::Number::kind
private

The documentation for this class was generated from the following files: