Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Attributes | List of all members
skjson::StringValue Class Referencefinal

#include <SkJSON.h>

Inheritance diagram for skjson::StringValue:
skjson::Value

Public Member Functions

 StringValue ()
 
 StringValue (const char *src, SkArenaAlloc &alloc)
 
 StringValue (const char *src, size_t size, SkArenaAlloc &alloc)
 
size_t size () const
 
const char * begin () const
 
const char * end () const
 
std::string_view str () 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::kString
 

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 292 of file SkJSON.h.

Constructor & Destructor Documentation

◆ StringValue() [1/3]

skjson::StringValue::StringValue ( )

◆ StringValue() [2/3]

skjson::StringValue::StringValue ( const char *  src,
SkArenaAlloc alloc 
)

Definition at line 201 of file SkJSON.cpp.

202 : StringValue(src, strlen(src), alloc) {}

◆ StringValue() [3/3]

skjson::StringValue::StringValue ( const char *  src,
size_t  size,
SkArenaAlloc alloc 
)

Definition at line 204 of file SkJSON.cpp.

204 {
205 new (this) FastString(src, size, src, alloc);
206}
size_t size() const
Definition: SkJSON.h:300

Member Function Documentation

◆ begin()

const char * skjson::StringValue::begin ( ) const
inline

Definition at line 315 of file SkJSON.h.

315 {
316 return this->getTag() == Tag::kShortString
317 ? this->cast<char>()
318 : this->cast<VectorValue<char, Value::Type::kString>>()->begin();
319 }
const char * begin() const
Definition: SkJSON.h:315
const T * cast() const
Definition: SkJSON.h:184
Tag getTag() const
Definition: SkJSON.h:148

◆ end()

const char * skjson::StringValue::end ( ) const
inline

Definition at line 321 of file SkJSON.h.

321 {
322 return this->getTag() == Tag::kShortString
323 ? strchr(this->cast<char>(), '\0')
324 : this->cast<VectorValue<char, Value::Type::kString>>()->end();
325 }
const char * end() const
Definition: SkJSON.h:321

◆ size()

size_t skjson::StringValue::size ( ) const
inline

Definition at line 300 of file SkJSON.h.

300 {
301 switch (this->getTag()) {
303 // We don't bother storing a length for short strings on the assumption
304 // that strlen is fast in this case. If this becomes problematic, we
305 // can either go back to storing (7-len) in the tag byte or write a fast
306 // short_strlen.
307 return strlen(this->cast<char>());
308 case Tag::kString:
309 return this->cast<VectorValue<char, Value::Type::kString>>()->size();
310 default:
311 return 0;
312 }
313 }

◆ str()

std::string_view skjson::StringValue::str ( ) const
inline

Definition at line 327 of file SkJSON.h.

327 {
328 return std::string_view(this->begin(), this->size());
329 }

Member Data Documentation

◆ kType

constexpr Type skjson::StringValue::kType = Type::kString
inlinestaticconstexpr

Definition at line 294 of file SkJSON.h.


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