-
Notifications
You must be signed in to change notification settings - Fork 250
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Give zview its own header. Re-do
process_notice
.
The `process_notice` functions now work a little less hard to do useful work in catastrophic situations. If worse comes to worst, they'll just omit the trailing newline. There's a moer efficient variant taking a `zview`. Moving `zview` into its own header fixed some dependency ordering issues.
- Loading branch information
Showing
7 changed files
with
79 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** Zero-terminated string view class. | ||
*/ | ||
// Actual definitions in .hxx file so editors and such recognize file type. | ||
#include "pqxx/zview.hxx" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* Zero-terminated string view. | ||
* | ||
* DO NOT INCLUDE THIS FILE DIRECTLY; include pqxx/stringconv instead. | ||
* | ||
* Copyright (c) 2000-2020, Jeroen T. Vermeulen. | ||
* | ||
* See COPYING for copyright license. If you did not receive a file called | ||
* COPYING with this source code, please notify the distributor of this | ||
* mistake, or contact the author. | ||
*/ | ||
#ifndef PQXX_H_ZVIEW | ||
#define PQXX_H_ZVIEW | ||
|
||
#include "pqxx/compiler-public.hxx" | ||
|
||
#include <string_view> | ||
|
||
namespace pqxx | ||
{ | ||
/// Marker-type wrapper: zero-terminated @c std::string_view. | ||
/** @warning Use this only if the underlying string is zero-terminated. | ||
* | ||
* When you construct a zview, you are promising that the underlying string is | ||
* zero-terminated. It otherwise behaves exactly like a std::string_view. | ||
* The terminating zero is not "in" the string, so it does not count as part of | ||
* the view's length. | ||
* | ||
* The added guarantee lets the view be used as a C-style string, which often | ||
* matters since libpqxx builds on top of a C library. For this reason, zview | ||
* also adds a @c c_str method. | ||
*/ | ||
class zview : public std::string_view | ||
{ | ||
public: | ||
template<typename... Args> | ||
explicit constexpr zview(Args &&... args) : | ||
std::string_view(std::forward<Args>(args)...) | ||
{} | ||
|
||
/// Either a null pointer, or a zero-terminated text buffer. | ||
constexpr const char *c_str() const noexcept { return data(); } | ||
}; | ||
} // namespace pqxx | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters