Dmitigr Pgfe  1.1beta
The modern C++ API to PostgreSQL
Public Member Functions | List of all members
Sql_vector Class Referenceabstract

Represents a vector of SQL strings and useful operations on it. More...

#include <dmitigr/pgfe/sql_vector.hpp>

Public Member Functions

virtual ~Sql_vector ()=default
 The destructor. More...
 
Observers
virtual std::size_t sql_string_count () const =0
 
virtual bool has_sql_strings () const =0
 
virtual bool has_sql_string (const std::string &extra_name, const std::string &extra_value, const std::size_t offset=0, const std::size_t extra_offset=0) const =0
 
virtual std::optional< std::size_t > sql_string_index (const std::string &extra_name, const std::string &extra_value, std::size_t offset=0, std::size_t extra_offset=0) const =0
 
virtual std::size_t sql_string_index_throw (const std::string &extra_name, const std::string &extra_value, std::size_t offset=0, std::size_t extra_offset=0) const =0
 Similar to sql_string_index(const std::string&, const std::string&, std::size_t, std::size_t) except the requirement. More...
 
virtual Sql_stringsql_string (std::size_t index)=0
 
virtual const Sql_stringsql_string (std::size_t index) const =0
 
virtual Sql_stringsql_string (const std::string &extra_name, const std::string &extra_value, std::size_t offset=0, std::size_t extra_offset=0)=0
 
virtual const Sql_stringsql_string (const std::string &extra_name, const std::string &extra_value, std::size_t offset=0, std::size_t extra_offset=0) const =0
 
Modifiers
virtual void set_sql_string (std::size_t index, std::unique_ptr< Sql_string > &&sql_string)=0
 Sets the SQL string at the given index. More...
 
template<typename ... Types>
void set_sql_string (std::size_t index, Types &&... args)
 
virtual void append_sql_string (std::unique_ptr< Sql_string > &&sql_string)=0
 Appends the SQL string to this vector. More...
 
template<typename ... Types>
void append_sql_string (Types &&... args)
 
virtual void insert_sql_string (std::size_t index, std::unique_ptr< Sql_string > &&sql_string)=0
 Inserts new SQL string to this vector. More...
 
template<typename ... Types>
void insert_sql_string (std::size_t index, Types &&... args)
 
virtual void remove_sql_string (std::size_t index)=0
 Removes SQL string from the vector. More...
 
Conversions
virtual std::string to_string () const =0
 
virtual std::vector< std::unique_ptr< Sql_string > > to_vector () const =0
 
virtual std::vector< std::unique_ptr< Sql_string > > move_to_vector ()=0
 

Constructors

virtual std::unique_ptr< Sql_vectorclone () const =0
 
static DMITIGR_PGFE_API std::unique_ptr< Sql_vector > APIENTRY make ()
 Makes an empty SQL vector. More...
 
static DMITIGR_PGFE_API std::unique_ptr< Sql_vector > APIENTRY make (const std::string &input)
 Parses the input to make a SQL vector at once. More...
 
static DMITIGR_PGFE_API std::unique_ptr< Sql_vector > APIENTRY make (std::vector< std::unique_ptr< Sql_string >> &&v)
 

Detailed Description

Represents a vector of SQL strings and useful operations on it.

See also
Sql_string.

Constructor & Destructor Documentation

◆ ~Sql_vector()

virtual ~Sql_vector ( )
virtualdefault

The destructor.

Member Function Documentation

◆ append_sql_string() [1/2]

virtual void append_sql_string ( std::unique_ptr< Sql_string > &&  sql_string)
pure virtual

Appends the SQL string to this vector.

Parameters
sql_string- the SQL string to append.
Requires
(sql_string != nullptr)

◆ append_sql_string() [2/2]

void append_sql_string ( Types &&...  args)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ clone()

virtual std::unique_ptr<Sql_vector> clone ( ) const
pure virtual
Returns
The copy of this instance.

◆ has_sql_string()

virtual bool has_sql_string ( const std::string &  extra_name,
const std::string &  extra_value,
const std::size_t  offset = 0,
const std::size_t  extra_offset = 0 
) const
pure virtual
Returns
true if the SQL string with the given criterias is presents in this vector, or false otherwise.

◆ has_sql_strings()

virtual bool has_sql_strings ( ) const
pure virtual
Returns
true if this SQL vector is empty, or false otherwise.

◆ insert_sql_string() [1/2]

virtual void insert_sql_string ( std::size_t  index,
std::unique_ptr< Sql_string > &&  sql_string 
)
pure virtual

Inserts new SQL string to this vector.

Parameters
index- the index of the SQL string before which the new SQL string will be inserted;
sql_string- the SQL string to insert.
Requires
(index < sql_string_count() && sql_string != nullptr)

◆ insert_sql_string() [2/2]

void insert_sql_string ( std::size_t  index,
Types &&...  args 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ make() [1/3]

static DMITIGR_PGFE_API std::unique_ptr<Sql_vector> APIENTRY make ( )
static

Makes an empty SQL vector.

◆ make() [2/3]

static DMITIGR_PGFE_API std::unique_ptr<Sql_vector> APIENTRY make ( const std::string &  input)
static

Parses the input to make a SQL vector at once.

Parameters
input- the SQL input, such as a content of a file with multiple SQL commands and comments.
Returns
The SQL vector parsed from the input. For example, consider the following input:
-- Comment 1 (comment of the empty query string)
;
-- Comment 2 (unrelated comment)
-- Comment 3 (related comment)
SELECT 1;
-- Comment 4 (just a footer)
In this case the result vector will consists of the three sql string. (The second SQL string includes comments 2 and 3 and the SELECT 1 statement.)

◆ make() [3/3]

static DMITIGR_PGFE_API std::unique_ptr<Sql_vector> APIENTRY make ( std::vector< std::unique_ptr< Sql_string >> &&  v)
static

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ move_to_vector()

virtual std::vector<std::unique_ptr<Sql_string> > move_to_vector ( )
pure virtual
Returns
The result of conversion of this instance to the instance of type std::vector.
Effects
(has_sql_strings() == false)

◆ remove_sql_string()

virtual void remove_sql_string ( std::size_t  index)
pure virtual

Removes SQL string from the vector.

Requires
(index < sql_string_count())

◆ set_sql_string() [1/2]

virtual void set_sql_string ( std::size_t  index,
std::unique_ptr< Sql_string > &&  sql_string 
)
pure virtual

Sets the SQL string at the given index.

Parameters
index- the index of SQL string to set;
sql_string- the SQL string to set.
Requires
(index < sql_string_count() && sql_string != nullptr)

◆ set_sql_string() [2/2]

void set_sql_string ( std::size_t  index,
Types &&...  args 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
index- the index of SQL string to set.
args- the arguments to forward to Sql_string::make().

◆ sql_string() [1/4]

virtual Sql_string* sql_string ( std::size_t  index)
pure virtual
Returns
The SQL string that owns by this vector.
Parameters
index- the index of SQL string to return.
Requires
(index < sql_string_count())

◆ sql_string() [2/4]

virtual const Sql_string* sql_string ( std::size_t  index) const
pure virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ sql_string() [3/4]

virtual Sql_string* sql_string ( const std::string &  extra_name,
const std::string &  extra_value,
std::size_t  offset = 0,
std::size_t  extra_offset = 0 
)
pure virtual
Returns
The SQL string that owns by this vector, or nullptr if no SQL strings that meets the given criterias exists in this vector.
Parameters
See sql_string_index().
Requires
(offset < sql_string_count())
See also
Sql_string::extra().

◆ sql_string() [4/4]

virtual const Sql_string* sql_string ( const std::string &  extra_name,
const std::string &  extra_value,
std::size_t  offset = 0,
std::size_t  extra_offset = 0 
) const
pure virtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

◆ sql_string_count()

virtual std::size_t sql_string_count ( ) const
pure virtual
Returns
The count of SQL strings this vector contains.

◆ sql_string_index()

virtual std::optional<std::size_t> sql_string_index ( const std::string &  extra_name,
const std::string &  extra_value,
std::size_t  offset = 0,
std::size_t  extra_offset = 0 
) const
pure virtual
Returns
The index of the SQL string that owns by this vector, or std::nullopt if no SQL strings that meets the given criterias exists in this vector.
Parameters
extra_name- the name of the extra data field;
extra_value- the value of the extra data field;
offset- the starting position of lookup in this vector;
extra_offset- the starting position of lookup in the extra data.
Requires
(offset < sql_string_count() && extra_offset < sql_string(i)->extra()->field_count()), for each i in range [0, sql_string_count()).
See also
Sql_string::extra().

◆ sql_string_index_throw()

virtual std::size_t sql_string_index_throw ( const std::string &  extra_name,
const std::string &  extra_value,
std::size_t  offset = 0,
std::size_t  extra_offset = 0 
) const
pure virtual

Similar to sql_string_index(const std::string&, const std::string&, std::size_t, std::size_t) except the requirement.

Requires:
(has_sql_string(name))

◆ to_string()

virtual std::string to_string ( ) const
pure virtual
Returns
The result of conversion of this instance to the instance of type std::string.

◆ to_vector()

virtual std::vector<std::unique_ptr<Sql_string> > to_vector ( ) const
pure virtual
Returns
The result of conversion of this instance to the instance of type std::vector.

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