drogon
C++14/17-based HTTP application framework
Loading...
Searching...
No Matches
drogon::orm::Field Class Reference

Reference to a field in a result set. More...

#include <drogon/orm/Field.h>

Inheritance diagram for drogon::orm::Field:

Public Types

using SizeType = unsigned long

Public Member Functions

const char * name () const
 Column name.
bool isNull () const
 Is this field's value null?
const char * c_str () const
 Read as plain C string.
size_t length () const
 Get the length of the plain C string.
template<typename T>
as () const
 Convert to a type T value.
ArrayParser getArrayParser () const
 Parse the field as an SQL array.
template<typename T>
std::vector< std::shared_ptr< T > > asArray () const
template<>
DROGON_EXPORT const char * as () const
template<>
DROGON_EXPORT char * as () const
template<>
float as () const
template<>
double as () const
template<>
bool as () const
template<>
int as () const
template<>
long as () const
template<>
int8_t as () const
template<>
long long as () const
template<>
unsigned int as () const
template<>
unsigned long as () const
template<>
uint8_t as () const
template<>
unsigned long long as () const

Protected Member Functions

 Field (const Row &row, Row::SizeType columnNum) noexcept

Protected Attributes

Result::SizeType row_
long column_

Friends

class Row

Detailed Description

Reference to a field in a result set.

A field represents one entry in a row. It represents an actual value in the result set, and can be converted to various types.

Member Function Documentation

◆ c_str()

const char * drogon::orm::Field::c_str ( ) const

Read as plain C string.

Since the field's data is stored internally in the form of a zero-terminated C string, this is the fastest way to read it. Use the to() or as() functions to convert the string to other types such as int, or to C++ strings.

◆ getArrayParser()

ArrayParser drogon::orm::Field::getArrayParser ( ) const
inline

Parse the field as an SQL array.

Call the parser to retrieve values (and structure) from the array.

Make sure the result object stays alive until parsing is finished. If you keep the row of field object alive, it will keep the result object alive as well.

Member Data Documentation

◆ column_

long drogon::orm::Field::column_
protected

Column number You'd expect this to be a size_t, but due to the way reverse iterators are related to regular iterators, it must be allowed to underflow to -1.


The documentation for this class was generated from the following file: