libsl3 1.2.41002
A C++ interface for SQLite
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
sl3::Dataset Class Referencefinal

A utility for processing the result queries. More...

#include <sl3/dataset.hpp>

Inheritance diagram for sl3::Dataset:
sl3::Container< std::vector< DbValues > >

Public Types

typedef bool(* DbValueSort) (const DbValue &, const DbValue &)
 Typedef for a relation function signature.
 
- Public Types inherited from sl3::Container< std::vector< DbValues > >
using conatiner_type = std::vector< DbValues >
 
using iterator = typename conatiner_type::iterator
 
using const_iterator = typename conatiner_type::const_iterator
 
using value_type = typename conatiner_type::value_type
 
using reference = typename conatiner_type::reference
 
using const_reference = typename conatiner_type::const_reference
 
using size_type = typename conatiner_type::size_type
 
using container_type = std::vector< DbValues >
 

Public Member Functions

 Dataset () noexcept
 Constructor.
 
 Dataset (Types types)
 Constructor wiht DbValuesTypeList as description.
 
 Dataset (const Dataset &)=default
 Copy Constructor.
 
 Dataset (Dataset &&) noexcept(std::is_nothrow_move_constructible< Container< DbValues > >::value &&std::is_nothrow_move_constructible< Types >::value &&std::is_nothrow_move_constructible< std::vector< std::string > >::value)
 Move Constructor.
 
Datasetoperator= (const Dataset &)=default
 Value assignment.
 
Datasetoperator= (Dataset &&)=default
 Rvalues assignment.
 
void reset ()
 Clear all states. Removes loaded data so that the actual instance can be reused/refilled.
 
void reset (const Types &types)
 Clear all states.
 
void merge (const Dataset &other)
 Merge an other Dataset.
 
void merge (const DbValues &row)
 Merge DbValues.
 
std::size_t getIndex (const std::string &name) const
 Get the index of a field by namespace.
 
void sort (const std::vector< size_t > &idxs, DbValueSort cmp=&dbval_lt)
 Sort the Dataset.
 
- Public Member Functions inherited from sl3::Container< std::vector< DbValues > >
 Container () noexcept
 Constructor.
 
 Container (std::vector< DbValues > container) noexcept(std::is_nothrow_move_constructible< std::vector< DbValues > >::value)
 Constructor.
 
 Container (std::initializer_list< value_type > container)
 Constructor.
 
 Container (const Container &)=default
 Copy Constructor.
 
 Container (Container &&) noexcept(std::is_nothrow_move_constructible< std::vector< DbValues > >::value)=default
 Move constructor.
 
Containeroperator= (const Container &)=default
 Assignment.
 
Containeroperator= (Container &&)=default
 Move assignment.
 
virtual ~Container () noexcept(std::is_nothrow_destructible< std::vector< DbValues > >::value)=default
 Destructor.
 
iterator begin ()
 Iterator access.
 
const_iterator begin () const
 Iterator access.
 
iterator end ()
 Iterator access.
 
const_iterator end () const
 Iterator access.
 
const_iterator cbegin () const
 Iterator access.
 
const_iterator cend () const
 Iterator access.
 
size_type size () const
 Container size.
 
reference at (size_t i)
 checked random access
 
const_reference at (size_t i) const
 checked random access
 
reference operator[] (size_t i)
 unchecked random access
 
const_reference operator[] (size_t i) const
 unchecked random access
 

Additional Inherited Members

- Protected Attributes inherited from sl3::Container< std::vector< DbValues > >
std::vector< DbValues_cont
 Container T.
 

Detailed Description

A utility for processing the result queries.

This class is a RowCallback that loads the result of a Query into a list of DbValues. The loaded list can be browsed and the loaded values can be accessed.

A Dataset can either be created:

Member Typedef Documentation

◆ DbValueSort

typedef bool(* sl3::Dataset::DbValueSort) (const DbValue &, const DbValue &)

Typedef for a relation function signature.

Used to specify the the less function that shall be used for sorting a Dataset.

See also
Dataset::sort

Constructor & Destructor Documentation

◆ Dataset() [1/4]

sl3::Dataset::Dataset ( )
noexcept

Constructor.

All fields will be DsVariantField , using the storage type sqlite reports for the actual value. Field count will be detected and applied.

◆ Dataset() [2/4]

sl3::Dataset::Dataset ( Types  types)

Constructor wiht DbValuesTypeList as description.

Types of DbValue will use the given description when creating the DbValue list. If the given list is not empty, field count will be validated when the actual instance becomes populated with data.

Parameters
typesTypes the fields must satisfy

◆ Dataset() [3/4]

sl3::Dataset::Dataset ( const Dataset )
default

Copy Constructor.

◆ Dataset() [4/4]

sl3::Dataset::Dataset ( Dataset &&  ) const &&
noexcept

Move Constructor.

Member Function Documentation

◆ getIndex()

std::size_t sl3::Dataset::getIndex ( const std::string &  name) const

Get the index of a field by namespace.

Exceptions
sl3::OutOfRanageif name is not found
Parameters
namefield name
Returns
field index

◆ merge() [1/2]

void sl3::Dataset::merge ( const Dataset other)

Merge an other Dataset.

Appends the data of the given Dataset to the end of the actual data. The field names and types of the given Dataset must match the actuals one.

Exceptions
sl3::ErrTypeMisMatchif field names types are not equal or size differs.
Parameters
otherDataset which shall be added to this one.

◆ merge() [2/2]

void sl3::Dataset::merge ( const DbValues row)

Merge DbValues.

Appends the DbValues to the end of the actual data.

Exceptions
sl3::ErrTypeMisMatchif size differs from existing row size or if types are not compatible
Parameters
rowA row which shall be added.

◆ operator=() [1/2]

Dataset & sl3::Dataset::operator= ( const Dataset )
default

Value assignment.

Returns
reference to this

◆ operator=() [2/2]

Dataset & sl3::Dataset::operator= ( Dataset &&  )
default

Rvalues assignment.

Returns
reference to this

◆ reset() [1/2]

void sl3::Dataset::reset ( )

Clear all states. Removes loaded data so that the actual instance can be reused/refilled.

◆ reset() [2/2]

void sl3::Dataset::reset ( const Types types)

Clear all states.

Removes loaded data and sets a new specification for the field description so that the actual instance can be reused for populate with a different select statement / sql command. Passing an empty DbValuesTypeList mean that all fields will be DsVariandField and field count will be detected.

Parameters
typesnew Types requirement

◆ sort()

void sl3::Dataset::sort ( const std::vector< size_t > &  idxs,
DbValueSort  cmp = &dbval_lt 
)

Sort the Dataset.

Sort according to the given field indexes. The Dataset will be sorted according to sqlite rules.

Exceptions
sl2::OutOfRangeif a given index is invalid
Parameters
idxslist of field indexes
cmppointer to a less than compare function, default dbval_lt

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