dxd - dynax driver framework 3.0.1f223
cross platform open source driver development framework
Loading...
Searching...
No Matches
dx_serialize.h File Reference
This graph shows which files directly or indirectly include this file:

Classes

struct  dx::present::bitmap< names_t >
 bits each named: names() the (name, bit) pairs More...
struct  dx::present::choice< options_t >
 one of options(): the (name, value) pairs the struct allows as it stands More...
struct  dx::present::power2
 a power of two, and the half-way values, from min to max More...

Namespaces

namespace  dx
 dynax driver framework interface namespace
namespace  dx::present

Macros

#define DX_EQUAL_array(id, ids)
#define DX_EQUAL_bitmap(id, names)
#define DX_EQUAL_choice(id, options)
#define DX_EQUAL_cstr(id)
#define DX_EQUAL_direction(id)
#define DX_EQUAL_fourchar(id)
#define DX_EQUAL_level(id)
#define DX_EQUAL_matrix(id)
#define DX_EQUAL_nested(id)
#define DX_EQUAL_power2(id, min, max)
#define DX_EQUAL_value(id)
#define DX_EQUAL_vector(id)
#define DX_TREE_GET_array(id, ids)
#define DX_TREE_GET_bitmap(id, names)
#define DX_TREE_GET_choice(id, options)
#define DX_TREE_GET_cstr(id)
#define DX_TREE_GET_direction(id)
#define DX_TREE_GET_fourchar(id)
#define DX_TREE_GET_level(id)
#define DX_TREE_GET_matrix(id)
#define DX_TREE_GET_nested(id)
#define DX_TREE_GET_power2(id, min, max)
#define DX_TREE_GET_value(id)
#define DX_TREE_GET_vector(id)
#define DX_TREE_SERIALIZE(members)
 the tree serialization pair a struct's member list expands into, the visit that shows it and the equality
#define DX_TREE_SET_array(id, ids)
#define DX_TREE_SET_bitmap(id, names)
#define DX_TREE_SET_choice(id, options)
#define DX_TREE_SET_cstr(id)
#define DX_TREE_SET_direction(id)
#define DX_TREE_SET_fourchar(id)
#define DX_TREE_SET_level(id)
#define DX_TREE_SET_matrix(id)
#define DX_TREE_SET_nested(id)
#define DX_TREE_SET_power2(id, min, max)
#define DX_TREE_SET_value(id)
 member lists and their serialization sinks
#define DX_TREE_SET_vector(id)
#define DX_VISIT_access(id)
#define DX_VISIT_array(id, ids)
#define DX_VISIT_bitmap(id, names)
#define DX_VISIT_choice(id, options)
#define DX_VISIT_cstr(id)
#define DX_VISIT_direction(id)
#define DX_VISIT_fourchar(id)
#define DX_VISIT_level(id)
#define DX_VISIT_matrix(id)
#define DX_VISIT_nested(id)
#define DX_VISIT_power2(id, min, max)
#define DX_VISIT_value(id)
#define DX_VISIT_vector(id)

Functions

template<typename names_t>
 dx::present::bitmap (names_t) -> bitmap< names_t >
template<typename options_t>
 dx::present::choice (options_t) -> choice< options_t >

Macro Definition Documentation

◆ DX_EQUAL_array

#define DX_EQUAL_array ( id,
ids )
Value:
&& ids== other.ids&& [&]{\
for(uint32_t idx= 0; idx< ids&& idx< sizeof_array(id); idx++)\
if(!(id[idx]== other.id[idx]))\
return false;\
return true;}()
#define sizeof_array(array)
Definition dx_macros.h:129
unsigned int uint32_t
Definition wdk/dxd_platform.h:117

◆ DX_EQUAL_bitmap

#define DX_EQUAL_bitmap ( id,
names )
Value:
#define DX_EQUAL_value(id)
Definition dx_serialize.h:115

◆ DX_EQUAL_choice

#define DX_EQUAL_choice ( id,
options )
Value:

◆ DX_EQUAL_cstr

#define DX_EQUAL_cstr ( id)
Value:
&& !::strncmp(id, other.id, sizeof(id))

◆ DX_EQUAL_direction

#define DX_EQUAL_direction ( id)
Value:

◆ DX_EQUAL_fourchar

#define DX_EQUAL_fourchar ( id)
Value:

◆ DX_EQUAL_level

#define DX_EQUAL_level ( id)
Value:

◆ DX_EQUAL_matrix

#define DX_EQUAL_matrix ( id)
Value:
#define DX_EQUAL_vector(id)
Definition dx_serialize.h:124

◆ DX_EQUAL_nested

#define DX_EQUAL_nested ( id)
Value:

◆ DX_EQUAL_power2

#define DX_EQUAL_power2 ( id,
min,
max )
Value:

◆ DX_EQUAL_value

#define DX_EQUAL_value ( id)
Value:
&& id== other.id

The equality sink compares what the list names - an array up to its count, a C string up to its end - so neither the padding nor the unused slots of an array decide it; a nested member compares with its own operator ==, a format with its match against a wish.

◆ DX_EQUAL_vector

#define DX_EQUAL_vector ( id)
Value:
&& !::memcmp(id, other.id, sizeof(id))

◆ DX_TREE_GET_array

#define DX_TREE_GET_array ( id,
ids )
Value:
{const uint32_t count= static_cast<uint32_t>(tree[#id].size());\
for(ids= 0; ids< count&& ids< sizeof_array(id); ids++)\
id[ids].read(tree[#id][std::to_string(ids)]);}

◆ DX_TREE_GET_bitmap

#define DX_TREE_GET_bitmap ( id,
names )
Value:
#define DX_TREE_GET_value(id)
Definition dx_serialize.h:44

◆ DX_TREE_GET_choice

#define DX_TREE_GET_choice ( id,
options )
Value:

◆ DX_TREE_GET_cstr

#define DX_TREE_GET_cstr ( id)
Value:
{::strncpy(id, static_cast<std::string>(tree[#id](std::string{id})).c_str(), sizeof(id)- 1); id[sizeof(id)- 1]= {};}

◆ DX_TREE_GET_direction

#define DX_TREE_GET_direction ( id)
Value:
id= dx::stream::direction::from::string[static_cast<std::string>(tree[#id](dx::stream::direction::to::string[id]))];

◆ DX_TREE_GET_fourchar

#define DX_TREE_GET_fourchar ( id)
Value:
reinterpret_cast<uint32_t&>(id)= dx::fourchar::from::string(\
static_cast<std::string>(tree[#id](dx::fourchar::to::string(reinterpret_cast<const uint32_t&>(id)))).c_str());
uint32_t string(const char *fourchar)
Definition dx_common.h:565
std::string string(uint32_t fourchar)
Definition dx_common.h:549

◆ DX_TREE_GET_level

#define DX_TREE_GET_level ( id)
Value:
id= dx::log::from::string(static_cast<std::string>(tree[#id](std::string{dx::log::to::string(id)})).c_str());
static level string(const char *level)
Definition dx_log.h:68
static constexpr const char * string(level level)
Definition dx_log.h:57

◆ DX_TREE_GET_matrix

#define DX_TREE_GET_matrix ( id)
Value:
for(uint32_t row= 0; row< sizeof_array(id); row++)\
for(uint32_t col= 0; col< sizeof_array(id[row]); col++)\
id[row][col]= static_cast<std::remove_reference_t<decltype(id[row][col])>>(\
tree[#id][std::to_string(row)][std::to_string(col)](static_cast<uint32_t>(id[row][col])));

◆ DX_TREE_GET_nested

#define DX_TREE_GET_nested ( id)
Value:
id.read(tree[#id]);

◆ DX_TREE_GET_power2

#define DX_TREE_GET_power2 ( id,
min,
max )
Value:

◆ DX_TREE_GET_value

#define DX_TREE_GET_value ( id)
Value:
id= static_cast<decltype(id)>(tree[#id](static_cast<uint32_t>(id)));

◆ DX_TREE_GET_vector

#define DX_TREE_GET_vector ( id)
Value:
for(uint32_t idx= 0; idx< sizeof_array(id); idx++)\
id[idx]= static_cast<std::remove_reference_t<decltype(id[idx])>>(tree[#id][std::to_string(idx)](static_cast<uint32_t>(id[idx])));

◆ DX_TREE_SERIALIZE

#define DX_TREE_SERIALIZE ( members)
Value:
template<typename tree_t> void write(const tree_t& tree) const {members(DX_TREE_SET)}\
template<typename tree_t> void read(const tree_t& tree) {members(DX_TREE_GET)}\
template<typename visitor_t> void visit(visitor_t&& visitor) {members(DX_VISIT)}\
bool operator ==(const auto& other) const {return true members(DX_EQUAL);}
bool operator==(const std::string &id, const ::GUID &guid)
Definition dx_proxy.h:347

the tree serialization pair a struct's member list expands into, the visit that shows it and the equality

◆ DX_TREE_SET_array

#define DX_TREE_SET_array ( id,
ids )
Value:
for(uint32_t idx= 0; idx< ids&& idx< sizeof_array(id); idx++)\
id[idx].write(tree[#id][std::to_string(idx)]);

◆ DX_TREE_SET_bitmap

#define DX_TREE_SET_bitmap ( id,
names )
Value:
#define DX_TREE_SET_value(id)
member lists and their serialization sinks
Definition dx_serialize.h:43

◆ DX_TREE_SET_choice

#define DX_TREE_SET_choice ( id,
options )
Value:

◆ DX_TREE_SET_cstr

#define DX_TREE_SET_cstr ( id)
Value:
tree[#id]= std::string{id};

◆ DX_TREE_SET_direction

#define DX_TREE_SET_direction ( id)
Value:
tree[#id]= dx::stream::direction::to::string[id];

◆ DX_TREE_SET_fourchar

#define DX_TREE_SET_fourchar ( id)
Value:
tree[#id]= dx::fourchar::to::string(reinterpret_cast<const uint32_t&>(id));

◆ DX_TREE_SET_level

#define DX_TREE_SET_level ( id)
Value:
tree[#id]= std::string{dx::log::to::string(id)};

◆ DX_TREE_SET_matrix

#define DX_TREE_SET_matrix ( id)
Value:
for(uint32_t row= 0; row< sizeof_array(id); row++)\
for(uint32_t col= 0; col< sizeof_array(id[row]); col++)\
tree[#id][std::to_string(row)][std::to_string(col)]= static_cast<uint32_t>(id[row][col]);

◆ DX_TREE_SET_nested

#define DX_TREE_SET_nested ( id)
Value:
id.write(tree[#id]);

◆ DX_TREE_SET_power2

#define DX_TREE_SET_power2 ( id,
min,
max )
Value:

◆ DX_TREE_SET_value

#define DX_TREE_SET_value ( id)
Value:
tree[#id]= static_cast<uint32_t>(id);

member lists and their serialization sinks

Each struct names its members once, as a DX_MEMBERS_<struct> list of X##_<kind>(member[, count]) entries, and hands that list to a sink macro. The store's is the dx::key_value_tree one below, which recurses through named child nodes instead of flattening the struct into one opaque value - into a preference store, the registry, or a property's dictionary held as a cf::store (macOS, where the desc is also the device tree's wire format - see dx::coreaudio::pod::device's desc property).

A scalar rides as uint32_t so it lands in the store's own integer type (REG_DWORD) rather than a sizeof-wide byte copy - bitfields and bool included. An array's elements are the decimal index, read back by the node's own child count, so their order is numeric by construction and never depends on how the store sorts key names.

◆ DX_TREE_SET_vector

#define DX_TREE_SET_vector ( id)
Value:
for(uint32_t idx= 0; idx< sizeof_array(id); idx++)\
tree[#id][std::to_string(idx)]= static_cast<uint32_t>(id[idx]);

◆ DX_VISIT_access

#define DX_VISIT_access ( id)
Value:
[this]{return static_cast<uint32_t>(id);}, [this](uint32_t value){id= static_cast<decltype(id)>(value);}

◆ DX_VISIT_array

#define DX_VISIT_array ( id,
ids )
Value:
visitor(#id, id, ids);

◆ DX_VISIT_bitmap

#define DX_VISIT_bitmap ( id,
names )
Value:
visitor(#id, dx::present::bitmap{[]{return names();}}, DX_VISIT_access(id));
#define DX_VISIT_access(id)
Definition dx_serialize.h:96
bits each named: names() the (name, bit) pairs
Definition dx_serialize.h:90

◆ DX_VISIT_choice

#define DX_VISIT_choice ( id,
options )
Value:
visitor(#id, dx::present::choice{[this]{return options();}}, DX_VISIT_access(id));
one of options(): the (name, value) pairs the struct allows as it stands
Definition dx_serialize.h:91

◆ DX_VISIT_cstr

#define DX_VISIT_cstr ( id)
Value:
visitor(#id, id);

◆ DX_VISIT_direction

#define DX_VISIT_direction ( id)
Value:
visitor(#id, id);

◆ DX_VISIT_fourchar

#define DX_VISIT_fourchar ( id)
Value:
visitor(#id, dx::fourchar::to::string(reinterpret_cast<const uint32_t&>(id)));

◆ DX_VISIT_level

#define DX_VISIT_level ( id)
Value:
visitor(#id, id);

◆ DX_VISIT_matrix

#define DX_VISIT_matrix ( id)
Value:
visitor(#id, id);

◆ DX_VISIT_nested

#define DX_VISIT_nested ( id)
Value:
visitor(#id, id);

◆ DX_VISIT_power2

#define DX_VISIT_power2 ( id,
min,
max )
Value:
visitor(#id, dx::present::power2{min, max}, DX_VISIT_access(id));
a power of two, and the half-way values, from min to max
Definition dx_serialize.h:89

◆ DX_VISIT_value

#define DX_VISIT_value ( id)
Value:
visitor(#id, static_cast<decltype(id)*>(nullptr), DX_VISIT_access(id));

◆ DX_VISIT_vector

#define DX_VISIT_vector ( id)
Value:
visitor(#id, id);