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
{
bundle.
Put(
"myObject", std::make_shared<MyObject>());
return bundle;
}
{
bundle.
Get(
"searchTerm", &searchTerm);
std::shared_ptr<MyObject> myObject;
bundle.
Get(
"myObject", &myObject);
}
#include <utility/YiBundle.h>
◆ CYIBundle() [1/3]
◆ CYIBundle() [2/3]
CYIBundle::CYIBundle |
( |
const CYIBundle & |
bundle | ) |
|
Constructs a CYIBundle from the given bundle.
◆ CYIBundle() [3/3]
Constructs a CYIBundle from the given bundle.
◆ ~CYIBundle()
virtual CYIBundle::~CYIBundle |
( |
| ) |
|
|
virtual |
◆ Clear()
void CYIBundle::Clear |
( |
| ) |
|
◆ 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]
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]
Copy the content from the bundle.
◆ operator=() [2/2]
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: