Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | List of all members
skjson::NumberValue Class Referencefinal

#include <SkJSON.h>

Inheritance diagram for skjson::NumberValue:
skjson::Value

Public Member Functions

 NumberValue (int32_t)
 
 NumberValue (float)
 
double operator* () const
 
- Public Member Functions inherited from skjson::Value
Type getType () const
 
template<typename T >
bool is () const
 
template<typename T >
const Tas () const
 
template<typename T >
 operator const T * () const
 
SkString toString () const
 
const Valueoperator[] (const char *key) const
 

Static Public Attributes

static constexpr Type kType = Type::kNumber
 

Additional Inherited Members

- Public Types inherited from skjson::Value
enum class  Type {
  kNull , kBool , kNumber , kString ,
  kArray , kObject
}
 
- Protected Types inherited from skjson::Value
enum class  Tag : uint8_t {
  kShortString = 0b00000000 , kNull = 0b00000001 , kBool = 0b00000010 , kInt = 0b00000011 ,
  kFloat = 0b00000100 , kString = 0b00000101 , kArray = 0b00000110 , kObject = 0b00000111
}
 
- Protected Member Functions inherited from skjson::Value
void init_tagged (Tag)
 
void init_tagged_pointer (Tag, void *)
 
Tag getTag () const
 
template<typename T >
const Tcast () const
 
template<typename T >
Tcast ()
 
template<typename T >
const Tptr () const
 
- Static Protected Attributes inherited from skjson::Value
static constexpr uint8_t kTagMask = 0b00000111
 

Detailed Description

Definition at line 239 of file SkJSON.h.

Constructor & Destructor Documentation

◆ NumberValue() [1/2]

skjson::NumberValue::NumberValue ( int32_t  i)
explicit

Definition at line 73 of file SkJSON.cpp.

73 {
75 *this->cast<int32_t>() = i;
76 SkASSERT(this->getTag() == Tag::kInt);
77}
#define SkASSERT(cond)
Definition SkAssert.h:116
Tag getTag() const
Definition SkJSON.h:148
void init_tagged(Tag)
Definition SkJSON.cpp:38

◆ NumberValue() [2/2]

skjson::NumberValue::NumberValue ( float  f)
explicit

Definition at line 79 of file SkJSON.cpp.

79 {
81 *this->cast<float>() = f;
82 SkASSERT(this->getTag() == Tag::kFloat);
83}

Member Function Documentation

◆ operator*()

double skjson::NumberValue::operator* ( ) const
inline

Definition at line 246 of file SkJSON.h.

246 {
247 SkASSERT(this->getTag() == Tag::kInt ||
248 this->getTag() == Tag::kFloat);
249
250 return this->getTag() == Tag::kInt
251 ? static_cast<double>(*this->cast<int32_t>())
252 : static_cast<double>(*this->cast<float>());
253 }
const T * cast() const
Definition SkJSON.h:184

Member Data Documentation

◆ kType

constexpr Type skjson::NumberValue::kType = Type::kNumber
inlinestaticconstexpr

Definition at line 241 of file SkJSON.h.


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