libpqxx  7.1.2
zview.hxx
1 /* Zero-terminated string view.
2  *
3  * DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/stringconv instead.
4  *
5  * Copyright (c) 2000-2020, Jeroen T. Vermeulen.
6  *
7  * See COPYING for copyright license. If you did not receive a file called
8  * COPYING with this source code, please notify the distributor of this
9  * mistake, or contact the author.
10  */
11 #ifndef PQXX_H_ZVIEW
12 #define PQXX_H_ZVIEW
13 
14 #include "pqxx/compiler-public.hxx"
15 
16 #include <string_view>
17 
18 namespace pqxx
19 {
21 
32 class zview : public std::string_view
33 {
34 public:
35  constexpr zview() noexcept = default;
36 
38  constexpr zview(const char text[], std::ptrdiff_t len) :
39  std::string_view{text, static_cast<std::size_t>(len)}
40  {}
41 
43  constexpr zview(char text[], std::ptrdiff_t len) :
44  std::string_view{text, static_cast<std::size_t>(len)}
45  {}
46 
47  template<typename... Args>
48  explicit constexpr zview(Args &&... args) :
49  std::string_view(std::forward<Args>(args)...)
50  {}
51 
53  [[nodiscard]] constexpr char const *c_str() const noexcept { return data(); }
54 };
55 } // namespace pqxx
56 
57 #endif
constexpr char const * c_str() const noexcept
Either a null pointer, or a zero-terminated text buffer.
Definition: zview.hxx:53
constexpr zview(char text[], std::ptrdiff_t len)
Convenience overload: construct using pointer and signed length.
Definition: zview.hxx:43
constexpr zview(Args &&... args)
Definition: zview.hxx:48
The home of all libpqxx classes, functions, templates, etc.
Definition: array.hxx:25
constexpr zview() noexcept=default
STL namespace.
Marker-type wrapper: zero-terminated std::string_view.
Definition: zview.hxx:32
constexpr zview(const char text[], std::ptrdiff_t len)
Convenience overload: construct using pointer and signed length.
Definition: zview.hxx:38