13 const bool casesensitive =
true;
14 return Ase::kvpairs_assign (kvs, key_value_pair, casesensitive);
31static uint base_registry_count = 0;
33 template<
class O,
class M>
void
37 using value_type =
decltype (m->get());
38 const ptrdiff_t offset = ptrdiff_t (m) - ptrdiff_t (o);
39 auto accessor = [offset] (O *o, value_type *v) {
40 const ptrdiff_t maddr = ptrdiff_t (o) + offset;
41 M *m =
reinterpret_cast<M*
> (maddr);
45 std::function<value_type(O*,value_type*)> accessor_func = accessor;
46 tlog +=
string_format (
"BaseRegistry=%d;\n", ++base_registry_count);
50struct Widget : BaseRegistry {
51 char f_ = {};
void f_s (
const char n) { f_ = n; f.notify(); }
char f_g()
const { tlog +=
string_format (
"Widget.f=%d\n", f_);
return f_; }
52 char g_ = 0;
void g_s (
const char &n) { g_ = n; g.notify(); }
char g_g ()
const {
return g_; }
54 int bit_g () { tlog +=
string_format (
"realgetter=%d\n", bit_);
return bit_; }
55 int bit_s (
const int &bit) { tlog +=
string_format (
"realsetter=%d\n", bit);
return bit_ = bit; }
61 f (this,
"f", {
"blurb=_f_property",
"" }),
62 g (
this,
"g", {
"blurb=_g_property",
"", })
65 tlog +=
string_format (
"sizeof(Widget)=%zd (%p)\n",
sizeof (Widget),
this);
66 tlog +=
string_format (
"sizeof(bit_)=%zd (%p)\n",
sizeof (bit_), &bit_);
67 tlog +=
string_format (
"sizeof(bit)=%zd (%p) [[no_unique_address]]\n",
sizeof (bit), &bit);
68 tlog +=
string_format (
"sizeof(f_)=%zd (%p)\n",
sizeof (f_), &f_);
69 tlog +=
string_format (
"sizeof(f)=%zd (%p) [[no_unique_address]]\n",
sizeof (f), &f);
70 tlog +=
string_format (
"sizeof(g_)=%zd (%p)\n",
sizeof (g_), &g_);
71 tlog +=
string_format (
"sizeof(g)=%zd (%p) [[no_unique_address]]\n",
sizeof (g), &g);
87 TASSERT (
sizeof (Widget) <= 2 *
sizeof (
int));
94 tlog +=
string_format (
"Widget: { Widget = { .bit=%d, .f=%d, .g=%d };\n", w.bit_, w.f(),
int (w.g));
96 TASSERT (w.bit.get() == -17171 && w.f == 71 && w.g == -128);
97 TASSERT (w.f.info (
"blurb") ==
"_f_property");
98 TASSERT (w.g.info (
"blurb") ==
"_g_property");
Implement C++ member field API with a 0-sized class from setter and getter, maybe combined with [[no_...
static ssize_t search(const String ®ex, const String &input, Flags=DEFAULT)
Find regex in input and return match position >= 0 or return < 0 otherwise.
#define assert_return(expr,...)
Return from the current function if expr is unmet and issue an assertion warning.
#define TEST_INTEGRITY(FUNC)
Register func as an integrity test.
The Anklang C++ API namespace.
std::string string_format(const char *format, const Args &...args) __attribute__((__format__(__printf__
Format a string similar to sprintf(3) with support for std::string and std::ostringstream convertible...
uint32_t uint
Provide 'uint' as convenience type.
#define TASSERT(cond)
Unconditional test assertion, enters breakpoint if not fullfilled.