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::make_shared<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>

Public Member Functions

 CYIBundle ()
 
 CYIBundle (const CYIBundle &bundle)
 
 CYIBundle (CYIBundle &&bundle) noexcept
 
virtual ~CYIBundle ()
 
CYIBundleoperator= (const CYIBundle &bundle)
 
CYIBundleoperator= (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
 
const CYIAnyGet (const CYIString &key) const
 
std::vector< CYIStringGetKeys () const
 
bool IsKeyPresent (const CYIString &key) const
 
void Clear ()
 

Protected Member Functions

virtual void OnDataModified (const CYIString &key)
 

Constructor & Destructor Documentation

◆ CYIBundle() [1/3]

CYIBundle::CYIBundle ( )

◆ CYIBundle() [2/3]

CYIBundle::CYIBundle ( const CYIBundle bundle)

Constructs a CYIBundle from the given bundle.

◆ CYIBundle() [3/3]

CYIBundle::CYIBundle ( CYIBundle &&  bundle)
noexcept

Constructs a CYIBundle from the given bundle.

◆ ~CYIBundle()

virtual CYIBundle::~CYIBundle ( )
virtual

Member Function Documentation

◆ Clear()

void CYIBundle::Clear ( )

Clear the CYIBundle.

◆ Get() [1/3]

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.

◆ Get() [2/3]

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.

◆ Get() [3/3]

const CYIAny& CYIBundle::Get ( const CYIString key) const

Returns the CYIAny value for the specified key.

◆ GetKeys()

std::vector<CYIString> CYIBundle::GetKeys ( ) const

Returns the list of all keys in the bundle.

◆ GetWithDefault()

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.

◆ IsKeyPresent()

bool CYIBundle::IsKeyPresent ( const CYIString key) const

Checks for the presence of a key.

◆ OnDataModified()

virtual void CYIBundle::OnDataModified ( const CYIString key)
protectedvirtual

◆ operator=() [1/2]

CYIBundle& CYIBundle::operator= ( const CYIBundle bundle)

Copy the content from the bundle.

◆ operator=() [2/2]

CYIBundle& CYIBundle::operator= ( CYIBundle &&  bundle)

Move the content from the bundle.

◆ Put()

template<typename T >
void CYIBundle::Put ( const CYIString key,
T &&  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: