CppCrate 0.1
Public Member Functions | List of all members
CppCrate::Record Class Reference

Public Member Functions

 Record ()
 
 Record (const std::string &data, const std::vector< std::string > &names, const std::vector< CrateDataType > &types)
 
int size () const
 
Value value (int pos) const
 
Value value (const std::string &name) const
 

Detailed Description

The class Record encapsulates the values of a single row inside a Result.

To iterate over all values contained in a result use

for (int i = 0, total = r.size(); i < total; ++i) {
Value value = r.value(i);
// use value here
}

Constructor & Destructor Documentation

◆ Record() [1/2]

CppCrate::Record::Record ( )

Constructs an empty record.

◆ Record() [2/2]

CppCrate::Record::Record ( const std::string &  data,
const std::vector< std::string > &  names,
const std::vector< CrateDataType > &  types 
)

Constructs a record holding the values as defined in data. The values' names are defined by names and their types by types.

Member Function Documentation

◆ size()

int CppCrate::Record::size ( ) const

Returns the size of the values contained in the record.

◆ value() [1/2]

Value CppCrate::Record::value ( int  pos) const

Returns the value at position pos or an empty value if pos is invalid.

◆ value() [2/2]

Value CppCrate::Record::value ( const std::string &  name) const

Returns the value with the name name or an empty value if name does not exists.

Note
This value is slower than the index based variant. So if you know the value's position you might want to use value() with the index.