Gazebo Transport

API Reference

13.4.0
SqlParameter Class Reference

A class which contains a SQL statement parameter. SqlParameter can be useful for keeping SQL queries sanitized and avoid SQL injection. With C++17, it may be desirable to replace this class with std::variant. More...

#include <SqlStatement.hh>

Public Types

enum class  ParamType : int { NULL_TYPE , INTEGER , REAL , TEXT }
 An enum to indicate which type of parameter this is. More...
 

Public Member Functions

 SqlParameter ()
 
 SqlParameter (const SqlParameter &_other)
 Copy constructor. More...
 
 SqlParameter (const std::string &_string)
 Construct string parameter. More...
 
 SqlParameter (double _real)
 Construct real parameter. More...
 
 SqlParameter (int64_t _integer)
 Construct integer parameter. More...
 
 SqlParameter (SqlParameter &&_other)
 Move constructor. More...
 
 SqlParameter (std::nullptr_t)
 Construct NULL parameter. More...
 
 ~SqlParameter ()
 Destructor. More...
 
SqlParameteroperator= (const SqlParameter &_other)
 Copy assignment operator. More...
 
SqlParameteroperator= (SqlParameter &&_other)
 Move assignment operator. More...
 
const int64_t * QueryInteger () const
 Get the integer value of this parameter. More...
 
const double * QueryReal () const
 Get the floating-point value of this parameter. More...
 
const std::stringQueryText () const
 Get the text value of this paramter. More...
 
void Set (const std::string &_text)
 Set this parameter to a text string. More...
 
void Set (double _real)
 Set this parameter to a floating-point type. More...
 
void Set (int64_t _integer)
 Set this parameter to an INTEGER type. More...
 
void Set (std::nullptr_t _np)
 Set this parameter to a NULL_TYPE. More...
 
ParamType Type () const
 Get the type for this parameter. More...
 

Detailed Description

A class which contains a SQL statement parameter. SqlParameter can be useful for keeping SQL queries sanitized and avoid SQL injection. With C++17, it may be desirable to replace this class with std::variant.

These parameter types map directly to the datatypes of SQLite3: https://www.sqlite.org/datatype3.html

Member Enumeration Documentation

◆ ParamType

enum ParamType : int
strong

An enum to indicate which type of parameter this is.

Enumerator
NULL_TYPE 
INTEGER 
REAL 
TEXT 

Constructor & Destructor Documentation

◆ SqlParameter() [1/7]

◆ SqlParameter() [2/7]

SqlParameter ( std::nullptr_t  )
explicit

Construct NULL parameter.

See also
Set(std::nullptr_t)

◆ SqlParameter() [3/7]

SqlParameter ( int64_t  _integer)
explicit

Construct integer parameter.

See also
Set(int64_t)
Parameters
[in]_integeran integer

◆ SqlParameter() [4/7]

SqlParameter ( double  _real)
explicit

Construct real parameter.

See also
Set(double)
Parameters
[in]_reala real number

◆ SqlParameter() [5/7]

SqlParameter ( const std::string _string)
explicit

Construct string parameter.

See also
Set(const std::string &)
Parameters
[in]_stringa string

◆ SqlParameter() [6/7]

SqlParameter ( const SqlParameter _other)

Copy constructor.

Parameters
[in]_otherAnother SqlParameter

◆ SqlParameter() [7/7]

SqlParameter ( SqlParameter &&  _other)

Move constructor.

Parameters
[in]_otherAnother SqlParameter

◆ ~SqlParameter()

Destructor.

Member Function Documentation

◆ operator=() [1/2]

SqlParameter& operator= ( const SqlParameter _other)

Copy assignment operator.

Parameters
[in]_otherAnother SqlParameter
Returns
This object

◆ operator=() [2/2]

SqlParameter& operator= ( SqlParameter &&  _other)

Move assignment operator.

Parameters
[in]_otherAnother SqlParameter
Returns
This object

◆ QueryInteger()

const int64_t* QueryInteger ( ) const

Get the integer value of this parameter.

Returns
A pointer to this parameter's integer value, or a nullptr if it does not contain an integer.

◆ QueryReal()

const double* QueryReal ( ) const

Get the floating-point value of this parameter.

Returns
A pointer to this parameter's floating-point value, or a nullptr if it does not contain a REAL value.

◆ QueryText()

const std::string* QueryText ( ) const

Get the text value of this paramter.

Returns
A pointer to this parameter's text string, or a nullptr if it does not contain a text string.

◆ Set() [1/4]

void Set ( const std::string _text)

Set this parameter to a text string.

Parameters
[in]_textThe value to set this parameter to.

◆ Set() [2/4]

void Set ( double  _real)

Set this parameter to a floating-point type.

Parameters
[in]_realThe value to set this parameter to.

◆ Set() [3/4]

void Set ( int64_t  _integer)

Set this parameter to an INTEGER type.

Parameters
[in]_integerThe integer value to set this parameter to.

◆ Set() [4/4]

void Set ( std::nullptr_t  _np)

Set this parameter to a NULL_TYPE.

Parameters
[in]_npPass in a nullptr.

◆ Type()

ParamType Type ( ) const

Get the type for this parameter.

Returns
The type for this parameter

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