Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
skjson::ObjectValue Class Referencefinal

#include <SkJSON.h>

Inheritance diagram for skjson::ObjectValue:
skjson::VectorValue< Member, Value::Type::kObject > skjson::Value

Public Member Functions

 ObjectValue (const Member *src, size_t size, SkArenaAlloc &alloc)
 
const Valueoperator[] (const char *key) const
 
Valuewritable (const char *key, SkArenaAlloc &) const
 
- Public Member Functions inherited from skjson::VectorValue< Member, Value::Type::kObject >
size_t size () const
 
const Memberbegin () const
 
const Memberend () const
 
const Memberoperator[] (size_t i) 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
 

Additional Inherited Members

- Public Types inherited from skjson::VectorValue< Member, Value::Type::kObject >
using ValueT = Member
 
- Public Types inherited from skjson::Value
enum class  Type {
  kNull , kBool , kNumber , kString ,
  kArray , kObject
}
 
- Static Public Attributes inherited from skjson::VectorValue< Member, Value::Type::kObject >
static constexpr Type kType
 
- 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 337 of file SkJSON.h.

Constructor & Destructor Documentation

◆ ObjectValue()

skjson::ObjectValue::ObjectValue ( const Member src,
size_t  size,
SkArenaAlloc alloc 
)

Definition at line 208 of file SkJSON.cpp.

208 {
209 this->init_tagged_pointer(Tag::kObject, MakeVector<Member>(size, src, alloc));
210 SkASSERT(this->getTag() == Tag::kObject);
211}
#define SkASSERT(cond)
Definition: SkAssert.h:116
Tag getTag() const
Definition: SkJSON.h:148
void init_tagged_pointer(Tag, void *)
Definition: SkJSON.cpp:45

Member Function Documentation

◆ operator[]()

const Value & skjson::ObjectValue::operator[] ( const char *  key) const
inline

Definition at line 341 of file SkJSON.h.

341 {
342 static const Value gNullValue = NullValue();
343
344 const auto* member = this->find(key);
345 return member
346 ? member->fValue
347 : gNullValue;
348 }

◆ writable()

Value & skjson::ObjectValue::writable ( const char *  key,
SkArenaAlloc alloc 
) const

Definition at line 244 of file SkJSON.cpp.

244 {
245 Member* writable_member = const_cast<Member*>(this->find(key));
246
247 if (!writable_member) {
248 ObjectValue* writable_obj = const_cast<ObjectValue*>(this);
249 writable_obj->init_tagged_pointer(Tag::kObject, MakeVector<Member>(this->size() + 1,
250 this->begin(),
251 this->size(),
252 alloc));
253 writable_member = const_cast<Member*>(writable_obj->end() - 1);
254 writable_member->fKey = StringValue(key, strlen(key), alloc);
255 writable_member->fValue = NullValue();
256 }
257
258
259 return writable_member->fValue;
260}
ObjectValue(const Member *src, size_t size, SkArenaAlloc &alloc)
Definition: SkJSON.cpp:208

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