Types
Type utilities and generic and typed interfaces to objects in a store.
stored::Function
- 
template<typename T, typename Container>
class Function A typed function in a store.
This class only works for functions with fixed-length arguments (see stored::Type::isFixed()). Otherwise, use stored::Variant.
A Function is very small (it contains two words). It is default copyable and assignable, so it is fine to pass it by value.
Public Functions
- 
inline constexpr Function(Container &container, unsigned int f) noexcept
 Constructor for a valid Function.
- 
template<typename U>
inline U as() const Returns the value, like get(), cast to the given type.
Only call this function when it is valid().
- 
inline size_t callback(bool set, type &value) const
 Invoke the callback at the container().
- 
inline size_t callback(bool set, void *buffer, size_t len) const
 Invoke the callback at the container().
- 
inline Container &container() const noexcept
 Returns the container this Function belongs to.
Only call this function when it is valid().
- 
inline type get() const
 Calls the function and return its value.
Only call this function when it is valid().
- 
inline size_t get(void *dst, size_t len) const
 Calls the function and write its value in the given buffer.
Only call this function when it is valid().
- Parameters:
 dst – the buffer to write to
len – the length of
dst, normally equal to size()
- Returns:
 the number of bytes written to
dst
- 
inline unsigned int id() const noexcept
 Returns the function ID.
Only call this function when it is valid().
- 
inline bool operator!=(Function const &rhs) const noexcept
 Checks if this Function points to the same Function as the given one.
- 
inline bool operator==(Function const &rhs) const noexcept
 Checks if this Function points to the same Function as the given one.
- 
inline void set(type value) const
 Call the function to write the value.
Only call this function when it is valid().
Public Static Functions
- 
static inline constexpr size_t size() noexcept
 Returns the size of the function’s argument.
- 
inline constexpr Function(Container &container, unsigned int f) noexcept
 
stored::toType
stored::Variable
- 
template<typename T, typename Container, bool Hooks = Config::EnableHooks>
class Variable A typed variable in a store.
This class only works for fixed-length variables (see stored::Type::isFixed()). Otherwise, use stored::Variant.
A Variable is very small (it contains only a pointer). It is copyable and assignable, so it is fine to pass it by value.
Public Functions
- 
inline Variable(Variable const &v) noexcept
 Copy construct, such that this Variable points to the same buffer the given Variable does.
- 
inline ~Variable() noexcept
 Dtor.
- 
template<typename U>
inline U as() const noexcept Returns the value, like get(), cast to the given type.
Only call this function when it is valid().
- 
inline constexpr bool operator!=(Variable const &rhs) const noexcept
 Checks if two Variables do not point to the same buffer.
- 
inline Variable &operator=(Variable const &v) noexcept
 Let this Variable point to the same buffer as the given Variable.
Public Static Functions
- 
static inline constexpr size_t size() noexcept
 Returns the size of the data.
- 
inline Variable(Variable const &v) noexcept
 
stored::Variable with hooks
- 
template<typename T, typename Container>
class Variable<T, Container, true> : public stored::Variable<T, Container, false> A typed variable in a store, with hook support.
This class only works for fixed-length variables (see stored::Type::isFixed()). Otherwise, use stored::Variant.
This Variable is very small (it contains two pointers). It is copyable and assignable, so it is fine to pass it by value.
Public Types
Public Functions
- 
inline constexpr Variable(Container &container, type &buffer) noexcept
 Constructor for a valid Variable.
- 
inline Variable(Variable const &v) noexcept
 Copy construct, such that this Variable points to the same buffer the given Variable does.
- 
inline ~Variable() noexcept
 Dtor.
- 
template<typename U>
inline U as() const noexcept Returns the value, like get(), cast to the given type.
Only call this function when it is valid().
- 
inline void entryRO() const noexcept
 Calls the
entryRO()hook of the container.See also
your store’s
hookEntryRO()
- 
inline void entryX() const noexcept
 Calls the
entryX()hook of the container.See also
your store’s
hookEntryX()
- 
inline void exitRO() const noexcept
 Calls the
exitRO()hook of the container.See also
your store’s
hookExitRO()
- 
inline void exitX(bool changed) const noexcept
 Calls the
exitX()hook of the container.See also
your store’s
hookExitX()
- 
inline type get() const noexcept
 Returns the value.
Only call this function when it is valid().
entryRO()/exitRO() are called around the actual data retrieval.
- 
inline Container::Key key() const noexcept
 Returns the key that belongs to this Variable.
See also
your store’s bufferToKey()
Public Static Functions
- 
static inline constexpr size_t size() noexcept
 Returns the size of the data.
- 
inline constexpr Variable(Container &container, type &buffer) noexcept
 
stored::Variant
- 
template<typename Container>
class Variant A untyped interface to an object in a store.
This class works for all variables and functions of all types. However, using stored::Variable or stored::Function is more efficient both in performance and memory. Use those when you can.
A Variant is quite small (only about four words). It is default copyable and assignable, so it is fine to pass it by value.
Public Functions
- 
inline Variant(Container &container, Type::type type, unsigned int f, size_t len) noexcept
 Constructor for a function.
- 
inline Variant(Container &container, Type::type type, void *buffer, size_t len) noexcept
 Constructor for a variable.
- 
template<typename T>
inline explicit constexpr Variant(Function<T, Container> const &f) noexcept Constructor for a Function.
- 
template<typename T>
inline explicit constexpr Variant(Variable<T, Container> const &v) noexcept Constructor for a Variable.
- 
inline void *buffer() const noexcept
 Returns the buffer.
Only call this function when it is valid().
- 
inline size_t callback(bool set, void *buffer, size_t len) const
 Invoke the function callback.
Only works if this variant is a function.
- 
inline Container &container() const noexcept
 Returns the container.
Only call this function when it is valid().
- 
template<typename C>
inline void copy(Variant<C> const &other) noexcept Copies data from a Variant from another Container.
This copies data directly, without type conversion. This may come in handy when data of the same variable of different stores (or between stores with different wrappers) should be copied.
Only use this when:
- 
inline void entryRO() const noexcept
 Invokes
hookEntryRO()on the container().
- 
inline void entryRO(size_t len) const noexcept
 Invokes
hookEntryRO()on the container().
- 
inline void entryX() const noexcept
 Invokes
hookEntryX()on the container().
- 
inline void entryX(size_t len) const noexcept
 Invokes
hookEntryX()on the container().
- 
inline void exitRO() const noexcept
 Invokes
hookExitRO()on the container().
- 
inline void exitRO(size_t len) const noexcept
 Invokes
hookExitRO()on the container().
- 
inline void exitX(bool changed) const noexcept
 Invokes
hookExitX()on the container().
- 
inline void exitX(bool changed, size_t len) const noexcept
 Invokes
hookExitX()on the container().
- 
template<typename T>
inline Function<T, Container> function() const noexcept Returns a stored::Function that corresponds to this Variant.
Only call this function when it isFunction() and the type() matches
T.
- 
template<typename T>
inline T get() const Wrapper for get(void*,size_t) const that converts the type.
This only works for fixed types. Make sure that type() matches
T.
- 
inline Vector<char>::type get() const
 Gets the value.
See also
- 
inline size_t get(void *dst, size_t len = 0) const
 Get the value.
For variables, entryRO()/exitRO() is called.
In case type() is Type::String, only up to the first null byte are copied. If
dstis sufficiently large (len> size()), a null terminator is always written after the string.Only call this function when valid().
- Parameters:
 dst – the buffer to copy to
len – the length of
dst, when this is a fixed type, 0 implies the normal size
- Returns:
 the number of bytes written into
dst
- 
inline bool isFunction() const noexcept
 Checks if the type() is a function.
Only call this function when it is valid().
- 
inline bool isVariable() const noexcept
 Checks if the type() is a variable.
Only call this function when it is valid().
- 
inline Container::Key key() const noexcept
 Returns the key of this variable.
Only call this function when it isVariable().
See also
your store’s
bufferToKey()
- 
inline bool operator!=(Variant const &rhs) const noexcept
 Checks if this Variant points to the same object as the given one.
- 
inline bool operator==(Variant const &rhs) const noexcept
 Checks if this Variant points to the same object as the given one.
- 
inline void set(char const *data)
 Sets a string.
Only works if this variant is a string.
- 
inline void set(QString const &value)
 Sets a string.
Only works if this variant is a string.
- 
inline bool set(QVariant const &v)
 Set the value, given a QVariant.
- Returns:
 trueupon success
- 
template<typename T>
inline void set(T value) Wrapper for set(void const*,size_t) that converts the type.
This only works for fixed types. Make sure that type() matches
T.
- 
inline void set(Vector<char>::type const &data)
 Sets the value.
See also
- 
inline size_t set(void const *src, size_t len = 0)
 Set the value.
For variables, entryX()/exitX() is called.
In case type() is Type::String, only up to the first null byte are copied. If there is no null byte in
src, it is implicitly appended at the end.Only call this function when valid().
- Parameters:
 src – the buffer to copy from
len – the length of
src, when this is a fixed type, 0 implies the normal size
- Returns:
 the number of bytes read from
src
- 
inline size_t size() const noexcept
 Returns the size.
In case type() is Type::String, this returns the maximum size of the string, excluding null terminator.
Only call this function when it is valid().
- 
inline QString toQString() const
 Convert the value to a QString.
Only works if the type() is String.
- 
inline QVariant toQVariant() const
 Convert the value to a QVariant.
- 
inline Type::type type() const noexcept
 Returns the type.
Only call this function when it is valid().
- 
template<typename T>
inline Variable<T, Container> variable() const noexcept Returns a stored::Variable that corresponds to this Variant.
Only call this function when it isVariable() and the type() matches
T.
- 
inline Variant(Container &container, Type::type type, unsigned int f, size_t len) noexcept
 
stored::Variant<void>
- 
template<>
class Variant<void> A store-independent untyped wrapper for an object.
It is not usable, until it is applied to a store. All member functions, except for apply() are there to match the Variant’s interface, but are non-functional, as there is no container.
See also
Public Functions
- 
inline constexpr Variant(Type::type type, uintptr_t buffer_offset_or_f, size_t len) noexcept
 Constructor for a variable or function.
- 
template<typename Container>
inline Variant<Container> apply(Container &container) const noexcept Apply the stored object properties to a container.
- 
inline int &container() const noexcept
 Don’t use.
- 
inline void entryRO(size_t len = 0) const noexcept
 Don’t use.
- 
inline void entryX(size_t len = 0) const noexcept
 Don’t use.
- 
inline void exitRO(size_t len = 0) const noexcept
 Don’t use.
- 
inline void exitX(bool changed, size_t len = 0) const noexcept
 Don’t use.
- 
template<typename T, typename Container>
inline FreeFunction<T, Container> function() const noexcept Get the typed function corresponding to this variant, which is not bound to a specific store yet.
- 
template<typename T, typename Container>
inline Variable<T, Container> function(Container &container) const noexcept Get the typed function corresponding to this variant.
- 
inline size_t get(void *dst, size_t len = 0) const noexcept
 Don’t use.
- 
inline bool operator!=(Variant const &rhs) const noexcept
 Checks if this Variant points to the same object as the given one.
- 
inline bool operator==(Variant const &rhs) const noexcept
 Checks if this Variant points to the same object as the given one.
- 
inline size_t set(void const *src, size_t len = 0) noexcept
 Don’t use.
- 
inline size_t size() const noexcept
 Returns the size.
- 
inline constexpr Type::type type() const noexcept
 Returns the type.
- 
inline constexpr Variant(Type::type type, uintptr_t buffer_offset_or_f, size_t len) noexcept