Pepper_31_C++_interfaces
Public Member Functions | List of all members
pp::VarDictionary Class Reference

#include <var_dictionary.h>

Inheritance diagram for pp::VarDictionary:
Inheritance graph
Collaboration diagram for pp::VarDictionary:
Collaboration graph

Public Member Functions

 VarDictionary ()
 Constructs a new dictionary var. More...
 
 VarDictionary (const Var &var)
 
 VarDictionary (const PP_Var &var)
 
 VarDictionary (const VarDictionary &other)
 Copy constructor. More...
 
virtual ~VarDictionary ()
 
VarDictionaryoperator= (const VarDictionary &other)
 Assignment operator. More...
 
virtual Varoperator= (const Var &other)
 
Var Get (const Var &key) const
 
bool Set (const Var &key, const Var &value)
 
void Delete (const Var &key)
 
bool HasKey (const Var &key) const
 
VarArray GetKeys () const
 
- Public Member Functions inherited from pp::Var
 Var ()
 
 Var (Null)
 A constructor used to create a Var of type Null. More...
 
 Var (bool b)
 
 Var (int32_t i)
 
 Var (double d)
 
 Var (const char *utf8_str)
 A constructor used to create a UTF-8 character Var. More...
 
 Var (const std::string &utf8_str)
 A constructor used to create a UTF-8 character Var. More...
 
 Var (PassRef, const PP_Var &var)
 
 Var (const PP_Var &var)
 A constructor that increments the reference count. More...
 
 Var (DontManage, const PP_Var &var)
 
 Var (const Var &other)
 A constructor for copying a Var. More...
 
virtual ~Var ()
 Destructor. More...
 
bool operator== (const Var &other) const
 
bool is_undefined () const
 
bool is_null () const
 
bool is_bool () const
 
bool is_string () const
 
bool is_object () const
 
bool is_array () const
 
bool is_dictionary () const
 
bool is_int () const
 
bool is_double () const
 
bool is_number () const
 
bool is_array_buffer () const
 This function determines if this Var is an ArrayBuffer. More...
 
bool AsBool () const
 
int32_t AsInt () const
 
double AsDouble () const
 
std::string AsString () const
 
const PP_Varpp_var () const
 
PP_Var Detach ()
 
std::string DebugString () const
 

Additional Inherited Members

- Protected Attributes inherited from pp::Var
PP_Var var_
 
bool is_managed_
 

Detailed Description

Definition at line 17 of file var_dictionary.h.

Constructor & Destructor Documentation

pp::VarDictionary::VarDictionary ( )

Constructs a new dictionary var.

pp::VarDictionary::VarDictionary ( const Var var)
explicit

Constructs a VarDictionary given a var for which is_dictionary() is true. This will refer to the same dictionary var, but allow you to access methods specific to dictionary.

Parameters
[in]varA dictionary var.
pp::VarDictionary::VarDictionary ( const PP_Var var)
explicit

Constructs a VarDictionary given a PP_Var of type PP_VARTYPE_DICTIONARY.

Parameters
[in]varA PP_Var of type PP_VARTYPE_DICTIONARY.
pp::VarDictionary::VarDictionary ( const VarDictionary other)

Copy constructor.

virtual pp::VarDictionary::~VarDictionary ( )
virtual

Member Function Documentation

void pp::VarDictionary::Delete ( const Var key)

Deletes the specified key and its associated value, if the key exists.

Parameters
[in]keyA string var.
Var pp::VarDictionary::Get ( const Var key) const

Gets the value associated with the specified key.

Parameters
[in]keyA string var.
Returns
The value that is associated with key. If key is not a string var, or it doesn't exist in the dictionary, an undefined var is returned.

Referenced by pp::ext::DictField< pp::ext::socket::SocketType_Dev >::Populate(), and pp::ext::OptionalDictField< int32_t >::Populate().

VarArray pp::VarDictionary::GetKeys ( ) const

Gets all the keys in the dictionary.

Returns
An array var which contains all the keys of the dictionary. The elements are string vars. Returns an empty array var if failed.
bool pp::VarDictionary::HasKey ( const Var key) const

Checks whether a key exists.

Parameters
[in]keyA string var.
Returns
A bool indicating whether the key exists.
VarDictionary& pp::VarDictionary::operator= ( const VarDictionary other)

Assignment operator.

virtual Var& pp::VarDictionary::operator= ( const Var other)
virtual

The Var assignment operator is overridden here so that we can check for assigning a non-dictionary var to a VarDictionary.

Parameters
[in]otherThe dictionary var to be assigned.
Returns
The resulting VarDictionary (as a Var&).

Reimplemented from pp::Var.

bool pp::VarDictionary::Set ( const Var key,
const Var value 
)

Sets the value associated with the specified key.

Parameters
[in]keyA string var. If this key hasn't existed in the dictionary, it is added and associated with value; otherwise, the previous value is replaced with value.
[in]valueThe value to set.
Returns
A bool indicating whether the operation succeeds.

Referenced by pp::ext::DictField< pp::ext::socket::SocketType_Dev >::AddTo(), and pp::ext::OptionalDictField< int32_t >::MayAddTo().


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