Shaka Player Embedded
Public Member Functions | Static Public Member Functions | List of all members
shaka::Any Class Reference

#include <any.h>

Inheritance diagram for shaka::Any:
shaka::GenericConverter shaka::memory::Traceable

Public Member Functions

 Any ()
 
 Any (std::nullptr_t)
 
template<typename T >
 Any (const T &value)
 
 ~Any () override
 
 Any (const Any &)
 
 Any (Any &&)
 
Anyoperator= (const Any &)
 
Anyoperator= (Any &&)
 
bool IsTruthy () const
 
template<typename T >
bool TryConvertTo (T *result) const
 
bool TryConvert (Handle< JsValue > value) override
 
ReturnVal< JsValue > ToJsValue () const override
 
void Trace (memory::HeapTracer *tracer) const override
 
- Public Member Functions inherited from shaka::GenericConverter
virtual ~GenericConverter ()
 
- Public Member Functions inherited from shaka::memory::Traceable
virtual ~Traceable ()
 
virtual bool IsRootedAlive () const
 
virtual bool IsShortLived () const
 

Static Public Member Functions

static std::string name ()
 

Additional Inherited Members

- Static Public Attributes inherited from shaka::memory::Traceable
static constexpr const uint64_t kShortLiveDurationMs = 5000
 

Detailed Description

Defines any JavaScript value. This allows accepting any value and includes methods to convert to different types.

Definition at line 31 of file any.h.

Constructor & Destructor Documentation

§ Any() [1/5]

shaka::Any::Any ( )

Definition at line 23 of file any.cc.

§ Any() [2/5]

shaka::Any::Any ( std::nullptr_t  )
explicit

Definition at line 24 of file any.cc.

§ Any() [3/5]

template<typename T >
shaka::Any::Any ( const T &  value)
inlineexplicit

Definition at line 40 of file any.h.

§ ~Any()

shaka::Any::~Any ( )
override

Definition at line 25 of file any.cc.

§ Any() [4/5]

shaka::Any::Any ( const Any )
default

§ Any() [5/5]

shaka::Any::Any ( Any &&  )
default

Member Function Documentation

§ IsTruthy()

bool shaka::Any::IsTruthy ( ) const

Returns whether the value contained is a "truthy" value. The following values are falsy, everything else is truthy:

  • undefined
  • null
  • "" (empty string)
  • false (boolean)
  • NaN (number)
  • 0 (number)

Definition at line 32 of file any.cc.

§ name()

static std::string shaka::Any::name ( )
inlinestatic

Definition at line 33 of file any.h.

§ operator=() [1/2]

Any & shaka::Any::operator= ( const Any )
default

§ operator=() [2/2]

Any & shaka::Any::operator= ( Any &&  )
default

§ ToJsValue()

ReturnVal< JsValue > shaka::Any::ToJsValue ( ) const
overridevirtual

Converts the current value into a JavaScript value.

Implements shaka::GenericConverter.

Definition at line 56 of file any.cc.

§ Trace()

void shaka::Any::Trace ( memory::HeapTracer tracer) const
overridevirtual

Called during a GC run. This should call HeapTracer::Trace on all Traceable members. Be sure to call the base method when overriding.

Implements shaka::memory::Traceable.

Definition at line 60 of file any.cc.

§ TryConvert()

bool shaka::Any::TryConvert ( Handle< JsValue >  value)
overridevirtual

Tries to convert the given value into the required type, populating the members of this object as needed.

Returns
True on success, false on error.

Implements shaka::GenericConverter.

Definition at line 50 of file any.cc.

§ TryConvertTo()

template<typename T >
bool shaka::Any::TryConvertTo ( T *  result) const
inline

Tries to convert the current value into the given type. This can only be called on the event thread.

Parameters
result[OUT] Where to put the converted value.
Returns
True on success, false on failure.

Definition at line 72 of file any.h.


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