|
libpqxx
The C++ client library for PostgreSQL
|
#include <algorithm>#include <charconv>#include <cstring>#include <limits>#include <optional>#include <sstream>#include <stdexcept>#include <typeinfo>#include "pqxx/except.hxx"#include "pqxx/util.hxx"#include "pqxx/zview.hxx"#include "pqxx/internal/conversions.hxx"Go to the source code of this file.
Classes | |
| struct | pqxx::nullness< TYPE, ENABLE > |
| Traits describing a type's "null value," if any. More... | |
| struct | pqxx::no_null< TYPE > |
| Nullness traits describing a type which does not have a null value. More... | |
| struct | pqxx::string_traits< TYPE > |
| Traits class for use in string conversions. More... | |
| struct | pqxx::forbidden_conversion< TYPE > |
| String traits for a forbidden type conversion. More... | |
| struct | pqxx::string_traits< char > |
| You cannot convert a char to/from SQL. More... | |
| struct | pqxx::string_traits< unsigned char > |
| You cannot convert an unsigned char to/from SQL. More... | |
| struct | pqxx::string_traits< signed char > |
| You cannot convert a signed char to/from SQL. More... | |
| struct | pqxx::string_traits< std::byte > |
| You cannot convert a std::byte to/from SQL. More... | |
| struct | pqxx::nullness< ENUM, std::enable_if_t< std::is_enum_v< ENUM > > > |
| Nullness: Enums do not have an inherent null value. More... | |
| struct | pqxx::internal::enum_traits< ENUM > |
| Helper class for defining enum conversions. More... | |
Namespaces | |
| namespace | pqxx |
| The home of all libpqxx classes, functions, templates, etc. | |
| namespace | pqxx::internal |
| Internal items for libpqxx' own use. Do not use these yourself. | |
Macros | |
| #define | PQXX_DECLARE_ENUM_CONVERSION(ENUM) |
| Macro: Define a string conversion for an enum type. | |
Functions | |
| std::string | pqxx::internal::demangle_type_name (char const []) |
Attempt to demangle std::type_info::name() to something human-readable. | |
| template<typename TYPE> | |
| void | pqxx::oops_forbidden_conversion () noexcept |
| Nonexistent function to indicate a disallowed type conversion. | |
| template<typename TYPE> | |
| TYPE | pqxx::from_string (std::string_view text) |
| Parse a value in postgres' text format as a TYPE. | |
| template<> | |
| std::string_view | pqxx::from_string (std::string_view text) |
| "Convert" a std::string_view to a std::string_view. | |
| template<typename T> | |
| void | pqxx::from_string (std::string_view text, T &value) |
| Attempt to convert postgres-generated string to given built-in object. | |
| template<typename TYPE> | |
| std::string | pqxx::to_string (TYPE const &value) |
| Convert a value to a readable string that PostgreSQL will understand. | |
| template<typename... TYPE> | |
| std::vector< std::string_view > | pqxx::to_buf (char *here, char const *end, TYPE... value) |
| Convert multiple values to strings inside a single buffer. | |
| template<typename TYPE> | |
| void | pqxx::into_string (TYPE const &value, std::string &out) |
| Convert a value to a readable string that PostgreSQL will understand. | |
| template<typename TYPE> | |
| constexpr bool | pqxx::is_null (TYPE const &value) noexcept |
Is value null? | |
| template<typename... TYPE> | |
| std::size_t | pqxx::size_buffer (TYPE const &...value) noexcept |
| Estimate how much buffer space is needed to represent values as a string. | |
| template<typename TYPE> | |
| constexpr format | pqxx::param_format (TYPE const &) |
| What's the preferred format for passing non-null parameters of this type? | |
| template<typename TYPE> | |
| zview | pqxx::generic_to_buf (char *begin, char *end, TYPE const &value) |
Implement string_traits<TYPE>::to_buf by calling into_buf. | |
Variables | |
| template<typename TYPE> | |
| std::string const | pqxx::type_name {internal::demangle_type_name(typeid(TYPE).name())} |
| A human-readable name for a type, used in error messages and such. | |
| template<typename TYPE> | |
| constexpr bool | pqxx::is_sql_array {false} |
| Does this type translate to an SQL array? | |
| template<typename TYPE> | |
| constexpr bool | pqxx::is_unquoted_safe {false} |
| Can we use this type in arrays and composite types without quoting them? | |
| template<typename T> | |
| constexpr char | pqxx::array_separator {','} |
| Element separator between SQL array elements of this type. | |
| #define PQXX_DECLARE_ENUM_CONVERSION | ( | ENUM | ) |
Macro: Define a string conversion for an enum type.
This specialises the pqxx::string_traits template, so use it in the pqxx namespace.
For example:
#include <iostream>
#include <pqxx/strconv>
enum X { xa, xb };
namespace pqxx { PQXX_DECLARE_ENUM_CONVERSION(x); }
int main() { std::cout << pqxx::to_string(xa) << std::endl; }