-
Notifications
You must be signed in to change notification settings - Fork 6
ValueList type
etnKlendathu edited this page Sep 24, 2021
·
1 revision
pack::ValueList<BasicType>
ValueList is container specialized to hold BasicType. Exist slight difference between this type and ObjectList.
Pack defines some useful ValuesList<BasicType> as types:
using Int32List = ValueList<Type::Int32>;
using Int64List = ValueList<Type::Int64>;
using UInt32List = ValueList<Type::UInt32>;
using UInt64List = ValueList<Type::UInt64>;
using FloatList = ValueList<Type::Float>;
using DoubleList = ValueList<Type::Double>;
using BoolList = ValueList<Type::Bool>;
using StringList = ValueList<Type::String>;
Some useful methods (for BasicType::CppType see mapping in BasicType):
- Returns std::vector<BasicType::CppType>
const ListType& value() const;
- Sets std::vector<BasicType::CppType>
void setValue(const ListType& val);
- Appends BasicType::CppType to the container
void append(const CppType& value); void append(CppType&& value);
- Finds value in container (TODO: return int index as result)
bool find(const CppType& val) const;
- Remove values from container by it's value
bool remove(const CppType& toRemove);
- Return a reference to value by index
const CppType& operator[](int index) const;
- Returns true if container contains values
bool empty() const;
- Sorts list by comparison function object. Comparison function object should be same as described in std::sort
template <typename Func> void sort(Func&& func);
Create list of strings:
pack::StringList list = {"the", "blue", "parrot"};
Serialize it:
std::cerr << *pack::json::serialize(list) << std::endl;
Output would be:
["the", "blue", "parrot"]