SQT
A C++ ORM framework for SQLite
Loading...
Searching...
No Matches

◆ SQT_COLUMN_ACCESSOR_DEFAULT

#define SQT_COLUMN_ACCESSOR_DEFAULT ( COLUMN_NAME,
GETTER,
SETTER,
DEFAULT_VALUE )

Defines a column with a default value that binds to the specified accessor methods of the entity type.

Parameters
COLUMN_NAMEThe name of the column in the database. It will be also used as the instance name of the column.
GETTERA const member function of the entity type that retrieves the column value from an entity instance.
SETTERA non-const member function of the entity type that assigns the column value to an entity instance.
DEFAULT_VALUEThe default value of the column.

This macro is similar to the SQT_COLUMN_ACCESSOR macro, except that it allows specifying a default value for the column.

Example usage:

class MyEntity {
public:
int GetID() const {
return id_;
}
void SetID(int id) {
id_ = id;
}
const std::string& GetName() const {
return name_;
}
void SetName(std::string_view name) {
name_ = std::string{ name };
}
private:
int id_{};
std::string name_;
};
SQT_TABLE_BEGIN(MyEntityTable, MyEntity)
SQT_COLUMN_ACCESSOR_DEFAULT(ID, GetID, SetID, 0)
SQT_COLUMN_ACCESSOR_DEFAULT(Name, GetName, SetName, "default_name")
#define SQT_TABLE_BEGIN(TABLE_NAME, ENTITY_TYPE)
Begins the definition of a table type for the specified entity type.
Definition table_definition.h:147
#define SQT_TABLE_END
Ends the definition of a table type.
Definition table_definition.h:1091
#define SQT_COLUMN_ACCESSOR_DEFAULT(COLUMN_NAME, GETTER, SETTER, DEFAULT_VALUE)
Defines a column with a default value that binds to the specified accessor methods of the entity type...
Definition table_definition.h:545
See also
SQT_COLUMN_ACCESSOR