Skip to content

File cxxaux.hh

FileList > ase > cxxaux.hh

  • #include <ase/sysconfig.h>
  • #include <sys/types.h>
  • #include <cstdint>
  • #include <string>
  • #include <functional>
  • #include <vector>
  • #include <memory>
  • #include <cmath>
  • #include <mutex>
  • #include <map>

Namespaces

Type Name
namespace Ase
The Anklang C++ API namespace.

Classes

Type Name
struct Id32
Helper class for integer IDs up to 32 Bit, possibly of enum type.
class Persistent <class Class>
struct VirtualBase
Common base type to allow casting between polymorphic classes.

Macros

Type Name
define ASE_ABS (a) ((a) < 0 ? -(a) : (a))
Yield the absolute value of a .
define ASE_ALIGN (size, base) ((base) * ((size_t (size) + (base) - 1) / (base)))
Round up size to multiples of__base .
define ASE_ALIGNED16 (pointer) (!ALIGNMENT16 (pointer))
define ASE_ALIGNMENT16 (pointer) (0xf & ptrdiff_t (pointer))
define ASE_ALWAYS_INLINE __attribute__ ((always_inline))
define ASE_ARRAY_SIZE (array) (sizeof (array) / sizeof ((array)[0]))
Yield the number of C array elements.
define ASE_ASSERT (expr) do { if (expr) [[likely]] break; ::Ase::assertion_fatal (#expr); } while (0)
Issue an assertion warning if expr evaluates to false.
define ASE_ASSERT_PARANOID (expr) do { if (expr) [[likely]] break; ::Ase::assertion_failed (#expr); } while (0)
Like ASE_ASSERT_WARN(), enabled if expensive expr are allowed.
define ASE_ASSERT_RETURN (expr, ...) do { if (expr) [[likely]] break; ::Ase::assertion_failed (#expr); return __VA_ARGS__; } while (0)
Return from the current function if expr evaluates to false and issue an assertion warning.
define ASE_ASSERT_RETURN_UNREACHED (...) do { ::Ase::assertion_failed (nullptr); return __VA_ARGS__; } while (0)
Return from the current function and issue an assertion warning.
define ASE_ASSERT_UNREACHED (...) do { ::Ase::assertion_fatal (nullptr); } while (0)
Abort and issue an assertion error.
define ASE_ASSERT_WARN (expr) do { if (expr) [[likely]] break; ::Ase::assertion_failed (#expr); } while (0)
Issue an assertion warning if expr evaluates to false.
define ASE_CLAMP (v, mi, ma) ((v) < (mi) ? (mi) : ((v) > (ma) ? (ma) : (v)))
Yield v clamped to [__mi ..__ma ].
define ASE_CLASS_DECLS (Klass)
Forward declare class Klass; as well asKlassP andKlassS asvector<KlassP> .
define ASE_CLASS_NON_COPYABLE (ClassName)
Delete copy ctor and assignment operator.
define ASE_COLD __attribute__ ((__cold__))
define ASE_CONST __attribute__ ((__const__))
define ASE_CONSTRUCTOR __attribute__ ((constructor,used))
define ASE_CPP_PASTE2 (a, b) ASE_CPP_PASTE2_ (a,b)
Paste two macro arguments into one C symbol name.
define ASE_CPP_PASTE2_ (a, b) a ## b
define ASE_CPP_STRINGIFY (s) ASE_CPP_STRINGIFY_ (s)
Convert macro argument into a C const char*.
define ASE_CPP_STRINGIFY_ (s) #s
define ASE_DEFINE_ENUM_EQUALITY (Enum)
define ASE_DEFINE_FLAGS_ARITHMETIC (Enum)
define ASE_DEFINE_MAKE_SHARED (CLASS)
define ASE_DEPRECATED __attribute__ ((__deprecated__))
define ASE_FORMAT (fx) __attribute__ ((__format_arg__ (fx)))
define ASE_HOT __attribute__ ((__hot__))
define ASE_ISLIKELY (expr) __builtin_expect (bool (expr), 1)
Compiler hint to optimize for expr evaluating to true.
define ASE_MALLOC __attribute__ ((__malloc__))
define ASE_MAX (a, b) ((a) >= (b) ? (a) : (b))
Yield the greater value of a and__b .
define ASE_MAY_ALIAS __attribute__ ((may_alias))
define ASE_MIN (a, b) ((a) <= (b) ? (a) : (b))
Yield the smaller value of a and__b .
define ASE_NOINLINE __attribute__ ((noinline))
define ASE_NORETURN __attribute__ ((__noreturn__))
define ASE_NO_INSTRUMENT __attribute__ ((__no_instrument_function__))
define ASE_PRINTF (fx, ax) __attribute__ ((__format__ (__printf__, fx, ax)))
define ASE_PURE __attribute__ ((__pure__))
define ASE_RETURN_UNLESS (cond, ...) do { if (ASE_UNLIKELY (!bool (cond))) return __VA_ARGS__; } while (0)
Return silently if cond does not evaluate to true, with return value___ ..._
define ASE_SCANF (fx, ax) __attribute__ ((__format__ (__scanf__, fx, ax)))
define ASE_SENTINEL __attribute__ ((__sentinel__))
define ASE_STRUCT_DECLS (Klass)
Forward declare struct Klass; as well as shared_ptrKlassP and vectorKlassS .
define ASE_UNLIKELY (expr) __builtin_expect (bool (expr), 0)
Compiler hint to optimize for expr evaluating to false.
define ASE_UNUSED __attribute__ ((__unused__))
define ASE_USED __attribute__ ((__used__))
define ASE_USE_RESULT __attribute__ ((warn_unused_result))
define ASE_WEAK __attribute__ ((__weak__))

Macro Definition Documentation

define ASE_ABS

#define ASE_ABS (
    a
) ((a) < 0 ? -(a) : (a))

define ASE_ALIGN

#define ASE_ALIGN (
    size,
    base
) ((base) * ((size_t (size) + (base) - 1) / (base)))

define ASE_ALIGNED16

#define ASE_ALIGNED16 (
    pointer
) (!ALIGNMENT16 (pointer))

define ASE_ALIGNMENT16

#define ASE_ALIGNMENT16 (
    pointer
) (0xf & ptrdiff_t (pointer))

define ASE_ALWAYS_INLINE

#define ASE_ALWAYS_INLINE __attribute__ ((always_inline))

define ASE_ARRAY_SIZE

#define ASE_ARRAY_SIZE (
    array
) (sizeof (array) / sizeof ((array)[0]))

define ASE_ASSERT

#define ASE_ASSERT (
    expr
) do { if (expr) [[likely]] break; ::Ase::assertion_fatal (#expr); } while (0)

define ASE_ASSERT_PARANOID

#define ASE_ASSERT_PARANOID (
    expr
) do { if (expr) [[likely]] break; ::Ase::assertion_failed (#expr); } while (0)

define ASE_ASSERT_RETURN

#define ASE_ASSERT_RETURN (
    expr,
    ...
) do { if (expr) [[likely]] break; ::Ase::assertion_failed (#expr); return __VA_ARGS__; } while (0)

define ASE_ASSERT_RETURN_UNREACHED

#define ASE_ASSERT_RETURN_UNREACHED (
    ...
) do { ::Ase::assertion_failed (nullptr); return __VA_ARGS__; } while (0)

define ASE_ASSERT_UNREACHED

#define ASE_ASSERT_UNREACHED (
    ...
) do { ::Ase::assertion_fatal (nullptr); } while (0)

define ASE_ASSERT_WARN

#define ASE_ASSERT_WARN (
    expr
) do { if (expr) [[likely]] break; ::Ase::assertion_failed (#expr); } while (0)

define ASE_CLAMP

#define ASE_CLAMP (
    v,
    mi,
    ma
) ((v) < (mi) ? (mi) : ((v) > (ma) ? (ma) : (v)))

define ASE_CLASS_DECLS

#define ASE_CLASS_DECLS (
    Klass
) class Klass;                                                  \
  using ASE_CPP_PASTE2 (Klass, W) = ::std::weak_ptr<Klass>;     \
  using ASE_CPP_PASTE2 (Klass, P) = ::std::shared_ptr<Klass>;   \
  using ASE_CPP_PASTE2 (Klass, S) = ::std::vector<ASE_CPP_PASTE2 (Klass, P)>;

define ASE_CLASS_NON_COPYABLE

#define ASE_CLASS_NON_COPYABLE (
    ClassName
) /*copy-ctor*/ ClassName  (const ClassName&) = delete; \
  ClassName&    operator=  (const ClassName&) = delete

define ASE_COLD

#define ASE_COLD __attribute__ ((__cold__))

define ASE_CONST

#define ASE_CONST __attribute__ ((__const__))

define ASE_CONSTRUCTOR

#define ASE_CONSTRUCTOR __attribute__ ((constructor,used))

define ASE_CPP_PASTE2

#define ASE_CPP_PASTE2 (
    a,
    b
) ASE_CPP_PASTE2_ (a,b)

define ASE_CPP_PASTE2_

#define ASE_CPP_PASTE2_ (
    a,
    b
) a ## b

define ASE_CPP_STRINGIFY

#define ASE_CPP_STRINGIFY (
    s
) ASE_CPP_STRINGIFY_ (s)

define ASE_CPP_STRINGIFY_

#define ASE_CPP_STRINGIFY_ (
    s
) #s

define ASE_DEFINE_ENUM_EQUALITY

#define ASE_DEFINE_ENUM_EQUALITY (
    Enum
) constexpr bool    operator== (Enum v, int64_t n) { return int64_t (v) == n; } \
  constexpr bool    operator== (int64_t n, Enum v) { return n == int64_t (v); } \
  constexpr bool    operator!= (Enum v, int64_t n) { return int64_t (v) != n; } \
  constexpr bool    operator!= (int64_t n, Enum v) { return n != int64_t (v); }

define ASE_DEFINE_FLAGS_ARITHMETIC

#define ASE_DEFINE_FLAGS_ARITHMETIC (
    Enum
) 

define ASE_DEFINE_MAKE_SHARED

#define ASE_DEFINE_MAKE_SHARED (
    CLASS
) struct MakeSharedAllocator_ : std::allocator<CLASS> {                 \
    template<typename ...Args>                                          \
    static void construct (CLASS *p, Args &&...args)                    \
    { ::new (p) CLASS (std::forward<Args> (args)...); }                 \
    static void destroy (CLASS *p)                                      \
    { p->~CLASS (); }                                                   \
    template<typename U> struct rebind {                                \
      using other =                                                     \
        std::conditional_t<std::is_same<U, CLASS>::value,               \
                           MakeSharedAllocator_, std::allocator<U>>;    \
    };                                                                  \
  };                                                                    \
  template<typename ...Args> static std::shared_ptr<CLASS>              \
  make_shared (Args &&...args)                                          \
  {                                                                     \
    return std::allocate_shared<CLASS> (MakeSharedAllocator_(),         \
                                        std::forward<Args> (args)...);  \
  }

Define a member function static shared_ptr<CLASS> make_shared(ctorargs...);. As member function, access to a private dtor and ctors is granted, so no std::allocator friend declaration is needed to define make_shared() for its own class.


define ASE_DEPRECATED

#define ASE_DEPRECATED __attribute__ ((__deprecated__))

define ASE_FORMAT

#define ASE_FORMAT (
    fx
) __attribute__ ((__format_arg__ (fx)))

define ASE_HOT

#define ASE_HOT __attribute__ ((__hot__))

define ASE_ISLIKELY

#define ASE_ISLIKELY (
    expr
) __builtin_expect (bool (expr), 1)

define ASE_MALLOC

#define ASE_MALLOC __attribute__ ((__malloc__))

define ASE_MAX

#define ASE_MAX (
    a,
    b
) ((a) >= (b) ? (a) : (b))

define ASE_MAY_ALIAS

#define ASE_MAY_ALIAS __attribute__ ((may_alias))

define ASE_MIN

#define ASE_MIN (
    a,
    b
) ((a) <= (b) ? (a) : (b))

define ASE_NOINLINE

#define ASE_NOINLINE __attribute__ ((noinline))

define ASE_NORETURN

#define ASE_NORETURN __attribute__ ((__noreturn__))

define ASE_NO_INSTRUMENT

#define ASE_NO_INSTRUMENT __attribute__ ((__no_instrument_function__))

define ASE_PRINTF

#define ASE_PRINTF (
    fx,
    ax
) __attribute__ ((__format__ (__printf__, fx, ax)))

define ASE_PURE

#define ASE_PURE __attribute__ ((__pure__))

define ASE_RETURN_UNLESS

#define ASE_RETURN_UNLESS (
    cond,
    ...
) do { if (ASE_UNLIKELY (!bool (cond))) return __VA_ARGS__; } while (0)

define ASE_SCANF

#define ASE_SCANF (
    fx,
    ax
) __attribute__ ((__format__ (__scanf__, fx, ax)))

define ASE_SENTINEL

#define ASE_SENTINEL __attribute__ ((__sentinel__))

define ASE_STRUCT_DECLS

#define ASE_STRUCT_DECLS (
    Klass
) struct Klass;                                                  \
  using ASE_CPP_PASTE2 (Klass, P) = ::std::shared_ptr<Klass>;   \
  using ASE_CPP_PASTE2 (Klass, S) = ::std::vector<Klass>;

define ASE_UNLIKELY

#define ASE_UNLIKELY (
    expr
) __builtin_expect (bool (expr), 0)

define ASE_UNUSED

#define ASE_UNUSED __attribute__ ((__unused__))

define ASE_USED

#define ASE_USED __attribute__ ((__used__))

define ASE_USE_RESULT

#define ASE_USE_RESULT __attribute__ ((warn_unused_result))

define ASE_WEAK

#define ASE_WEAK __attribute__ ((__weak__))


The documentation for this class was generated from the following file /__w/anklang/anklang/ase/cxxaux.hh