You.i Engine
CYIBundle Class Reference

Detailed Description

CYIBundle represents a collection of key-value pairs.

Warning
Not to be used with arrays of char.
There isn't any type checking for Get(). Make sure you pass in the right type.

Usage Examples

CYIBundle CreateBundle()
{
CYIBundle bundle;
bundle.Put("searchTerm", CYIString("Indiana Jones"));
bundle.Put("myObject", std::shared_ptr<MyObject>(new MyObject()));
return bundle;
}
void ParseBundle(CYIBundle bundle)
{
CYIString searchTerm;
bundle.Get("searchTerm", &searchTerm);
std::shared_ptr<MyObject> myObject;
bundle.Get("myObject", &myObject);
}

#include <utility/YiBundle.h>

Inheritance diagram for CYIBundle:

Public Member Functions

 CYIBundle ()
 
 CYIBundle (const CYIBundle &bundle)
 
virtual ~CYIBundle ()
 
CYIBundleoperator= (const CYIBundle &bundle)
 
template<typename T >
void Put (const CYIString &key, T value)
 
template<typename T >
bool Get (const CYIString &key, T *pValue) const
 
template<typename T >
GetWithDefault (const CYIString &key, const T &defaultValue) const
 
template<typename T >
Get (const CYIString &key) const
 
bool IsKeyPresent (const CYIString &key) const
 
void Clear ()
 
- Public Member Functions inherited from CYIScriptableObject
 CYIScriptableObject ()
 
 CYIScriptableObject (const CYIScriptableObject &other)
 
CYIScriptableObjectoperator= (const CYIScriptableObject &other)
 
virtual ~CYIScriptableObject ()
 
CYIBindingImplementationGetBindingImplementation () const
 
void SetBindingImplementation (CYIBindingImplementation *pBindingImplementation)
 
virtual const CYIRuntimeTypeInfoGetRuntimeTypeInfoForScriptObject () const
 

Protected Member Functions

virtual void OnDataModified (const CYIString &key)
 

Constructor & Destructor Documentation

CYIBundle::CYIBundle ( )
CYIBundle::CYIBundle ( const CYIBundle bundle)

Constructs a CYIBundle from the given bundle.

virtual CYIBundle::~CYIBundle ( )
virtual

Member Function Documentation

void CYIBundle::Clear ( )

Clear the CYIBundle.

template<typename T >
bool CYIBundle::Get ( const CYIString key,
T *  pValue 
) const

Retrieve the value for the specified key. Returns true if the key is found, otherwise false.

template<typename T >
T CYIBundle::Get ( const CYIString key) const

Retrieve the value for the specified key. If the provided key is not found in the bundle, the default constructor of T is used to construct a default value. A warning is also logged.

template<typename T >
T CYIBundle::GetWithDefault ( const CYIString key,
const T &  defaultValue 
) const

Retrieve the value for the specified key. If the provided key is not found in the bundle, the provided default value is returned.

bool CYIBundle::IsKeyPresent ( const CYIString key) const

Checks for the presence of a key.

virtual void CYIBundle::OnDataModified ( const CYIString key)
protectedvirtual
CYIBundle& CYIBundle::operator= ( const CYIBundle bundle)

Copy the content from the bundle.

template<typename T >
void CYIBundle::Put ( const CYIString key,
value 
)

Add a key-value pair. If the key already exist, it is overwritten.


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