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

Additional Inherited Members

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

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

Constructor & Destructor Documentation

◆ Dataset() [1/4]

sl3::Dataset::Dataset ( )


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.

typesTypes the fields must satisfy

◆ Dataset() [3/4]

sl3::Dataset::Dataset ( const Dataset )

Copy Constructor.

◆ Dataset() [4/4]

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

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.

sl3::OutOfRanageif name is not found
namefield name
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.

sl3::ErrTypeMisMatchif field names types are not equal or size differs.
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.

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

◆ operator=() [1/2]

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

Value assignment.

reference to this

◆ operator=() [2/2]

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

Rvalues assignment.

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.

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.

sl2::OutOfRangeif a given index is invalid
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: