NAWA 0.9
Web Application Framework for C++
macros.h File Reference

Macros for frequently used patterns. More...

#include <experimental/propagate_const>
#include <memory>

Go to the source code of this file.

Macros

#define NAWA_PRIVATE_DATA()
 
#define NAWA_DEFAULT_DESTRUCTOR_DEF(Class)   virtual ~Class()
 
#define NAWA_DEFAULT_DESTRUCTOR_OVERRIDE_DEF(Class)   ~Class() override
 
#define NAWA_DEFAULT_DESTRUCTOR_IMPL(Class)   Class::~Class() = default;
 
#define NAWA_DEFAULT_DESTRUCTOR_IMPL_WITH_NS(Namespace, Class)   Namespace::Class::~Class() = default;
 
#define NAWA_DEFAULT_CONSTRUCTOR_DEF(Class)   Class()
 
#define NAWA_DEFAULT_CONSTRUCTOR_IMPL(Class)    Class::Class() { data = make_unique<Data>(); }
 
#define NAWA_DEFAULT_CONSTRUCTOR_IMPL_WITH_NS(Namespace, Class)    Namespace::Class::Class() { data = make_unique<Data>(); }
 
#define NAWA_COPY_CONSTRUCTOR_DEF(Class)   Class(Class const& other)
 
#define NAWA_COPY_CONSTRUCTOR_IMPL(Class)    Class::Class(const Class& other) { data = make_unique<Data>(*other.data); }
 
#define NAWA_COPY_CONSTRUCTOR_IMPL_WITH_NS(Namespace, Class)    Namespace::Class::Class(const Namespace::Class& other) { data = make_unique<Data>(*other.data); }
 
#define NAWA_COPY_CONSTRUCTOR_DERIVED_IMPL(Class, Parent)    Class::Class(const Class& other) : Parent(other) { data = make_unique<Data>(*other.data); }
 
#define NAWA_COPY_CONSTRUCTOR_DERIVED_IMPL_WITH_NS(Namespace, Class, Parent)    Namespace::Class::Class(const Namespace::Class& other) : Parent(other) { data = make_unique<Data>(*other.data); }
 
#define NAWA_COPY_ASSIGNMENT_OPERATOR_DEF(Class)   Class& operator=(const Class& other)
 
#define NAWA_COPY_ASSIGNMENT_OPERATOR_IMPL(Class)
 
#define NAWA_COPY_ASSIGNMENT_OPERATOR_IMPL_WITH_NS(Namespace, Class)
 
#define NAWA_COPY_ASSIGNMENT_OPERATOR_DERIVED_IMPL(Class, Parent)
 
#define NAWA_COPY_ASSIGNMENT_OPERATOR_DERIVED_IMPL_WITH_NS(Namespace, Class, Parent)
 
#define NAWA_MOVE_CONSTRUCTOR_DEF(Class)   Class(Class&& other) noexcept
 
#define NAWA_MOVE_CONSTRUCTOR_IMPL(Class)    Class::Class(Class&& other) noexcept : data(std::move(other.data)) {}
 
#define NAWA_MOVE_CONSTRUCTOR_IMPL_WITH_NS(Namespace, Class)    Namespace::Class::Class(Namespace::Class&& other) noexcept : data(std::move(other.data)) {}
 
#define NAWA_MOVE_CONSTRUCTOR_DERIVED_IMPL(Class, Parent)    Class::Class(Class&& other) noexcept : Parent(std::move(other)), data(std::move(other.data)) {}
 
#define NAWA_MOVE_CONSTRUCTOR_DERIVED_IMPL_WITH_NS(Namespace, Class, Parent)    Namespace::Class::Class(Namespace::Class&& other) noexcept : Parent(std::move(other)), data(std::move(other.data)) {}
 
#define NAWA_MOVE_ASSIGNMENT_OPERATOR_DEF(Class)   Class& operator=(Class&& other) noexcept
 
#define NAWA_MOVE_ASSIGNMENT_OPERATOR_IMPL(Class)
 
#define NAWA_MOVE_ASSIGNMENT_OPERATOR_IMPL_WITH_NS(Namespace, Class)
 
#define NAWA_MOVE_ASSIGNMENT_OPERATOR_DERIVED_IMPL(Class, Parent)
 
#define NAWA_MOVE_ASSIGNMENT_OPERATOR_DERIVED_IMPL_WITH_NS(Namespace, Class, Parent)
 
#define NAWA_PRIMITIVE_DATA_ACCESSORS_DEF(Class, Member, Type)
 
#define NAWA_COMPLEX_DATA_ACCESSORS_DEF(Class, Member, Type)
 
#define NAWA_PRIMITIVE_DATA_ACCESSORS_IMPL(Class, Member, Type)
 
#define NAWA_COMPLEX_DATA_ACCESSORS_IMPL(Class, Member, Type)
 

Detailed Description

Macros for frequently used patterns.

Definition in file macros.h.

Macro Definition Documentation

◆ NAWA_PRIVATE_DATA

#define NAWA_PRIVATE_DATA ( )
Value:
struct Data; \
std::experimental::propagate_const<std::unique_ptr<Data>> data;

Definition at line 30 of file macros.h.

◆ NAWA_DEFAULT_DESTRUCTOR_DEF

#define NAWA_DEFAULT_DESTRUCTOR_DEF (   Class)    virtual ~Class()

Definition at line 34 of file macros.h.

◆ NAWA_DEFAULT_DESTRUCTOR_OVERRIDE_DEF

#define NAWA_DEFAULT_DESTRUCTOR_OVERRIDE_DEF (   Class)    ~Class() override

Definition at line 35 of file macros.h.

◆ NAWA_DEFAULT_DESTRUCTOR_IMPL

#define NAWA_DEFAULT_DESTRUCTOR_IMPL (   Class)    Class::~Class() = default;

Definition at line 36 of file macros.h.

◆ NAWA_DEFAULT_DESTRUCTOR_IMPL_WITH_NS

#define NAWA_DEFAULT_DESTRUCTOR_IMPL_WITH_NS (   Namespace,
  Class 
)    Namespace::Class::~Class() = default;

Definition at line 37 of file macros.h.

◆ NAWA_DEFAULT_CONSTRUCTOR_DEF

#define NAWA_DEFAULT_CONSTRUCTOR_DEF (   Class)    Class()

Definition at line 39 of file macros.h.

◆ NAWA_DEFAULT_CONSTRUCTOR_IMPL

#define NAWA_DEFAULT_CONSTRUCTOR_IMPL (   Class)     Class::Class() { data = make_unique<Data>(); }

Definition at line 40 of file macros.h.

◆ NAWA_DEFAULT_CONSTRUCTOR_IMPL_WITH_NS

#define NAWA_DEFAULT_CONSTRUCTOR_IMPL_WITH_NS (   Namespace,
  Class 
)     Namespace::Class::Class() { data = make_unique<Data>(); }

Definition at line 42 of file macros.h.

◆ NAWA_COPY_CONSTRUCTOR_DEF

#define NAWA_COPY_CONSTRUCTOR_DEF (   Class)    Class(Class const& other)

Definition at line 45 of file macros.h.

◆ NAWA_COPY_CONSTRUCTOR_IMPL

#define NAWA_COPY_CONSTRUCTOR_IMPL (   Class)     Class::Class(const Class& other) { data = make_unique<Data>(*other.data); }

Definition at line 46 of file macros.h.

◆ NAWA_COPY_CONSTRUCTOR_IMPL_WITH_NS

#define NAWA_COPY_CONSTRUCTOR_IMPL_WITH_NS (   Namespace,
  Class 
)     Namespace::Class::Class(const Namespace::Class& other) { data = make_unique<Data>(*other.data); }

Definition at line 48 of file macros.h.

◆ NAWA_COPY_CONSTRUCTOR_DERIVED_IMPL

#define NAWA_COPY_CONSTRUCTOR_DERIVED_IMPL (   Class,
  Parent 
)     Class::Class(const Class& other) : Parent(other) { data = make_unique<Data>(*other.data); }

Definition at line 50 of file macros.h.

◆ NAWA_COPY_CONSTRUCTOR_DERIVED_IMPL_WITH_NS

#define NAWA_COPY_CONSTRUCTOR_DERIVED_IMPL_WITH_NS (   Namespace,
  Class,
  Parent 
)     Namespace::Class::Class(const Namespace::Class& other) : Parent(other) { data = make_unique<Data>(*other.data); }

Definition at line 52 of file macros.h.

◆ NAWA_COPY_ASSIGNMENT_OPERATOR_DEF

#define NAWA_COPY_ASSIGNMENT_OPERATOR_DEF (   Class)    Class& operator=(const Class& other)

Definition at line 55 of file macros.h.

◆ NAWA_COPY_ASSIGNMENT_OPERATOR_IMPL

#define NAWA_COPY_ASSIGNMENT_OPERATOR_IMPL (   Class)
Value:
Class& Class::operator=(const Class& other) { \
if (this != &other) { \
*data = *other.data; \
} \
return *this; \
}

Definition at line 56 of file macros.h.

◆ NAWA_COPY_ASSIGNMENT_OPERATOR_IMPL_WITH_NS

#define NAWA_COPY_ASSIGNMENT_OPERATOR_IMPL_WITH_NS (   Namespace,
  Class 
)
Value:
Namespace::Class& Namespace::Class::operator=(const Namespace::Class& other) { \
if (this != &other) { \
*data = *other.data; \
} \
return *this; \
}

Definition at line 63 of file macros.h.

◆ NAWA_COPY_ASSIGNMENT_OPERATOR_DERIVED_IMPL

#define NAWA_COPY_ASSIGNMENT_OPERATOR_DERIVED_IMPL (   Class,
  Parent 
)
Value:
Class& Class::operator=(const Class& other) { \
if (this != &other) { \
Parent::operator=(other); \
*data = *other.data; \
} \
return *this; \
}

Definition at line 70 of file macros.h.

◆ NAWA_COPY_ASSIGNMENT_OPERATOR_DERIVED_IMPL_WITH_NS

#define NAWA_COPY_ASSIGNMENT_OPERATOR_DERIVED_IMPL_WITH_NS (   Namespace,
  Class,
  Parent 
)
Value:
Namespace::Class& Namespace::Class::operator=(const Namespace::Class& other) { \
if (this != &other) { \
Parent::operator=(other); \
*data = *other.data; \
} \
return *this; \
}

Definition at line 78 of file macros.h.

◆ NAWA_MOVE_CONSTRUCTOR_DEF

#define NAWA_MOVE_CONSTRUCTOR_DEF (   Class)    Class(Class&& other) noexcept

Definition at line 87 of file macros.h.

◆ NAWA_MOVE_CONSTRUCTOR_IMPL

#define NAWA_MOVE_CONSTRUCTOR_IMPL (   Class)     Class::Class(Class&& other) noexcept : data(std::move(other.data)) {}

Definition at line 88 of file macros.h.

◆ NAWA_MOVE_CONSTRUCTOR_IMPL_WITH_NS

#define NAWA_MOVE_CONSTRUCTOR_IMPL_WITH_NS (   Namespace,
  Class 
)     Namespace::Class::Class(Namespace::Class&& other) noexcept : data(std::move(other.data)) {}

Definition at line 90 of file macros.h.

◆ NAWA_MOVE_CONSTRUCTOR_DERIVED_IMPL

#define NAWA_MOVE_CONSTRUCTOR_DERIVED_IMPL (   Class,
  Parent 
)     Class::Class(Class&& other) noexcept : Parent(std::move(other)), data(std::move(other.data)) {}

Definition at line 92 of file macros.h.

◆ NAWA_MOVE_CONSTRUCTOR_DERIVED_IMPL_WITH_NS

#define NAWA_MOVE_CONSTRUCTOR_DERIVED_IMPL_WITH_NS (   Namespace,
  Class,
  Parent 
)     Namespace::Class::Class(Namespace::Class&& other) noexcept : Parent(std::move(other)), data(std::move(other.data)) {}

Definition at line 94 of file macros.h.

◆ NAWA_MOVE_ASSIGNMENT_OPERATOR_DEF

#define NAWA_MOVE_ASSIGNMENT_OPERATOR_DEF (   Class)    Class& operator=(Class&& other) noexcept

Definition at line 97 of file macros.h.

◆ NAWA_MOVE_ASSIGNMENT_OPERATOR_IMPL

#define NAWA_MOVE_ASSIGNMENT_OPERATOR_IMPL (   Class)
Value:
Class& Class::operator=(Class&& other) noexcept { \
if (this != &other) { \
data = std::move(other.data); \
} \
return *this; \
}

Definition at line 98 of file macros.h.

◆ NAWA_MOVE_ASSIGNMENT_OPERATOR_IMPL_WITH_NS

#define NAWA_MOVE_ASSIGNMENT_OPERATOR_IMPL_WITH_NS (   Namespace,
  Class 
)
Value:
Namespace::Class& Namespace::Class::operator=(Namespace::Class&& other) noexcept { \
if (this != &other) { \
data = std::move(other.data); \
} \
return *this; \
}

Definition at line 105 of file macros.h.

◆ NAWA_MOVE_ASSIGNMENT_OPERATOR_DERIVED_IMPL

#define NAWA_MOVE_ASSIGNMENT_OPERATOR_DERIVED_IMPL (   Class,
  Parent 
)
Value:
Class& Class::operator=(Class&& other) noexcept { \
if (this != &other) { \
data = std::move(other.data); \
Parent::operator=(std::move(other)); \
} \
return *this; \
}

Definition at line 112 of file macros.h.

◆ NAWA_MOVE_ASSIGNMENT_OPERATOR_DERIVED_IMPL_WITH_NS

#define NAWA_MOVE_ASSIGNMENT_OPERATOR_DERIVED_IMPL_WITH_NS (   Namespace,
  Class,
  Parent 
)
Value:
Namespace::Class& Namespace::Class::operator=(Namespace::Class&& other) noexcept { \
if (this != &other) { \
data = std::move(other.data); \
Parent::operator=(std::move(other)); \
} \
return *this; \
}

Definition at line 120 of file macros.h.

◆ NAWA_PRIMITIVE_DATA_ACCESSORS_DEF

#define NAWA_PRIMITIVE_DATA_ACCESSORS_DEF (   Class,
  Member,
  Type 
)
Value:
Type& Member() noexcept; \
[[nodiscard]] Type Member() const noexcept; \
Class& Member(Type value) noexcept

Definition at line 129 of file macros.h.

◆ NAWA_COMPLEX_DATA_ACCESSORS_DEF

#define NAWA_COMPLEX_DATA_ACCESSORS_DEF (   Class,
  Member,
  Type 
)
Value:
Type& Member() noexcept; \
[[nodiscard]] Type const& Member() const noexcept; \
Class& Member(Type value) noexcept

Definition at line 133 of file macros.h.

◆ NAWA_PRIMITIVE_DATA_ACCESSORS_IMPL

#define NAWA_PRIMITIVE_DATA_ACCESSORS_IMPL (   Class,
  Member,
  Type 
)
Value:
Type& Class::Member() noexcept { return data->Member; } \
Type Class::Member() const noexcept { return data->Member; } \
Class& Class::Member(Type value) noexcept { \
data->Member = value; \
return *this; \
}

Definition at line 137 of file macros.h.

◆ NAWA_COMPLEX_DATA_ACCESSORS_IMPL

#define NAWA_COMPLEX_DATA_ACCESSORS_IMPL (   Class,
  Member,
  Type 
)
Value:
Type& Class::Member() noexcept { return data->Member; } \
Type const& Class::Member() const noexcept { return data->Member; } \
Class& Class::Member(Type value) noexcept { \
data->Member = std::move(value); \
return *this; \
}

Definition at line 144 of file macros.h.