userver: storages::clickhouse::Query Class Reference
Loading...
Searching...
No Matches
storages::clickhouse::Query Class Reference

#include <userver/storages/query.hpp>

Detailed Description

Holds a query, its name and logging mode; used by all the SQL databases of userver.

Holds a query, its name and logging mode; used by all the SQL databases of userver.

Prefer using via Embedding SQL/YQL files via userver_add_sql_library or use a const variable with name specified as NameLiteral.

Note
You may write a query in .sql file and generate a header file with Query from it. See Embedding SQL/YQL files via userver_add_sql_library for more information.

Prefer using via Embedding SQL/YQL files via userver_add_sql_library or use a const variable with name specified as NameLiteral.

Note
You may write a query in .sql file and generate a header file with Query from it. See Embedding SQL/YQL files via userver_add_sql_library for more information.

Definition at line 28 of file query.hpp.

Classes

class  NameLiteral
 Compile time literal with query name. More...
 

Public Types

enum class  LogMode : unsigned char {
  kFull ,
  kNameOnly
}
 
using Name = utils::StrongTypedef<struct NameTag, std::string>
 String with query name.
 
using NameView = utils::zstring_view
 Zero terminated view to the query name.
 

Public Member Functions

 Query (const Query &other)=default
 
 Query (Query &&other)=default
 
constexpr Query (utils::StringLiteral statement, NameLiteral name, LogMode log_mode)
 Constructor that omits dynamic initialization and relies on statement and name being string literals.
 
 Query (const char *statement, std::optional< Name > name=std::nullopt, LogMode log_mode=LogMode::kFull)
 
 Query (std::string statement, std::optional< Name > name=std::nullopt, LogMode log_mode=LogMode::kFull)
 
Queryoperator= (const Query &other)=default
 
Queryoperator= (Query &&other)=default
 
std::optional< NameViewGetOptionalNameView () const noexcept
 
std::optional< NameGetOptionalName () const
 
utils::zstring_view GetStatementView () const noexcept
 
LogMode GetLogMode () const noexcept
 

Member Typedef Documentation

◆ Name

using storages::Query::Name = utils::StrongTypedef<struct NameTag, std::string>

String with query name.

Definition at line 31 of file query.hpp.

◆ NameView

Zero terminated view to the query name.

Definition at line 34 of file query.hpp.

Member Enumeration Documentation

◆ LogMode

enum class storages::Query::LogMode : unsigned char
strong
Enumerator
kFull 

Output name and optionally statement.

kNameOnly 

Output only name.

Definition at line 52 of file query.hpp.

Constructor & Destructor Documentation

◆ Query() [1/3]

storages::Query::Query ( utils::StringLiteral statement,
NameLiteral name,
LogMode log_mode )
inlineconstexpr

Constructor that omits dynamic initialization and relies on statement and name being string literals.

Definition at line 66 of file query.hpp.

◆ Query() [2/3]

storages::Query::Query ( const char * statement,
std::optional< Name > name = std::nullopt,
LogMode log_mode = LogMode::kFull )
inline

Definition at line 69 of file query.hpp.

◆ Query() [3/3]

storages::Query::Query ( std::string statement,
std::optional< Name > name = std::nullopt,
LogMode log_mode = LogMode::kFull )
inline

Definition at line 71 of file query.hpp.

Member Function Documentation

◆ GetLogMode()

LogMode storages::Query::GetLogMode ( ) const
inlinenoexcept
Returns
logging mode

Definition at line 84 of file query.hpp.

◆ GetOptionalName()

std::optional< Name > storages::Query::GetOptionalName ( ) const
inline
Returns
optional queury name suitable for construction of a new Query

Definition at line 78 of file query.hpp.

◆ GetOptionalNameView()

std::optional< NameView > storages::Query::GetOptionalNameView ( ) const
noexcept
Returns
view to the query name that is alive as long as *this is alive

◆ GetStatementView()

utils::zstring_view storages::Query::GetStatementView ( ) const
noexcept
Returns
zero terminated view to the statement that is alive as long as *this is alive

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