matador::field Class Reference

Describes a database column field. More...

#include <field.hpp>

Public Member Functions

 field ()
 Creates an empty field.
 
 field (const char *name)
 Creates a named field.
 
 field (const std::string &name)
 Creates a named field.
 
 ~field ()
 Destroy a field.
 
size_t index () const
 Returns the index of the field in table.
 
void index (size_t i)
 Sets the index in table of the field.
 
std::string name () const
 Returns the name of the field.
 
void name (const std::string &n)
 Sets the name of the field.
 
database_type type () const
 Returns the type of the field.
 
void type (database_type t)
 Sets the type of the field.
 
std::size_t size () const
 Returns the size of the field.
 
void size (std::size_t s)
 Sets the size of the field.
 
std::size_t precision () const
 Returns the precision of the field.
 
void precision (std::size_t p)
 Sets the precision of the field.
 
bool is_not_null () const
 Returns true if NULL value is not allowed.
 
void not_null (bool nn)
 Set to true if NULL value is not allowed for this field.
 
std::string default_value () const
 Returns the default value as string.
 
void default_value (const std::string &value)
 Sets the default value as string.
 

Detailed Description

Describes a database column field.

Constructor & Destructor Documentation

◆ field() [1/2]

matador::field::field ( const char *  name)
explicit

Creates a named field.

Parameters
nameName of the column field

◆ field() [2/2]

matador::field::field ( const std::string &  name)
explicit

Creates a named field.

Parameters
nameName of the column field

Member Function Documentation

◆ default_value() [1/2]

std::string matador::field::default_value ( ) const

Returns the default value as string.

Returns
Default value as string

◆ default_value() [2/2]

void matador::field::default_value ( const std::string &  value)

Sets the default value as string.

Parameters
valueDefault value as string

◆ index() [1/2]

size_t matador::field::index ( ) const

Returns the index of the field in table.

Returns
Index of the field in table

◆ index() [2/2]

void matador::field::index ( size_t  i)

Sets the index in table of the field.

Parameters
iThe index of the field

◆ is_not_null()

bool matador::field::is_not_null ( ) const

Returns true if NULL value is not allowed.

Returns
True if NULL value is not allowed

◆ name() [1/2]

std::string matador::field::name ( ) const

Returns the name of the field.

Returns
Name of the field

◆ name() [2/2]

void matador::field::name ( const std::string &  n)

Sets the name of the field.

Parameters
nName of the field to set

◆ not_null()

void matador::field::not_null ( bool  nn)

Set to true if NULL value is not allowed for this field.

Parameters
nnTrue if NULL value is not allowed

◆ precision() [1/2]

std::size_t matador::field::precision ( ) const

Returns the precision of the field.

Return the precision of the field if field is of type float or double

Returns
Precision of the field

◆ precision() [2/2]

void matador::field::precision ( std::size_t  p)

Sets the precision of the field.

Has only an effect if the field type is float or double.

Parameters
pPrecision of the field to set

◆ size() [1/2]

std::size_t matador::field::size ( ) const

Returns the size of the field.

Return the size of the field if field is a numeric or varchar type.

Returns
Size of the field

◆ size() [2/2]

void matador::field::size ( std::size_t  s)

Sets the size of the field.

Has only an effect if the type of the field is numeric or varchar.

Parameters
sSize of the field to set

◆ type() [1/2]

database_type matador::field::type ( ) const

Returns the type of the field.

Returns
Type of the field

◆ type() [2/2]

void matador::field::type ( database_type  t)

Sets the type of the field.

Parameters
tType of the field to set

The documentation for this class was generated from the following file:
  • matador/sql/field.hpp