You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by bc...@apache.org on 2018/05/17 21:52:26 UTC
[trafficserver] 01/02: Replace ts::string_view with std::string_view
This is an automated email from the ASF dual-hosted git repository.
bcall pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit f692c2014c1bace3555bb145efe866dec17b80c1
Author: Bryan Call <bc...@apache.org>
AuthorDate: Wed May 16 08:21:40 2018 -0700
Replace ts::string_view with std::string_view
---
CMakeLists.txt | 2 -
cmd/traffic_cache_tool/File.cc | 3 +-
cmd/traffic_layout/info.cc | 2 +-
cmd/traffic_layout/traffic_layout.cc | 6 +-
.../internal-libraries/buffer-writer.en.rst | 10 +-
.../internal-libraries/index.en.rst | 1 -
.../internal-libraries/string_view.en.rst | 69 --
.../DelayTransformationPlugin.cc | 4 +-
.../GzipTransformationPlugin.cc | 4 +-
.../NullTransformationPlugin.cc | 4 +-
example/cppapi/post_buffer/PostBuffer.cc | 4 +-
example/ssl_preaccept/ssl_preaccept.cc | 12 +-
iocore/net/I_NetVConnection.h | 12 +-
iocore/net/NetVConnection.cc | 4 +-
iocore/net/P_SSLNetVConnection.h | 8 +-
iocore/net/P_SSLUtils.h | 4 +-
iocore/net/P_UnixNetVConnection.h | 4 +-
iocore/net/SSLNetVConnection.cc | 14 +-
iocore/net/SSLSNIConfig.cc | 4 +-
iocore/net/UnixNet.cc | 16 +-
iocore/net/UnixNetVConnection.cc | 6 +-
lib/cppapi/GzipDeflateTransformation.cc | 8 +-
lib/cppapi/GzipInflateTransformation.cc | 6 +-
lib/cppapi/TransformationPlugin.cc | 4 +-
.../include/atscppapi/GzipDeflateTransformation.h | 4 +-
.../include/atscppapi/GzipInflateTransformation.h | 4 +-
.../include/atscppapi/TransformationPlugin.h | 10 +-
lib/records/RecHttp.cc | 6 +-
lib/records/RecRawStats.cc | 2 +-
lib/ts/BufferWriter.h | 41 +-
lib/ts/BufferWriterFormat.cc | 44 +-
lib/ts/BufferWriterForward.h | 4 +-
lib/ts/CryptoHash.h | 4 +-
lib/ts/I_Layout.h | 13 +-
lib/ts/Layout.cc | 16 +-
lib/ts/Makefile.am | 4 +-
lib/ts/MemArena.cc | 4 +-
lib/ts/MemSpan.h | 10 +-
lib/ts/TextView.h | 20 +-
lib/ts/ink_inet.cc | 58 +-
lib/ts/ink_inet.h | 57 +-
lib/ts/ink_memory.h | 7 +-
lib/ts/ink_res_init.cc | 2 +-
lib/ts/ink_string.h | 17 +
lib/ts/string_view.h | 1093 --------------------
lib/ts/unit-tests/test_BufferWriter.cc | 7 +-
lib/ts/unit-tests/test_BufferWriterFormat.cc | 20 +-
lib/ts/unit-tests/test_TextView.cc | 5 +-
lib/ts/unit-tests/test_ink_inet.cc | 32 +-
lib/ts/unit-tests/test_layout.cc | 2 +-
lib/ts/unit-tests/test_string_view.cc | 552 ----------
lib/tsconfig/TsConfigLua.h | 26 +-
mgmt/LocalManager.cc | 4 +-
.../ssl_cert_loader/ssl-cert-loader.cc | 10 +-
plugins/experimental/tls_bridge/regex.cc | 4 +-
plugins/experimental/tls_bridge/regex.h | 6 +-
.../experimental/webp_transform/ImageTransform.cc | 6 +-
proxy/InkAPI.cc | 16 +-
proxy/ProxyClientSession.h | 6 +-
proxy/ProxyClientTransaction.h | 6 +-
proxy/hdrs/HTTP.cc | 2 +-
proxy/hdrs/URL.cc | 4 +-
proxy/hdrs/URL.h | 4 +-
proxy/http/ForwardedConfig.cc | 4 +-
proxy/http/HttpConfig.cc | 4 +-
proxy/http/HttpConfig.h | 4 +-
proxy/http/HttpSM.cc | 14 +-
proxy/http/HttpSM.h | 8 +-
proxy/http/HttpServerSession.h | 4 +-
proxy/http/HttpTransactHeaders.cc | 31 +-
proxy/http/HttpTransactHeaders.h | 2 +-
proxy/http/unit-tests/test_ForwardedConfig.cc | 2 +-
proxy/http2/Http2ClientSession.h | 6 +-
proxy/logging/LogHost.cc | 4 +-
74 files changed, 372 insertions(+), 2054 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a7eb06f..af29025 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1290,7 +1290,6 @@ add_library(libtsutil SHARED
lib/ts/SimpleTokenizer.h
lib/ts/SourceLocation.cc
lib/ts/SourceLocation.h
- lib/ts/string_view.h
lib/ts/test_arena.cc
lib/ts/test_atomic.cc
lib/ts/test_freelist.cc
@@ -1330,7 +1329,6 @@ add_executable(test_tslib
lib/ts/unit-tests/test_MemSpan.cc
lib/ts/unit-tests/test_MT_hashtable.cc
lib/ts/unit-tests/test_Scalar.cc
- lib/ts/unit-tests/test_string_view.cc
lib/ts/unit-tests/test_scoped_resource.cc
lib/ts/unit-tests/test_TextView.cc
)
diff --git a/cmd/traffic_cache_tool/File.cc b/cmd/traffic_cache_tool/File.cc
index 526d303..faa415e 100644
--- a/cmd/traffic_cache_tool/File.cc
+++ b/cmd/traffic_cache_tool/File.cc
@@ -24,6 +24,7 @@
#include "File.h"
#include <unistd.h>
#include <fcntl.h>
+#include <errno.h>
namespace ts
{
@@ -33,7 +34,7 @@ namespace ts
@return A newly @x ats_malloc string of the combined paths.
*/
std::string
-path_join(ts::string_view lhs, ts::string_view rhs)
+path_join(std::string_view lhs, std::string_view rhs)
{
size_t ln = lhs.size();
size_t rn = rhs.size();
diff --git a/cmd/traffic_layout/info.cc b/cmd/traffic_layout/info.cc
index 0a47699..03bfd26 100644
--- a/cmd/traffic_layout/info.cc
+++ b/cmd/traffic_layout/info.cc
@@ -114,7 +114,7 @@ produce_features(bool json)
}
void
-print_var(ts::string_view const &name, ts::string_view const &value, bool json, bool last = false)
+print_var(std::string_view const &name, std::string_view const &value, bool json, bool last = false)
{
if (json) {
printf(R"( "%.*s": "%.*s"%s)", static_cast<int>(name.size()), name.data(), static_cast<int>(value.size()), value.data(),
diff --git a/cmd/traffic_layout/traffic_layout.cc b/cmd/traffic_layout/traffic_layout.cc
index d808786..c77e40c 100644
--- a/cmd/traffic_layout/traffic_layout.cc
+++ b/cmd/traffic_layout/traffic_layout.cc
@@ -36,6 +36,8 @@
#include <fstream>
#include <set>
+using namespace std::literals;
+
struct subcommand {
int (*handler)(int, const char **);
const std::string name;
@@ -84,7 +86,7 @@ int
info(int argc, const char **argv)
{
// take the "info" out from command line
- if (argv[1] && argv[1] == "info"_sv) {
+ if (argv[1] && argv[1] == "info"sv) {
for (int i = 1; i < argc; i++) {
argv[i] = argv[i + 1];
}
@@ -92,7 +94,7 @@ info(int argc, const char **argv)
// detect help command
int i = 1;
while (argv[i]) {
- if (argv[i] == "--help"_sv || argv[i] == "-h"_sv) {
+ if (argv[i] == "--help"sv || argv[i] == "-h"sv) {
help_usage();
}
++i;
diff --git a/doc/developer-guide/internal-libraries/buffer-writer.en.rst b/doc/developer-guide/internal-libraries/buffer-writer.en.rst
index aa76fa0..d6629a9 100644
--- a/doc/developer-guide/internal-libraries/buffer-writer.en.rst
+++ b/doc/developer-guide/internal-libraries/buffer-writer.en.rst
@@ -208,7 +208,7 @@ a "not enough space" message if not. E.g. ::
ts::FixedBufferWriter subw{w.auxWriter()};
this->write_some_output(subw);
if (!subw.error()) w.fill(subw.size());
- else w.write("Insufficient space"_sv);
+ else w.write("Insufficient space"sv);
Examples
++++++++
@@ -243,11 +243,11 @@ becomes
// ...
- w.write(" ["_sv);
+ w.write(" ["sv);
if (s->txn_conf->insert_request_via_string > 2) { // Highest verbosity
w.write(incoming_via);
} else {
- w.write(ts::string_view{incoming_via + VIA_CLIENT, VIA_SERVER - VIA_CLIENT});
+ w.write(std::string_view{incoming_via + VIA_CLIENT, VIA_SERVER - VIA_CLIENT});
}
w.write(']');
@@ -255,11 +255,11 @@ There will be no overrun on the memory buffer in :arg:`w`, in strong contrast to
This can be done better, as ::
if (w.remaining() >= 3) {
- w.clip(1).write(" ["_sv);
+ w.clip(1).write(" ["sv);
if (s->txn_conf->insert_request_via_string > 2) { // Highest verbosity
w.write(incoming_via);
} else {
- w.write(ts::string_view{incoming_via + VIA_CLIENT, VIA_SERVER - VIA_CLIENT});
+ w.write(std::string_view{incoming_via + VIA_CLIENT, VIA_SERVER - VIA_CLIENT});
}
w.extend(1).write(']');
}
diff --git a/doc/developer-guide/internal-libraries/index.en.rst b/doc/developer-guide/internal-libraries/index.en.rst
index fd9051d..f6e8391 100644
--- a/doc/developer-guide/internal-libraries/index.en.rst
+++ b/doc/developer-guide/internal-libraries/index.en.rst
@@ -28,7 +28,6 @@ development team.
.. toctree::
:maxdepth: 1
- string_view.en
TextView.en
MemSpan.en
scalar.en
diff --git a/doc/developer-guide/internal-libraries/string_view.en.rst b/doc/developer-guide/internal-libraries/string_view.en.rst
deleted file mode 100644
index 4d67f3e..0000000
--- a/doc/developer-guide/internal-libraries/string_view.en.rst
+++ /dev/null
@@ -1,69 +0,0 @@
-.. Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-
-.. include:: ../../common.defs
-
-.. default-domain:: cpp
-
-ts::string_view
-***************
-
-Synopsis
-========
-
-:code:`#include <ts/string_view.h>`
-
-.. class:: string_view
-
- An internal implementation of `std::string_view
- <https://en.cppreference.com/w/cpp/header/string_view>`__. This was done because
- :code:`std::string_view` is part of the C++17 standard and therefore cannot be assumed in our
- supported compilers (which are currently only C++11).
-
-Description
-===========
-
-:class:`string_view` provides a read only view into memory allocated elsewhere and is handy for when
-passing around pieces of memory, such as pieces of an HTTP header. It is essentially a pointer and a
-length and a quick glance at our internal API will provide numerous places this kind of data is
-passed.
-
-This implementation is intended to be as similar as possible to the standard version to avoid
-transition difficulties if / when we upgrade to C++17. For this reason no additional features,
-regardless of how useful we might find them, have been or will be added to this class.
-
-The only known difference at this time is the literal operator is :code:`""_sv` instead of
-:code:`""sv` as it is for :code:`std::string_view`. The reason is a compiler limitation which does
-not allow non-compiler headers to define literal operators without a leading ``_``. The use would be
-
-.. code-block:: cpp
-
- ts::string_view ts_v = "A literal string"_sv; // ts::string_view
- std::string_view std_v = "A literal string"sv; // std::string_view
-
-If you discover any other differences, that is a bug in our implementation and should be fixed.
-
-For a class that provides a much richer set of text manipulation methods, see :class:`TextView`
-which is a subclass of :class:`string_view`.
-
-For passing instance of :class:`string_view` it is reasonable to pass it by value. Examining machine
-code shows this is the same cost as passing the pointer and length as two arguments and saves
-indirection on in the called code.
-
-There is no shortage of additional reference material available, beyond the basic description noted
-above, which serves to describe the API and usage of this class, and duplicating it here would serve
-no purpose.
diff --git a/example/cppapi/delay_transformation_plugin/DelayTransformationPlugin.cc b/example/cppapi/delay_transformation_plugin/DelayTransformationPlugin.cc
index e2036ef..3733b7e 100644
--- a/example/cppapi/delay_transformation_plugin/DelayTransformationPlugin.cc
+++ b/example/cppapi/delay_transformation_plugin/DelayTransformationPlugin.cc
@@ -17,7 +17,7 @@
*/
#include <iostream>
-#include <ts/string_view.h>
+#include <string_view>
#include <atscppapi/GlobalPlugin.h>
#include <atscppapi/TransactionPlugin.h>
#include <atscppapi/TransformationPlugin.h>
@@ -65,7 +65,7 @@ public:
}
void
- consume(ts::string_view data) override
+ consume(std::string_view data) override
{
TS_DEBUG(TAG, "Consuming...");
produce(data);
diff --git a/example/cppapi/gzip_transformation/GzipTransformationPlugin.cc b/example/cppapi/gzip_transformation/GzipTransformationPlugin.cc
index e7e5940..ad6d043 100644
--- a/example/cppapi/gzip_transformation/GzipTransformationPlugin.cc
+++ b/example/cppapi/gzip_transformation/GzipTransformationPlugin.cc
@@ -17,7 +17,7 @@
*/
#include <iostream>
-#include <ts/string_view.h>
+#include <string_view>
#include <atscppapi/GlobalPlugin.h>
#include <atscppapi/TransactionPlugin.h>
#include <atscppapi/TransformationPlugin.h>
@@ -104,7 +104,7 @@ public:
}
void
- consume(ts::string_view data) override
+ consume(std::string_view data) override
{
produce(data);
}
diff --git a/example/cppapi/null_transformation_plugin/NullTransformationPlugin.cc b/example/cppapi/null_transformation_plugin/NullTransformationPlugin.cc
index 7398cc4..598d49f 100644
--- a/example/cppapi/null_transformation_plugin/NullTransformationPlugin.cc
+++ b/example/cppapi/null_transformation_plugin/NullTransformationPlugin.cc
@@ -17,7 +17,7 @@
*/
#include <iostream>
-#include <ts/string_view.h>
+#include <string_view>
#include <atscppapi/GlobalPlugin.h>
#include <atscppapi/TransactionPlugin.h>
#include <atscppapi/TransformationPlugin.h>
@@ -57,7 +57,7 @@ public:
}
void
- consume(ts::string_view data) override
+ consume(std::string_view data) override
{
produce(data);
}
diff --git a/example/cppapi/post_buffer/PostBuffer.cc b/example/cppapi/post_buffer/PostBuffer.cc
index feda07a..cc3ecf2 100644
--- a/example/cppapi/post_buffer/PostBuffer.cc
+++ b/example/cppapi/post_buffer/PostBuffer.cc
@@ -17,7 +17,7 @@
*/
#include <iostream>
-#include <ts/string_view.h>
+#include <string_view>
#include <atscppapi/GlobalPlugin.h>
#include <atscppapi/TransactionPlugin.h>
#include <atscppapi/TransformationPlugin.h>
@@ -44,7 +44,7 @@ public:
}
void
- consume(ts::string_view data) override
+ consume(std::string_view data) override
{
buffer_.append(data.data(), data.length());
}
diff --git a/example/ssl_preaccept/ssl_preaccept.cc b/example/ssl_preaccept/ssl_preaccept.cc
index cc2b16e..58fef8e 100644
--- a/example/ssl_preaccept/ssl_preaccept.cc
+++ b/example/ssl_preaccept/ssl_preaccept.cc
@@ -51,14 +51,14 @@ IpRangeQueue ClientBlindTunnelIp;
Configuration Config; // global configuration
void
-Parse_Addr_String(ts::string_view const &text, IpRange &range)
+Parse_Addr_String(std::string_view const &text, IpRange &range)
{
IpAddr newAddr;
// Is there a hyphen?
size_t hyphen_pos = text.find('-');
- if (hyphen_pos != ts::string_view::npos) {
- ts::string_view addr1 = text.substr(0, hyphen_pos);
- ts::string_view addr2 = text.substr(hyphen_pos + 1);
+ if (hyphen_pos != std::string_view::npos) {
+ std::string_view addr1 = text.substr(0, hyphen_pos);
+ std::string_view addr2 = text.substr(hyphen_pos + 1);
range.first.load(addr1);
range.second.load(addr2);
} else { // Assume it is a single address
@@ -77,13 +77,13 @@ Load_Config_Value(Value const &parent, const char *name, IpRangeQueue &addrs)
IpRange ipRange;
if (v.isLiteral()) {
auto txt = v.getText();
- Parse_Addr_String(ts::string_view(txt._ptr, txt._size), ipRange);
+ Parse_Addr_String(std::string_view(txt._ptr, txt._size), ipRange);
addrs.push_back(ipRange);
} else if (v.isContainer()) {
size_t i;
for (i = 0; i < v.childCount(); i++) {
auto txt = v[i].getText();
- Parse_Addr_String(ts::string_view(txt._ptr, txt._size), ipRange);
+ Parse_Addr_String(std::string_view(txt._ptr, txt._size), ipRange);
addrs.push_back(ipRange);
}
}
diff --git a/iocore/net/I_NetVConnection.h b/iocore/net/I_NetVConnection.h
index 3d4d7b0..5bf51c2 100644
--- a/iocore/net/I_NetVConnection.h
+++ b/iocore/net/I_NetVConnection.h
@@ -32,7 +32,7 @@
#include "I_IOBuffer.h"
#include "I_Socks.h"
#include <ts/apidefs.h>
-#include <ts/string_view.h>
+#include <string_view>
#define CONNECT_SUCCESS 1
#define CONNECT_FAILURE 0
@@ -201,7 +201,7 @@ struct NetVCOptions {
IpEndpoint ip;
// Literal IPv4 and IPv6 addresses are not permitted in "HostName".(rfc6066#section-3)
- if (name && len && ats_ip_pton(ts::string_view(name, len), &ip) != 0) {
+ if (name && len && ats_ip_pton(std::string_view(name, len), &ip) != 0) {
sni_servername = ats_strndup(name, len);
} else {
sni_servername = nullptr;
@@ -235,9 +235,9 @@ struct NetVCOptions {
return *this;
}
- ts::string_view get_family_string() const;
+ std::string_view get_family_string() const;
- ts::string_view get_proto_string() const;
+ std::string_view get_proto_string() const;
/// @name Debugging
//@{
@@ -628,13 +628,13 @@ public:
}
virtual int
- populate_protocol(ts::string_view *results, int n) const
+ populate_protocol(std::string_view *results, int n) const
{
return 0;
}
virtual const char *
- protocol_contains(ts::string_view prefix) const
+ protocol_contains(std::string_view prefix) const
{
return nullptr;
}
diff --git a/iocore/net/NetVConnection.cc b/iocore/net/NetVConnection.cc
index 198d0bb..a4f9239 100644
--- a/iocore/net/NetVConnection.cc
+++ b/iocore/net/NetVConnection.cc
@@ -45,7 +45,7 @@ NetVConnection::cancel_OOB()
return;
}
-ts::string_view
+std::string_view
NetVCOptions::get_proto_string() const
{
switch (ip_proto) {
@@ -59,7 +59,7 @@ NetVCOptions::get_proto_string() const
return {};
}
-ts::string_view
+std::string_view
NetVCOptions::get_family_string() const
{
switch (ip_family) {
diff --git a/iocore/net/P_SSLNetVConnection.h b/iocore/net/P_SSLNetVConnection.h
index 46117cd..4b0985f 100644
--- a/iocore/net/P_SSLNetVConnection.h
+++ b/iocore/net/P_SSLNetVConnection.h
@@ -33,7 +33,7 @@
#include <ts/ink_platform.h>
#include <ts/apidefs.h>
-#include <ts/string_view.h>
+#include <string_view>
#include <openssl/ssl.h>
#include <openssl/err.h>
@@ -293,8 +293,8 @@ public:
return ssl ? SSL_get_cipher_name(ssl) : nullptr;
}
- int populate_protocol(ts::string_view *results, int n) const override;
- const char *protocol_contains(ts::string_view tag) const override;
+ int populate_protocol(std::string_view *results, int n) const override;
+ const char *protocol_contains(std::string_view tag) const override;
/**
* Populate the current object based on the socket information in in the
@@ -318,7 +318,7 @@ public:
SSLNetVConnection &operator=(const SSLNetVConnection &) = delete;
private:
- ts::string_view map_tls_protocol_to_tag(const char *proto_string) const;
+ std::string_view map_tls_protocol_to_tag(const char *proto_string) const;
bool update_rbio(bool move_to_socket);
bool sslHandShakeComplete = false;
diff --git a/iocore/net/P_SSLUtils.h b/iocore/net/P_SSLUtils.h
index 8278307..dc96ab8 100644
--- a/iocore/net/P_SSLUtils.h
+++ b/iocore/net/P_SSLUtils.h
@@ -260,8 +260,8 @@ public:
void
emplace(cchar *key, std::string &hostname)
{
- ts::string_view addr, port;
- if (ats_ip_parse(ts::string_view(hostname), &addr, &port) == 0) {
+ std::string_view addr, port;
+ if (ats_ip_parse(std::string_view(hostname), &addr, &port) == 0) {
auto *hs = new HostStruct(ats_strdup(addr.data()), addr.length(), atoi(port.data()));
TunnelhMap.put(ats_strdup(key), hs);
}
diff --git a/iocore/net/P_UnixNetVConnection.h b/iocore/net/P_UnixNetVConnection.h
index 490e143..054ed6c 100644
--- a/iocore/net/P_UnixNetVConnection.h
+++ b/iocore/net/P_UnixNetVConnection.h
@@ -174,8 +174,8 @@ public:
/////////////////////////////////////////////////////////////////
UnixNetVConnection();
- int populate_protocol(ts::string_view *results, int n) const override;
- const char *protocol_contains(ts::string_view tag) const override;
+ int populate_protocol(std::string_view *results, int n) const override;
+ const char *protocol_contains(std::string_view tag) const override;
// noncopyable
UnixNetVConnection(const NetVConnection &) = delete;
diff --git a/iocore/net/SSLNetVConnection.cc b/iocore/net/SSLNetVConnection.cc
index 892d002..61c0fca 100644
--- a/iocore/net/SSLNetVConnection.cc
+++ b/iocore/net/SSLNetVConnection.cc
@@ -37,6 +37,8 @@
#include <climits>
#include <string>
+using namespace std::literals;
+
#if TS_USE_TLS_ASYNC
#include <openssl/async.h>
#endif
@@ -1700,10 +1702,10 @@ SSLNetVConnection::populate(Connection &con, Continuation *c, void *arg)
return EVENT_DONE;
}
-ts::string_view
+std::string_view
SSLNetVConnection::map_tls_protocol_to_tag(const char *proto_string) const
{
- ts::string_view retval{"tls/?.?"_sv}; // return this if the protocol lookup doesn't work.
+ std::string_view retval{"tls/?.?"sv}; // return this if the protocol lookup doesn't work.
if (proto_string) {
// openSSL guarantees the case of the protocol string.
@@ -1732,7 +1734,7 @@ SSLNetVConnection::map_tls_protocol_to_tag(const char *proto_string) const
}
int
-SSLNetVConnection::populate_protocol(ts::string_view *results, int n) const
+SSLNetVConnection::populate_protocol(std::string_view *results, int n) const
{
int retval = 0;
if (n > retval) {
@@ -1748,10 +1750,10 @@ SSLNetVConnection::populate_protocol(ts::string_view *results, int n) const
}
const char *
-SSLNetVConnection::protocol_contains(ts::string_view prefix) const
+SSLNetVConnection::protocol_contains(std::string_view prefix) const
{
- const char *retval = nullptr;
- ts::string_view tag = map_tls_protocol_to_tag(getSSLProtocol());
+ const char *retval = nullptr;
+ std::string_view tag = map_tls_protocol_to_tag(getSSLProtocol());
if (prefix.size() <= tag.size() && strncmp(tag.data(), prefix.data(), prefix.size()) == 0) {
retval = tag.data();
} else {
diff --git a/iocore/net/SSLSNIConfig.cc b/iocore/net/SSLSNIConfig.cc
index 66e90c2..d947b9c 100644
--- a/iocore/net/SSLSNIConfig.cc
+++ b/iocore/net/SSLSNIConfig.cc
@@ -118,8 +118,8 @@ SNIConfigParams::get(cchar *servername) const
Vec<cchar *> keys;
wild_sni_action_map.get_keys(keys);
for (int i = 0; i < static_cast<int>(keys.length()); i++) {
- ts::string_view sv{servername, strlen(servername)};
- ts::string_view key_sv{keys.get(i)};
+ std::string_view sv{servername, strlen(servername)};
+ std::string_view key_sv{keys.get(i)};
if (sv.size() >= key_sv.size() && sv.substr(sv.size() - key_sv.size()) == key_sv) {
return wild_sni_action_map.get(key_sv.data());
}
diff --git a/iocore/net/UnixNet.cc b/iocore/net/UnixNet.cc
index 5163831..eb95841 100644
--- a/iocore/net/UnixNet.cc
+++ b/iocore/net/UnixNet.cc
@@ -23,6 +23,8 @@
#include "P_Net.h"
+using namespace std::literals;
+
ink_hrtime last_throttle_warning;
ink_hrtime last_shedding_warning;
int net_connections_throttle;
@@ -252,24 +254,24 @@ int
NetHandler::update_nethandler_config(const char *str, RecDataT, RecData data, void *)
{
uint32_t *updated_member = nullptr; // direct pointer to config member for update.
- ts::string_view name{str};
+ std::string_view name{str};
- if (name == "proxy.config.net.max_connections_in"_sv) {
+ if (name == "proxy.config.net.max_connections_in"sv) {
updated_member = &NetHandler::global_config.max_connections_in;
Debug("net_queue", "proxy.config.net.max_connections_in updated to %" PRId64, data.rec_int);
- } else if (name == "proxy.config.net.max_active_connections_in"_sv) {
+ } else if (name == "proxy.config.net.max_active_connections_in"sv) {
updated_member = &NetHandler::global_config.max_connections_active_in;
Debug("net_queue", "proxy.config.net.max_active_connections_in updated to %" PRId64, data.rec_int);
- } else if (name == "proxy.config.net.inactive_threshold_in"_sv) {
+ } else if (name == "proxy.config.net.inactive_threshold_in"sv) {
updated_member = &NetHandler::global_config.inactive_threshold_in;
Debug("net_queue", "proxy.config.net.inactive_threshold_in updated to %" PRId64, data.rec_int);
- } else if (name == "proxy.config.net.transaction_no_activity_timeout_in"_sv) {
+ } else if (name == "proxy.config.net.transaction_no_activity_timeout_in"sv) {
updated_member = &NetHandler::global_config.transaction_no_activity_timeout_in;
Debug("net_queue", "proxy.config.net.transaction_no_activity_timeout_in updated to %" PRId64, data.rec_int);
- } else if (name == "proxy.config.net.keep_alive_no_activity_timeout_in"_sv) {
+ } else if (name == "proxy.config.net.keep_alive_no_activity_timeout_in"sv) {
updated_member = &NetHandler::global_config.keep_alive_no_activity_timeout_in;
Debug("net_queue", "proxy.config.net.keep_alive_no_activity_timeout_in updated to %" PRId64, data.rec_int);
- } else if (name == "proxy.config.net.default_inactivity_timeout"_sv) {
+ } else if (name == "proxy.config.net.default_inactivity_timeout"sv) {
updated_member = &NetHandler::global_config.default_inactivity_timeout;
Debug("net_queue", "proxy.config.net.default_inactivity_timeout updated to %" PRId64, data.rec_int);
}
diff --git a/iocore/net/UnixNetVConnection.cc b/iocore/net/UnixNetVConnection.cc
index 263da9a..49515d3 100644
--- a/iocore/net/UnixNetVConnection.cc
+++ b/iocore/net/UnixNetVConnection.cc
@@ -1499,7 +1499,7 @@ UnixNetVConnection::remove_from_active_queue()
}
int
-UnixNetVConnection::populate_protocol(ts::string_view *results, int n) const
+UnixNetVConnection::populate_protocol(std::string_view *results, int n) const
{
int retval = 0;
if (n > retval) {
@@ -1516,9 +1516,9 @@ UnixNetVConnection::populate_protocol(ts::string_view *results, int n) const
}
const char *
-UnixNetVConnection::protocol_contains(ts::string_view tag) const
+UnixNetVConnection::protocol_contains(std::string_view tag) const
{
- ts::string_view retval = options.get_proto_string();
+ std::string_view retval = options.get_proto_string();
if (!IsNoCasePrefixOf(tag, retval)) { // didn't match IP level, check TCP level
retval = options.get_family_string();
if (!IsNoCasePrefixOf(tag, retval)) { // no match here either, return empty.
diff --git a/lib/cppapi/GzipDeflateTransformation.cc b/lib/cppapi/GzipDeflateTransformation.cc
index 977131e..ee85649 100644
--- a/lib/cppapi/GzipDeflateTransformation.cc
+++ b/lib/cppapi/GzipDeflateTransformation.cc
@@ -23,7 +23,7 @@
#include <vector>
#include <zlib.h>
#include <cinttypes>
-#include <ts/string_view.h>
+#include <string_view>
#include "atscppapi/TransformationPlugin.h"
#include "atscppapi/GzipDeflateTransformation.h"
#include "logging_internal.h"
@@ -80,7 +80,7 @@ GzipDeflateTransformation::~GzipDeflateTransformation()
}
void
-GzipDeflateTransformation::consume(ts::string_view data)
+GzipDeflateTransformation::consume(std::string_view data)
{
if (data.size() == 0) {
return;
@@ -118,7 +118,7 @@ GzipDeflateTransformation::consume(ts::string_view data)
LOG_DEBUG("Iteration %d: Deflate compressed %ld bytes to %d bytes, producing output...", iteration, data.size(),
bytes_to_write);
- produce(ts::string_view(reinterpret_cast<char *>(&buffer[0]), static_cast<size_t>(bytes_to_write)));
+ produce(std::string_view(reinterpret_cast<char *>(&buffer[0]), static_cast<size_t>(bytes_to_write)));
} while (state_->z_stream_.avail_out == 0);
state_->z_stream_.next_out = nullptr;
@@ -152,7 +152,7 @@ GzipDeflateTransformation::handleInputComplete()
if (status == Z_OK || status == Z_STREAM_END) {
LOG_DEBUG("Iteration %d: Gzip deflate finalize had an extra %d bytes to process, status '%d'. Producing output...", iteration,
bytes_to_write, status);
- produce(ts::string_view(reinterpret_cast<char *>(buffer), static_cast<size_t>(bytes_to_write)));
+ produce(std::string_view(reinterpret_cast<char *>(buffer), static_cast<size_t>(bytes_to_write)));
} else if (status != Z_STREAM_END) {
LOG_ERROR("Iteration %d: Gzip deflinate finalize produced an error '%d'", iteration, status);
}
diff --git a/lib/cppapi/GzipInflateTransformation.cc b/lib/cppapi/GzipInflateTransformation.cc
index cfa5375..49674f6 100644
--- a/lib/cppapi/GzipInflateTransformation.cc
+++ b/lib/cppapi/GzipInflateTransformation.cc
@@ -24,7 +24,7 @@
#include <vector>
#include <zlib.h>
#include <cinttypes>
-#include <ts/string_view.h>
+#include <string_view>
#include "atscppapi/TransformationPlugin.h"
#include "atscppapi/GzipInflateTransformation.h"
#include "logging_internal.h"
@@ -83,7 +83,7 @@ GzipInflateTransformation::~GzipInflateTransformation()
}
void
-GzipInflateTransformation::consume(ts::string_view data)
+GzipInflateTransformation::consume(std::string_view data)
{
if (data.size() == 0) {
return;
@@ -122,7 +122,7 @@ GzipInflateTransformation::consume(ts::string_view data)
LOG_DEBUG("Iteration %d: Gzip inflated a total of %d bytes, producingOutput...", iteration,
(inflate_block_size - state_->z_stream_.avail_out));
- produce(ts::string_view(&buffer[0], (inflate_block_size - state_->z_stream_.avail_out)));
+ produce(std::string_view(&buffer[0], (inflate_block_size - state_->z_stream_.avail_out)));
state_->bytes_produced_ += (inflate_block_size - state_->z_stream_.avail_out);
}
state_->z_stream_.next_out = nullptr;
diff --git a/lib/cppapi/TransformationPlugin.cc b/lib/cppapi/TransformationPlugin.cc
index 2746d7c..33e73db 100644
--- a/lib/cppapi/TransformationPlugin.cc
+++ b/lib/cppapi/TransformationPlugin.cc
@@ -302,7 +302,7 @@ TransformationPlugin::resumeCallback(TSCont cont, TSEvent event, void *edata)
}
size_t
-TransformationPlugin::doProduce(ts::string_view data)
+TransformationPlugin::doProduce(std::string_view data)
{
LOG_DEBUG("TransformationPlugin=%p tshttptxn=%p producing output with length=%ld", this, state_->txn_, data.length());
int64_t write_length = static_cast<int64_t>(data.length());
@@ -358,7 +358,7 @@ TransformationPlugin::doProduce(ts::string_view data)
}
size_t
-TransformationPlugin::produce(ts::string_view data)
+TransformationPlugin::produce(std::string_view data)
{
if (state_->type_ == REQUEST_TRANSFORMATION) {
state_->request_xform_output_.append(data.data(), data.length());
diff --git a/lib/cppapi/include/atscppapi/GzipDeflateTransformation.h b/lib/cppapi/include/atscppapi/GzipDeflateTransformation.h
index 0833c77..e86913c 100644
--- a/lib/cppapi/include/atscppapi/GzipDeflateTransformation.h
+++ b/lib/cppapi/include/atscppapi/GzipDeflateTransformation.h
@@ -24,7 +24,7 @@
#pragma once
#include <string>
-#include <ts/string_view.h>
+#include <string_view>
#include "atscppapi/TransformationPlugin.h"
namespace atscppapi
@@ -70,7 +70,7 @@ namespace transformations
*
* @param data the input data to compress
*/
- void consume(ts::string_view data) override;
+ void consume(std::string_view data) override;
/**
* Any TransformationPlugin must implement handleInputComplete(), this method will
diff --git a/lib/cppapi/include/atscppapi/GzipInflateTransformation.h b/lib/cppapi/include/atscppapi/GzipInflateTransformation.h
index 9e01793..dbe7648 100644
--- a/lib/cppapi/include/atscppapi/GzipInflateTransformation.h
+++ b/lib/cppapi/include/atscppapi/GzipInflateTransformation.h
@@ -23,7 +23,7 @@
#pragma once
-#include <ts/string_view.h>
+#include <string_view>
#include "atscppapi/TransformationPlugin.h"
namespace atscppapi
@@ -71,7 +71,7 @@ namespace transformations
*
* @param data the input data to decompress
*/
- void consume(ts::string_view) override;
+ void consume(std::string_view) override;
/**
* Any TransformationPlugin must implement handleInputComplete(), this method will
diff --git a/lib/cppapi/include/atscppapi/TransformationPlugin.h b/lib/cppapi/include/atscppapi/TransformationPlugin.h
index 0dc4d29..9258c4b 100644
--- a/lib/cppapi/include/atscppapi/TransformationPlugin.h
+++ b/lib/cppapi/include/atscppapi/TransformationPlugin.h
@@ -22,7 +22,7 @@
#pragma once
-#include <ts/string_view.h>
+#include <string_view>
#include <atscppapi/Transaction.h>
#include <atscppapi/TransactionPlugin.h>
@@ -62,7 +62,7 @@ struct TransformationPluginState;
* transaction.getClientResponse().getHeaders().set("X-Content-Transformed", "1");
* transaction.resume();
* }
- * void consume(ts::string_view data) {
+ * void consume(std::string_view data) {
* produce(data);
* }
* void handleInputComplete() {
@@ -93,7 +93,7 @@ public:
* A method that you must implement when writing a TransformationPlugin, this method will be
* fired whenever an upstream TransformationPlugin has produced output.
*/
- virtual void consume(ts::string_view data) = 0;
+ virtual void consume(std::string_view data) = 0;
/**
* Call this method if you wish to pause the transformation.
@@ -117,7 +117,7 @@ protected:
* This method is how a TransformationPlugin will produce output for the downstream
* transformation plugin.
*/
- size_t produce(ts::string_view);
+ size_t produce(std::string_view);
/**
* This is the method that you must call when you're done producing output for
@@ -130,7 +130,7 @@ protected:
private:
TransformationPluginState *state_; /** Internal state for a TransformationPlugin */
- size_t doProduce(ts::string_view);
+ size_t doProduce(std::string_view);
static int resumeCallback(TSCont cont, TSEvent event, void *edata); /** Resume callback*/
};
diff --git a/lib/records/RecHttp.cc b/lib/records/RecHttp.cc
index f86f588..07f1ee0 100644
--- a/lib/records/RecHttp.cc
+++ b/lib/records/RecHttp.cc
@@ -28,7 +28,7 @@
#include <ts/Tokenizer.h>
#include <strings.h>
#include <ts/ink_inet.h>
-#include <ts/string_view.h>
+#include <string_view>
SessionProtocolNameRegistry globalSessionProtocolNameRegistry;
@@ -379,8 +379,8 @@ HttpProxyPort::processOptions(const char *opts)
if (af_set_p) {
if (in_ip_set_p && m_family != m_inbound_ip.family()) {
- ts::string_view iname{ats_ip_family_name(m_inbound_ip.family())};
- ts::string_view fname{ats_ip_family_name(m_family)};
+ std::string_view iname{ats_ip_family_name(m_inbound_ip.family())};
+ std::string_view fname{ats_ip_family_name(m_family)};
Warning("Invalid port descriptor '%s' - the inbound adddress family [%.*s] is not the same type as the explicit family value "
"[%.*s]",
opts, static_cast<int>(iname.size()), iname.data(), static_cast<int>(fname.size()), fname.data());
diff --git a/lib/records/RecRawStats.cc b/lib/records/RecRawStats.cc
index dfc8e33..4c9038f 100644
--- a/lib/records/RecRawStats.cc
+++ b/lib/records/RecRawStats.cc
@@ -23,7 +23,7 @@
#include "P_RecCore.h"
#include "P_RecProcess.h"
-#include <ts/string_view.h>
+#include <string_view>
//-------------------------------------------------------------------------
// raw_stat_get_total
diff --git a/lib/ts/BufferWriter.h b/lib/ts/BufferWriter.h
index 2d92d4d..29e2522 100644
--- a/lib/ts/BufferWriter.h
+++ b/lib/ts/BufferWriter.h
@@ -29,11 +29,14 @@
#include <vector>
#include <string>
#include <iosfwd>
+#include <string_view>
#include <ts/TextView.h>
#include <ts/MemSpan.h>
#include <ts/BufferWriterForward.h>
+using namespace std::literals;
+
namespace ts
{
/** Base (abstract) class for concrete buffer writers.
@@ -86,7 +89,7 @@ public:
@return @c *this
*/
BufferWriter &
- write(const string_view &sv)
+ write(const std::string_view &sv)
{
return write(sv.data(), sv.size());
}
@@ -367,14 +370,14 @@ public:
}
/// Provide a string_view of all successfully written characters.
- string_view
+ std::string_view
view() const
{
- return string_view(_buf, size());
+ return std::string_view(_buf, size());
}
/// Provide a @c string_view of all successfully written characters as a user conversion.
- operator string_view() const { return view(); }
+ operator std::string_view() const { return view(); }
/** Get a @c FixedBufferWriter for the unused output buffer.
@@ -535,9 +538,9 @@ namespace bw_fmt
/// Global named argument table.
using GlobalSignature = void (*)(BufferWriter &, BWFSpec const &);
- using GlobalTable = std::map<string_view, GlobalSignature>;
+ using GlobalTable = std::map<std::string_view, GlobalSignature>;
extern GlobalTable BWF_GLOBAL_TABLE;
- extern GlobalSignature Global_Table_Find(string_view name);
+ extern GlobalSignature Global_Table_Find(std::string_view name);
/// Generic integral conversion.
BufferWriter &Format_Integer(BufferWriter &w, BWFSpec const &spec, uintmax_t n, bool negative_p);
@@ -550,7 +553,7 @@ namespace bw_fmt
using BWGlobalNameSignature = bw_fmt::GlobalSignature;
/// Add a global @a name to BufferWriter formatting, output generated by @a formatter.
/// @return @c true if the name was register, @c false if not (name already in use).
-bool bwf_register_global(string_view name, BWGlobalNameSignature formatter);
+bool bwf_register_global(std::string_view name, BWGlobalNameSignature formatter);
/** Compiled BufferWriter format.
@@ -575,7 +578,7 @@ public:
the case of no specifier found (@c false) or an empty specifier (@c true).
*/
- static bool parse(TextView &fmt, string_view &literal, string_view &spec);
+ static bool parse(TextView &fmt, std::string_view &literal, std::string_view &spec);
/** Parsed items from the format string.
@@ -617,8 +620,8 @@ BufferWriter::printv(TextView fmt, std::tuple<Args...> const &args)
while (fmt.size()) {
// Next string piece of interest is an (optional) literal and then an (optinal) format specifier.
// There will always be a specifier except for the possible trailing literal.
- string_view lit_v;
- string_view spec_v;
+ std::string_view lit_v;
+ std::string_view spec_v;
bool spec_p = BWFormat::parse(fmt, lit_v, spec_v);
if (lit_v.size()) {
@@ -648,7 +651,7 @@ BufferWriter::printv(TextView fmt, std::tuple<Args...> const &args)
if (gf) {
gf(lw, spec);
} else {
- lw.write("{~"_sv).write(spec._name).write("~}"_sv);
+ lw.write("{~"sv).write(spec._name).write("~}"sv);
}
}
if (lw.extent()) {
@@ -686,7 +689,7 @@ BufferWriter::printv(BWFormat const &fmt, std::tuple<Args...> const &args)
if (0 <= idx && idx < N) {
fa[idx](lw, item._spec, args);
} else if (item._spec._name.size()) {
- lw.write("{~"_sv).write(item._spec._name).write("~}"_sv);
+ lw.write("{~"sv).write(item._spec._name).write("~}"sv);
}
}
bw_fmt::Do_Alignment(item._spec, *this, lw);
@@ -713,13 +716,13 @@ BufferWriter &bwformat(BufferWriter &w, BWFSpec const &spec, MemSpan const &span
// -- Common formatters --
-BufferWriter &bwformat(BufferWriter &w, BWFSpec const &spec, string_view sv);
+BufferWriter &bwformat(BufferWriter &w, BWFSpec const &spec, std::string_view sv);
template <size_t N>
BufferWriter &
bwformat(BufferWriter &w, BWFSpec const &spec, const char (&a)[N])
{
- return bwformat(w, spec, string_view(a, N - 1));
+ return bwformat(w, spec, std::string_view(a, N - 1));
}
inline BufferWriter &
@@ -728,7 +731,7 @@ bwformat(BufferWriter &w, BWFSpec const &spec, const char *v)
if (spec._type == 'x' || spec._type == 'X') {
bwformat(w, spec, static_cast<const void *>(v));
} else {
- bwformat(w, spec, string_view(v));
+ bwformat(w, spec, std::string_view(v));
}
return w;
}
@@ -736,13 +739,13 @@ bwformat(BufferWriter &w, BWFSpec const &spec, const char *v)
inline BufferWriter &
bwformat(BufferWriter &w, BWFSpec const &spec, TextView tv)
{
- return bwformat(w, spec, static_cast<string_view>(tv));
+ return bwformat(w, spec, static_cast<std::string_view>(tv));
}
inline BufferWriter &
bwformat(BufferWriter &w, BWFSpec const &spec, std::string const &s)
{
- return bwformat(w, spec, string_view{s});
+ return bwformat(w, spec, std::string_view{s});
}
template <typename F>
@@ -795,9 +798,9 @@ inline BufferWriter &
bwformat(BufferWriter &w, BWFSpec const &spec, bool f)
{
if ('s' == spec._type) {
- w.write(f ? "true"_sv : "false"_sv);
+ w.write(f ? "true"sv : "false"sv);
} else if ('S' == spec._type) {
- w.write(f ? "TRUE"_sv : "FALSE"_sv);
+ w.write(f ? "TRUE"sv : "FALSE"sv);
} else {
bw_fmt::Format_Integer(w, spec, static_cast<uintmax_t>(f), false);
}
diff --git a/lib/ts/BufferWriterFormat.cc b/lib/ts/BufferWriterFormat.cc
index 4bee3a1..4bdd507 100644
--- a/lib/ts/BufferWriterFormat.cc
+++ b/lib/ts/BufferWriterFormat.cc
@@ -31,6 +31,8 @@
#include <array>
#include <chrono>
+using namespace std::literals;
+
namespace
{
// Customized version of string to int. Using this instead of the general @c svtoi function
@@ -215,7 +217,7 @@ namespace bw_fmt
void
Err_Bad_Arg_Index(BufferWriter &w, int i, size_t n)
{
- static const BWFormat fmt{"{{BAD_ARG_INDEX:{} of {}}}"_sv};
+ static const BWFormat fmt{"{{BAD_ARG_INDEX:{} of {}}}"sv};
w.print(fmt, i, n);
}
@@ -446,7 +448,7 @@ namespace bw_fmt
}
}
width -= static_cast<int>(n);
- string_view digits{buff + sizeof(buff) - n, n};
+ std::string_view digits{buff + sizeof(buff) - n, n};
if (spec._align == BWFSpec::Align::SIGN) { // custom for signed case because prefix and digits are seperated.
if (neg) {
@@ -489,15 +491,15 @@ namespace bw_fmt
BufferWriter &
Format_Floating(BufferWriter &w, BWFSpec const &spec, double f, bool neg_p)
{
- static const ts::string_view infinity_bwf{"Inf"};
- static const ts::string_view nan_bwf{"NaN"};
- static const ts::string_view zero_bwf{"0"};
- static const ts::string_view subnormal_bwf{"subnormal"};
- static const ts::string_view unknown_bwf{"unknown float"};
+ static const std::string_view infinity_bwf{"Inf"};
+ static const std::string_view nan_bwf{"NaN"};
+ static const std::string_view zero_bwf{"0"};
+ static const std::string_view subnormal_bwf{"subnormal"};
+ static const std::string_view unknown_bwf{"unknown float"};
// Handle floating values that are not normal
if (!std::isnormal(f)) {
- ts::string_view unnormal;
+ std::string_view unnormal;
switch (std::fpclassify(f)) {
case FP_INFINITE:
unnormal = infinity_bwf;
@@ -567,8 +569,8 @@ namespace bw_fmt
--width; // '.'
width -= static_cast<int>(r);
- string_view whole_digits{whole + sizeof(whole) - l, l};
- string_view frac_digits{fraction + sizeof(fraction) - r, r};
+ std::string_view whole_digits{whole + sizeof(whole) - l, l};
+ std::string_view frac_digits{fraction + sizeof(fraction) - r, r};
Write_Aligned(w,
[&]() {
@@ -583,7 +585,7 @@ namespace bw_fmt
/// Write out the @a data as hexadecimal, using @a digits as the conversion.
void
- Hex_Dump(BufferWriter &w, string_view data, const char *digits)
+ Hex_Dump(BufferWriter &w, std::string_view data, const char *digits)
{
const char *ptr = data.data();
for (auto n = data.size(); n > 0; --n) {
@@ -596,7 +598,7 @@ namespace bw_fmt
} // namespace bw_fmt
BufferWriter &
-bwformat(BufferWriter &w, BWFSpec const &spec, string_view sv)
+bwformat(BufferWriter &w, BWFSpec const &spec, std::string_view sv)
{
int width = static_cast<int>(spec._min); // amount left to fill.
if (spec._prec > 0) {
@@ -643,8 +645,8 @@ BWFormat::BWFormat(ts::TextView fmt)
int arg_idx = 0;
while (fmt) {
- string_view lit_str;
- string_view spec_str;
+ std::string_view lit_str;
+ std::string_view spec_str;
bool spec_p = this->parse(fmt, lit_str, spec_str);
if (lit_str.size()) {
@@ -673,7 +675,7 @@ BWFormat::~BWFormat() {}
/// Pass the results back in @a literal and @a specifier as appropriate.
/// Update @a fmt to strip the parsed text.
bool
-BWFormat::parse(ts::TextView &fmt, string_view &literal, string_view &specifier)
+BWFormat::parse(ts::TextView &fmt, std::string_view &literal, std::string_view &specifier)
{
TextView::size_type off;
@@ -697,7 +699,7 @@ BWFormat::parse(ts::TextView &fmt, string_view &literal, string_view &specifier)
} else if ('}' == c1) {
throw std::invalid_argument("BWFormat:: Unopened } in format string.");
} else {
- literal = string_view{fmt.data(), off};
+ literal = std::string_view{fmt.data(), off};
fmt.remove_prefix(off + 1);
}
} else {
@@ -724,7 +726,7 @@ BWFormat::Format_Literal(BufferWriter &w, BWFSpec const &spec)
}
bw_fmt::GlobalSignature
-bw_fmt::Global_Table_Find(string_view name)
+bw_fmt::Global_Table_Find(std::string_view name)
{
if (name.size()) {
auto spot = bw_fmt::BWF_GLOBAL_TABLE.find(name);
@@ -748,7 +750,7 @@ FixedBufferWriter::operator>>(int fd) const
}
bool
-bwf_register_global(string_view name, BWGlobalNameSignature formatter)
+bwf_register_global(std::string_view name, BWGlobalNameSignature formatter)
{
return ts::bw_fmt::BWF_GLOBAL_TABLE.emplace(name, formatter).second;
}
@@ -765,7 +767,7 @@ BWF_Timestamp(ts::BufferWriter &w, ts::BWFSpec const &spec)
char buff[32];
std::time_t t = std::time(nullptr);
auto n = strftime(buff, sizeof(buff), "%Y %b %d %H:%M:%S", std::localtime(&t));
- w.write(ts::string_view{buff, n});
+ w.write(std::string_view{buff, n});
}
void
@@ -790,11 +792,11 @@ void
BWF_ThreadName(ts::BufferWriter &w, ts::BWFSpec const &spec)
{
#if defined(__FreeBSD_version)
- bwformat(w, spec, "thread"_sv); // no thread names in FreeBSD.
+ bwformat(w, spec, "thread"sv); // no thread names in FreeBSD.
#else
char name[32]; // manual says at least 16, bump that up a bit.
pthread_getname_np(pthread_self(), name, sizeof(name));
- bwformat(w, spec, ts::string_view{name});
+ bwformat(w, spec, std::string_view{name});
#endif
}
diff --git a/lib/ts/BufferWriterForward.h b/lib/ts/BufferWriterForward.h
index 475a7e2..7f16404 100644
--- a/lib/ts/BufferWriterForward.h
+++ b/lib/ts/BufferWriterForward.h
@@ -62,8 +62,8 @@ struct BWFSpec {
int _prec = -1; ///< Precision
unsigned int _max = std::numeric_limits<unsigned int>::max(); ///< Maxium width
int _idx = -1; ///< Positional "name" of the specification.
- string_view _name; ///< Name of the specification.
- string_view _ext; ///< Extension if provided.
+ std::string_view _name; ///< Name of the specification.
+ std::string_view _ext; ///< Extension if provided.
static const self_type DEFAULT;
diff --git a/lib/ts/CryptoHash.h b/lib/ts/CryptoHash.h
index 971e458..037a726 100644
--- a/lib/ts/CryptoHash.h
+++ b/lib/ts/CryptoHash.h
@@ -23,7 +23,7 @@
#pragma once
#include <ts/BufferWriter.h>
-#include <ts/string_view.h>
+#include <string_view>
/// Apache Traffic Server commons.
@@ -190,7 +190,7 @@ bwformat(BufferWriter &w, BWFSpec const &spec, ats::CryptoHash const &hash)
BWFSpec local_spec{spec};
if ('X' != local_spec._type)
local_spec._type = 'x';
- return bwformat(w, local_spec, ts::string_view(reinterpret_cast<const char *>(hash.u8), CRYPTO_HASH_SIZE));
+ return bwformat(w, local_spec, std::string_view(reinterpret_cast<const char *>(hash.u8), CRYPTO_HASH_SIZE));
}
} // namespace ts
diff --git a/lib/ts/I_Layout.h b/lib/ts/I_Layout.h
index e5ddf77..cf6d7f5 100644
--- a/lib/ts/I_Layout.h
+++ b/lib/ts/I_Layout.h
@@ -32,34 +32,33 @@
// use std string and string view for layout
#include <string>
-#include "ts/string_view.h"
/**
The Layout is a simple place holder for the distribution layout.
*/
struct Layout {
- Layout(ts::string_view const _prefix = {});
+ Layout(std::string_view const _prefix = {});
~Layout();
/**
Return file path relative to Layout->prefix
*/
- std::string relative(ts::string_view file);
+ std::string relative(std::string_view file);
/**
update the sysconfdir to a test conf dir
*/
- void update_sysconfdir(ts::string_view dir);
+ void update_sysconfdir(std::string_view dir);
/**
Return file path relative to dir
Example usage: Layout::relative_to(default_layout()->sysconfdir, "foo.bar");
*/
- static std::string relative_to(ts::string_view dir, ts::string_view file);
+ static std::string relative_to(std::string_view dir, std::string_view file);
/**
Return file path relative to dir
@@ -67,7 +66,7 @@ struct Layout {
Example usage: Layout::relative_to(default_layout()->sysconfdir, "foo.bar");
*/
- static void relative_to(char *buf, size_t bufsz, ts::string_view dir, ts::string_view file);
+ static void relative_to(char *buf, size_t bufsz, std::string_view dir, std::string_view file);
/**
Creates a Layout Object with the given prefix. If no
@@ -75,7 +74,7 @@ struct Layout {
at the compile time.
*/
- static void create(ts::string_view const prefix = {});
+ static void create(std::string_view const prefix = {});
/**
Returns the Layout object created by create_default_layout().
diff --git a/lib/ts/Layout.cc b/lib/ts/Layout.cc
index 053f9eb..c34280a 100644
--- a/lib/ts/Layout.cc
+++ b/lib/ts/Layout.cc
@@ -44,7 +44,7 @@ Layout::get()
}
void
-Layout::create(ts::string_view const prefix)
+Layout::create(std::string_view const prefix)
{
if (layout == nullptr) {
layout = new Layout(prefix);
@@ -52,7 +52,7 @@ Layout::create(ts::string_view const prefix)
}
static void
-_relative(char *path, size_t buffsz, ts::string_view root, ts::string_view file)
+_relative(char *path, size_t buffsz, std::string_view root, std::string_view file)
{
if (ink_filepath_merge(path, buffsz, root.data(), file.data(), INK_FILEPATH_TRUENAME)) {
int err = errno;
@@ -69,7 +69,7 @@ _relative(char *path, size_t buffsz, ts::string_view root, ts::string_view file)
}
static std::string
-layout_relative(ts::string_view root, ts::string_view file)
+layout_relative(std::string_view root, std::string_view file)
{
char path[PATH_NAME_MAX];
std::string ret;
@@ -79,26 +79,26 @@ layout_relative(ts::string_view root, ts::string_view file)
}
std::string
-Layout::relative(ts::string_view file)
+Layout::relative(std::string_view file)
{
return layout_relative(prefix, file);
}
// for updating the structure sysconfdir
void
-Layout::update_sysconfdir(ts::string_view dir)
+Layout::update_sysconfdir(std::string_view dir)
{
sysconfdir.assign(dir.data(), dir.size());
}
std::string
-Layout::relative_to(ts::string_view dir, ts::string_view file)
+Layout::relative_to(std::string_view dir, std::string_view file)
{
return layout_relative(dir, file);
}
void
-Layout::relative_to(char *buf, size_t bufsz, ts::string_view dir, ts::string_view file)
+Layout::relative_to(char *buf, size_t bufsz, std::string_view dir, std::string_view file)
{
char path[PATH_NAME_MAX];
@@ -111,7 +111,7 @@ Layout::relative_to(char *buf, size_t bufsz, ts::string_view dir, ts::string_vie
}
}
-Layout::Layout(ts::string_view const _prefix)
+Layout::Layout(std::string_view const _prefix)
{
if (!_prefix.empty()) {
prefix.assign(_prefix.data(), _prefix.size());
diff --git a/lib/ts/Makefile.am b/lib/ts/Makefile.am
index 746436f..fead563 100644
--- a/lib/ts/Makefile.am
+++ b/lib/ts/Makefile.am
@@ -20,7 +20,7 @@ include $(top_srcdir)/build/tidy.mk
library_includedir=$(includedir)/ts
-library_include_HEADERS = apidefs.h string_view.h TextView.h
+library_include_HEADERS = apidefs.h TextView.h
noinst_PROGRAMS = mkdfa CompileParseRules
check_PROGRAMS = test_tsutil test_arena test_atomic test_freelist test_geometry test_List test_Map test_Vec test_X509HostnameValidator test_tslib
@@ -198,7 +198,6 @@ libtsutil_la_SOURCES = \
SimpleTokenizer.h \
SourceLocation.cc \
SourceLocation.h \
- string_view.h \
TestBox.h \
TextBuffer.cc \
TextBuffer.h \
@@ -274,7 +273,6 @@ test_tslib_SOURCES = \
unit-tests/test_MemArena.cc \
unit-tests/test_MT_hashtable.cc \
unit-tests/test_Scalar.cc \
- unit-tests/test_string_view.cc \
unit-tests/test_scoped_resource.cc \
unit-tests/test_TextView.cc
diff --git a/lib/ts/MemArena.cc b/lib/ts/MemArena.cc
index 22e18cb..e1f3b9d 100644
--- a/lib/ts/MemArena.cc
+++ b/lib/ts/MemArena.cc
@@ -22,6 +22,8 @@
limitations under the License.
*/
+#include <algorithm>
+
#include "MemArena.h"
#include <ts/ink_memory.h>
#include <ts/ink_assert.h>
@@ -183,4 +185,4 @@ MemArena::extent() const
zret += b->size;
}
return zret;
-};
\ No newline at end of file
+};
diff --git a/lib/ts/MemSpan.h b/lib/ts/MemSpan.h
index a7b7765..540e700 100644
--- a/lib/ts/MemSpan.h
+++ b/lib/ts/MemSpan.h
@@ -29,7 +29,7 @@
#include <iosfwd>
#include <iostream>
#include <cstddef>
-#include <ts/string_view.h>
+#include <string_view>
/// Apache Traffic Server commons.
namespace ts
@@ -268,13 +268,13 @@ public:
*
* @return A @c string_view covering the span contents.
*/
- string_view view() const;
+ std::string_view view() const;
/** Support automatic conversion to string_view.
*
* @return A view of the memory in this span.
*/
- operator string_view() const;
+ operator std::string_view() const;
/// Internal utility for computing the difference of two void pointers.
/// @return the byte (char) difference between the pointers, @a lhs - @a rhs
@@ -595,13 +595,13 @@ MemSpan::find_if(F const &pred)
return nullptr;
}
-inline string_view
+inline std::string_view
MemSpan::view() const
{
return {static_cast<const char *>(_data), static_cast<size_t>(_size)};
}
-inline MemSpan::operator string_view() const
+inline MemSpan::operator std::string_view() const
{
return this->view();
}
diff --git a/lib/ts/TextView.h b/lib/ts/TextView.h
index 30c1a3b..a1a688f 100644
--- a/lib/ts/TextView.h
+++ b/lib/ts/TextView.h
@@ -5,7 +5,7 @@
only as the view doesn't own the memory. Along with generic buffer methods are specialized
methods to support better string parsing, particularly token based parsing.
- This class is based on @c ts::string_view and is easily and cheaply converted to and from that class.
+ This class is based on @c std::string_view and is easily and cheaply converted to and from that class.
@section license License
@@ -34,7 +34,7 @@
#include <memory.h>
#include <algorithm>
#include <string>
-#include <ts/string_view.h>
+#include <string_view>
/// Apache Traffic Server commons.
namespace ts
@@ -91,17 +91,17 @@ intmax_t svtoi(TextView src, TextView *parsed = nullptr, int base = 0);
@c TextView is based on an earlier classes @c ConstBuffer, @c StringView and influenced by @c
Boost.string_ref and @c std::string_view. None of these were adequate for how use of @c
ConstBuffer evolved with regard to text based manipulations. @c TextView is a super set of @c
- std::string_view (and therefore our local implementation, @ts::string_view). It is designed to
+ std::string_view (and therefore our local implementation, @std::string_view). It is designed to
be a drop in replacement.
@note To simplify the interface there is no constructor just a character pointer. Constructors require
either a literal string or an explicit length. This avoid ambiguities which are much more annoying that
explicitly calling @c strlen on a character pointer.
*/
-class TextView : public string_view
+class TextView : public std::string_view
{
- using self_type = TextView; ///< Self reference type.
- using super_type = string_view; ///< Parent type.
+ using self_type = TextView; ///< Self reference type.
+ using super_type = std::string_view; ///< Parent type.
public:
/// Default constructor (empty buffer).
@@ -145,7 +145,7 @@ public:
*/
constexpr TextView(std::nullptr_t);
- /// Construct from a @c ts::string_view.
+ /// Construct from a @c std::string_view.
constexpr TextView(super_type const &that);
/// Construct from @c std::string, referencing the entire string contents.
@@ -174,7 +174,7 @@ public:
self_type &operator++();
/** Shift the view to discard the leading @a n bytes.
- Equivalent to @c ts::string_view::remove_prefix
+ Equivalent to @c std::string_view::remove_prefix
@return @a this
*/
self_type &operator+=(size_t n);
@@ -883,7 +883,7 @@ TextView::ltrim(super_type const &delimiters)
inline TextView &
TextView::ltrim(const char *delimiters)
{
- return this->ltrim(ts::string_view(delimiters));
+ return this->ltrim(std::string_view(delimiters));
}
inline TextView &
@@ -924,7 +924,7 @@ TextView::trim(super_type const &delimiters)
inline TextView &
TextView::trim(const char *delimiters)
{
- return this->trim(ts::string_view(delimiters));
+ return this->trim(std::string_view(delimiters));
}
template <typename F>
diff --git a/lib/ts/ink_inet.cc b/lib/ts/ink_inet.cc
index daa496b..4b02280 100644
--- a/lib/ts/ink_inet.cc
+++ b/lib/ts/ink_inet.cc
@@ -36,18 +36,20 @@
IpAddr const IpAddr::INVALID;
-const ts::string_view IP_PROTO_TAG_IPV4("ipv4"_sv);
-const ts::string_view IP_PROTO_TAG_IPV6("ipv6"_sv);
-const ts::string_view IP_PROTO_TAG_UDP("udp"_sv);
-const ts::string_view IP_PROTO_TAG_TCP("tcp"_sv);
-const ts::string_view IP_PROTO_TAG_TLS_1_0("tls/1.0"_sv);
-const ts::string_view IP_PROTO_TAG_TLS_1_1("tls/1.1"_sv);
-const ts::string_view IP_PROTO_TAG_TLS_1_2("tls/1.2"_sv);
-const ts::string_view IP_PROTO_TAG_TLS_1_3("tls/1.3"_sv);
-const ts::string_view IP_PROTO_TAG_HTTP_0_9("http/0.9"_sv);
-const ts::string_view IP_PROTO_TAG_HTTP_1_0("http/1.0"_sv);
-const ts::string_view IP_PROTO_TAG_HTTP_1_1("http/1.1"_sv);
-const ts::string_view IP_PROTO_TAG_HTTP_2_0("h2"_sv); // HTTP/2 over TLS
+using namespace std::literals;
+
+const std::string_view IP_PROTO_TAG_IPV4("ipv4"sv);
+const std::string_view IP_PROTO_TAG_IPV6("ipv6"sv);
+const std::string_view IP_PROTO_TAG_UDP("udp"sv);
+const std::string_view IP_PROTO_TAG_TCP("tcp"sv);
+const std::string_view IP_PROTO_TAG_TLS_1_0("tls/1.0"sv);
+const std::string_view IP_PROTO_TAG_TLS_1_1("tls/1.1"sv);
+const std::string_view IP_PROTO_TAG_TLS_1_2("tls/1.2"sv);
+const std::string_view IP_PROTO_TAG_TLS_1_3("tls/1.3"sv);
+const std::string_view IP_PROTO_TAG_HTTP_0_9("http/0.9"sv);
+const std::string_view IP_PROTO_TAG_HTTP_1_0("http/1.0"sv);
+const std::string_view IP_PROTO_TAG_HTTP_1_1("http/1.1"sv);
+const std::string_view IP_PROTO_TAG_HTTP_2_0("h2"sv); // HTTP/2 over TLS
uint32_t
ink_inet_addr(const char *s)
@@ -142,10 +144,10 @@ ats_ip_ntop(const struct sockaddr *addr, char *dst, size_t size)
return zret;
}
-ts::string_view
+std::string_view
ats_ip_family_name(int family)
{
- return AF_INET == family ? IP_PROTO_TAG_IPV4 : AF_INET6 == family ? IP_PROTO_TAG_IPV6 : "Unspec"_sv;
+ return AF_INET == family ? IP_PROTO_TAG_IPV4 : AF_INET6 == family ? IP_PROTO_TAG_IPV6 : "Unspec"sv;
}
const char *
@@ -157,12 +159,12 @@ ats_ip_nptop(sockaddr const *addr, char *dst, size_t size)
}
int
-ats_ip_parse(ts::string_view str, ts::string_view *addr, ts::string_view *port, ts::string_view *rest)
+ats_ip_parse(std::string_view str, std::string_view *addr, std::string_view *port, std::string_view *rest)
{
ts::TextView src(str); /// Easier to work with for parsing.
// In case the incoming arguments are null, set them here and only check for null once.
// it doesn't matter if it's all the same, the results will be thrown away.
- ts::string_view local;
+ std::string_view local;
if (!addr) {
addr = &local;
}
@@ -221,7 +223,7 @@ ats_ip_parse(ts::string_view str, ts::string_view *addr, ts::string_view *port,
if (tmp.data() == src.data()) { // no digits at all
src.assign(tmp.data() - 1, tmp.size() + 1); // back up to include colon
} else {
- *port = ts::string_view(tmp.data(), src.data() - tmp.data());
+ *port = std::string_view(tmp.data(), src.data() - tmp.data());
}
}
*rest = src;
@@ -230,10 +232,10 @@ ats_ip_parse(ts::string_view str, ts::string_view *addr, ts::string_view *port,
}
int
-ats_ip_pton(const ts::string_view &src, sockaddr *ip)
+ats_ip_pton(const std::string_view &src, sockaddr *ip)
{
int zret = -1;
- ts::string_view addr, port;
+ std::string_view addr, port;
ats_ip_invalidate(ip);
if (0 == ats_ip_parse(src, &addr, &port)) {
@@ -242,9 +244,9 @@ ats_ip_pton(const ts::string_view &src, sockaddr *ip)
char *tmp = static_cast<char *>(alloca(addr.size() + 1));
memcpy(tmp, addr.data(), addr.size());
tmp[addr.size()] = 0;
- addr = ts::string_view(tmp, addr.size());
+ addr = std::string_view(tmp, addr.size());
}
- if (addr.find(':') != ts::string_view::npos) { // colon -> IPv6
+ if (addr.find(':') != std::string_view::npos) { // colon -> IPv6
in6_addr addr6;
if (inet_pton(AF_INET6, addr.data(), &addr6)) {
zret = 0;
@@ -267,7 +269,7 @@ ats_ip_pton(const ts::string_view &src, sockaddr *ip)
}
int
-ats_ip_range_parse(ts::string_view src, IpAddr &lower, IpAddr &upper)
+ats_ip_range_parse(std::string_view src, IpAddr &lower, IpAddr &upper)
{
int zret = TS_ERROR;
IpAddr addr, addr2;
@@ -279,7 +281,7 @@ ats_ip_range_parse(ts::string_view src, IpAddr &lower, IpAddr &upper)
static const uint64_t ones[]{UINT64_MAX, UINT64_MAX};
static const IpAddr MAX_ADDR6{reinterpret_cast<in6_addr const &>(ones)};
- auto idx = src.find_first_of("/-"_sv);
+ auto idx = src.find_first_of("/-"sv);
if (idx != src.npos) {
if (idx + 1 >= src.size()) { // must have something past the separator or it's bogus.
zret = TS_ERROR;
@@ -427,7 +429,7 @@ IpAddr::load(const char *text)
}
int
-IpAddr::load(ts::string_view const &text)
+IpAddr::load(std::string_view const &text)
{
IpEndpoint ip;
int zret = ats_ip_pton(text, &ip.sa);
@@ -529,8 +531,8 @@ ats_ip_getbestaddrinfo(const char *host, IpEndpoint *ip4, IpEndpoint *ip6)
int port = 0; // port value to assign if we find an address.
addrinfo ai_hints;
addrinfo *ai_result;
- ts::string_view addr_text, port_text;
- ts::string_view src(host, strlen(host) + 1);
+ std::string_view addr_text, port_text;
+ std::string_view src(host, strlen(host) + 1);
if (ip4) {
ats_ip_invalidate(ip4);
@@ -545,7 +547,7 @@ ats_ip_getbestaddrinfo(const char *host, IpEndpoint *ip4, IpEndpoint *ip6)
char *tmp = static_cast<char *>(alloca(addr_text.size() + 1));
memcpy(tmp, addr_text.data(), addr_text.size());
tmp[addr_text.size()] = 0;
- addr_text = ts::string_view(tmp, addr_text.size());
+ addr_text = std::string_view(tmp, addr_text.size());
}
ink_zero(ai_hints);
ai_hints.ai_family = AF_UNSPEC;
@@ -629,7 +631,7 @@ ats_ip_getbestaddrinfo(const char *host, IpEndpoint *ip4, IpEndpoint *ip6)
}
int
-ats_ip_check_characters(ts::string_view text)
+ats_ip_check_characters(std::string_view text)
{
bool found_colon = false;
bool found_hex = false;
diff --git a/lib/ts/ink_inet.h b/lib/ts/ink_inet.h
index b048830..a0e74a6 100644
--- a/lib/ts/ink_inet.h
+++ b/lib/ts/ink_inet.h
@@ -27,9 +27,10 @@
#include <netinet/in.h>
#include <netdb.h>
#include <sys/socket.h>
+#include <string_view>
+
#include <ts/ink_memory.h>
#include <ts/ink_apidefs.h>
-#include <ts/string_view.h>
#include <ts/BufferWriterForward.h>
#if !TS_HAS_IN6_IS_ADDR_UNSPECIFIED
@@ -45,18 +46,18 @@ IN6_IS_ADDR_UNSPECIFIED(in6_addr const *addr)
#endif
// IP protocol stack tags.
-extern const ts::string_view IP_PROTO_TAG_IPV4;
-extern const ts::string_view IP_PROTO_TAG_IPV6;
-extern const ts::string_view IP_PROTO_TAG_UDP;
-extern const ts::string_view IP_PROTO_TAG_TCP;
-extern const ts::string_view IP_PROTO_TAG_TLS_1_0;
-extern const ts::string_view IP_PROTO_TAG_TLS_1_1;
-extern const ts::string_view IP_PROTO_TAG_TLS_1_2;
-extern const ts::string_view IP_PROTO_TAG_TLS_1_3;
-extern const ts::string_view IP_PROTO_TAG_HTTP_0_9;
-extern const ts::string_view IP_PROTO_TAG_HTTP_1_0;
-extern const ts::string_view IP_PROTO_TAG_HTTP_1_1;
-extern const ts::string_view IP_PROTO_TAG_HTTP_2_0;
+extern const std::string_view IP_PROTO_TAG_IPV4;
+extern const std::string_view IP_PROTO_TAG_IPV6;
+extern const std::string_view IP_PROTO_TAG_UDP;
+extern const std::string_view IP_PROTO_TAG_TCP;
+extern const std::string_view IP_PROTO_TAG_TLS_1_0;
+extern const std::string_view IP_PROTO_TAG_TLS_1_1;
+extern const std::string_view IP_PROTO_TAG_TLS_1_2;
+extern const std::string_view IP_PROTO_TAG_TLS_1_3;
+extern const std::string_view IP_PROTO_TAG_HTTP_0_9;
+extern const std::string_view IP_PROTO_TAG_HTTP_1_0;
+extern const std::string_view IP_PROTO_TAG_HTTP_1_1;
+extern const std::string_view IP_PROTO_TAG_HTTP_2_0;
struct IpAddr; // forward declare.
@@ -139,10 +140,10 @@ int ats_tcp_somaxconn();
@return 0 if an address was found, non-zero otherwise.
*/
-int ats_ip_parse(ts::string_view src, ///< [in] String to search.
- ts::string_view *addr, ///< [out] Range containing IP address.
- ts::string_view *port, ///< [out] Range containing port.
- ts::string_view *rest = nullptr ///< [out] Remnant past the addr/port if any.
+int ats_ip_parse(std::string_view src, ///< [in] String to search.
+ std::string_view *addr, ///< [out] Range containing IP address.
+ std::string_view *port, ///< [out] Range containing port.
+ std::string_view *rest = nullptr ///< [out] Remnant past the addr/port if any.
);
/** Check to see if a buffer contains only IP address characters.
@@ -151,7 +152,7 @@ int ats_ip_parse(ts::string_view src, ///< [in] String to search.
- AF_INET - only digits and dots.
- AF_INET6 - colons found.
*/
-int ats_ip_check_characters(ts::string_view text);
+int ats_ip_check_characters(std::string_view text);
/**
Wrapper for inet_addr().
@@ -188,7 +189,7 @@ ats_ip_invalidate(IpEndpoint *ip)
/** Get a string name for an IP address family.
@return The string name (never @c nullptr).
*/
-ts::string_view ats_ip_family_name(int family);
+std::string_view ats_ip_family_name(int family);
/// Test for IP protocol.
/// @return @c true if the address is IP, @c false otherwise.
@@ -1046,8 +1047,8 @@ ats_ip_nptop(IpEndpoint const *addr, ///< Address.
@return 0 on success, non-zero on failure.
*/
-int ats_ip_pton(const ts::string_view &text, ///< [in] text.
- sockaddr *addr ///< [out] address
+int ats_ip_pton(const std::string_view &text, ///< [in] text.
+ sockaddr *addr ///< [out] address
);
/** Convert @a text to an IP address and write it to @a addr.
@@ -1066,12 +1067,12 @@ ats_ip_pton(const char *text, ///< [in] text.
sockaddr_in6 *addr ///< [out] address
)
{
- return ats_ip_pton(ts::string_view(text, strlen(text)), ats_ip_sa_cast(addr));
+ return ats_ip_pton(std::string_view(text, strlen(text)), ats_ip_sa_cast(addr));
}
inline int
-ats_ip_pton(const ts::string_view &text, ///< [in] text.
- IpEndpoint *addr ///< [out] address
+ats_ip_pton(const std::string_view &text, ///< [in] text.
+ IpEndpoint *addr ///< [out] address
)
{
return ats_ip_pton(text, &addr->sa);
@@ -1082,7 +1083,7 @@ ats_ip_pton(const char *text, ///< [in] text.
IpEndpoint *addr ///< [out] address
)
{
- return ats_ip_pton(ts::string_view(text, strlen(text)), &addr->sa);
+ return ats_ip_pton(std::string_view(text, strlen(text)), &addr->sa);
}
inline int
@@ -1090,7 +1091,7 @@ ats_ip_pton(const char *text, ///< [in] text.
sockaddr *addr ///< [out] address
)
{
- return ats_ip_pton(ts::string_view(text, strlen(text)), addr);
+ return ats_ip_pton(std::string_view(text, strlen(text)), addr);
}
/** Get the best address info for @a name.
@@ -1203,7 +1204,7 @@ struct IpAddr {
otherwise this object is invalidated.
@return 0 on success, non-zero on failure.
*/
- int load(ts::string_view const &str ///< Text of IP address.
+ int load(std::string_view const &str ///< Text of IP address.
);
/** Output to a string.
@@ -1452,7 +1453,7 @@ ats_ip_pton(const char *text, ///< [in] text.
return addr.load(text) ? 0 : -1;
}
-int ats_ip_range_parse(ts::string_view src, IpAddr &lower, IpAddr &upper);
+int ats_ip_range_parse(std::string_view src, IpAddr &lower, IpAddr &upper);
inline IpEndpoint &
IpEndpoint::assign(IpAddr const &addr, in_port_t port)
diff --git a/lib/ts/ink_memory.h b/lib/ts/ink_memory.h
index 5ea54d9..626fb96 100644
--- a/lib/ts/ink_memory.h
+++ b/lib/ts/ink_memory.h
@@ -28,7 +28,6 @@
#include <cinttypes>
#include <string>
-#include "ts/string_view.h"
#include "ts/ink_config.h"
#if HAVE_UNISTD_H
@@ -151,7 +150,7 @@ ats_stringdup(std::string const &p)
}
inline char *
-ats_stringdup(ts::string_view const &p)
+ats_stringdup(std::string_view const &p)
{
return p.empty() ? nullptr : _xstrdup(p.data(), p.size(), nullptr);
}
@@ -491,7 +490,7 @@ public:
_r = strdup(s.c_str());
}
// constructor with string_view
- explicit ats_scoped_str(const ts::string_view &s)
+ explicit ats_scoped_str(const std::string_view &s)
{
if (s.empty())
_r = nullptr;
@@ -517,7 +516,7 @@ public:
}
// string_view case
self &
- operator=(const ts::string_view &s)
+ operator=(const std::string_view &s)
{
if (s.empty())
_r = nullptr;
diff --git a/lib/ts/ink_res_init.cc b/lib/ts/ink_res_init.cc
index 44011a3..ca0c29c 100644
--- a/lib/ts/ink_res_init.cc
+++ b/lib/ts/ink_res_init.cc
@@ -515,7 +515,7 @@ ink_res_init(ink_res_state statp, ///< State object to update.
cp++;
}
if ((*cp != '\0') && (*cp != '\n')) {
- ts::string_view host(cp, strcspn(cp, ";# \t\n"));
+ std::string_view host(cp, strcspn(cp, ";# \t\n"));
if (0 == ats_ip_pton(host, &statp->nsaddr_list[nserv].sa)) {
// If there was no port in the config, lets use NAMESERVER_PORT
if (ats_ip_port_host_order(&statp->nsaddr_list[nserv].sa) == 0) {
diff --git a/lib/ts/ink_string.h b/lib/ts/ink_string.h
index 92e0ced..7ba8c4c 100644
--- a/lib/ts/ink_string.h
+++ b/lib/ts/ink_string.h
@@ -34,6 +34,7 @@
#include <cstdio>
#include <memory.h>
#include <strings.h>
+#include <string_view>
#include "ts/ink_assert.h"
#include "ts/ink_error.h"
@@ -383,3 +384,19 @@ ink_fast_ltoa(int64_t val, char *buf, int buf_len)
return ink_small_itoa((int)val, buf, buf_len);
}
+
+/// Check for prefix.
+/// @return @c true if @a lhs is a prefix (ignoring case) of @a rhs.
+inline bool
+IsNoCasePrefixOf(std::string_view const &lhs, std::string_view const &rhs)
+{
+ return lhs.size() <= rhs.size() && 0 == strncasecmp(lhs.data(), rhs.data(), lhs.size());
+}
+
+/// Check for prefix.
+/// @return @c true if @a lhs is a prefix of @a rhs.
+inline bool
+IsPrefixOf(std::string_view const &lhs, std::string_view const &rhs)
+{
+ return lhs.size() <= rhs.size() && 0 == memcmp(lhs.data(), rhs.data(), lhs.size());
+}
diff --git a/lib/ts/string_view.h b/lib/ts/string_view.h
deleted file mode 100644
index d4eca7d..0000000
--- a/lib/ts/string_view.h
+++ /dev/null
@@ -1,1093 +0,0 @@
-/** @file
-
- This is an implemetation of the std::string_view class for us to use
- with c++11 and 14 until we can use the c++ 17 standard. This has a few overloads
- to deal with some ats objects to help with migration work
-
- @section license License
-
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-#pragma once
-
-#include <cstddef>
-#include <type_traits>
-#include <iterator>
-#include <stdexcept>
-#include <algorithm>
-#include <utility>
-#include <string>
-#include <ostream>
-#include <cstring>
-
-#if __cplusplus < 201402L
-#define CONSTEXPR14 inline
-#else
-#define CONSTEXPR14 constexpr
-#endif
-
-#if __cplusplus >= 201703L
-namespace ts
-{
-using string_view = std::string_view;
-}
-#else
-namespace ts
-{
-// forward declare class for iterator friend relationship
-template <typename _Type, typename _CharTraits = std::char_traits<_Type>> class basic_string_view;
-
-/////////////////////
-// the iterator
-
-namespace _private_
-{
- template <typename _CharTraits> class string_view_iterator
- { // iterator for character buffer wrapper
- public:
- using iterator_category = std::random_access_iterator_tag;
- using value_type = typename _CharTraits::char_type;
- using difference_type = std::ptrdiff_t;
- using pointer = const value_type *;
- using reference = const value_type &;
-
- constexpr string_view_iterator() noexcept = default;
-
- private:
- friend basic_string_view<value_type, _CharTraits>;
-
- constexpr explicit string_view_iterator(const pointer rhs) noexcept : m_ptr(rhs) {}
-
- public:
- constexpr reference operator*() const noexcept
- { // return designated object
- return *m_ptr;
- }
-
- constexpr pointer operator->() const noexcept
- { // return pointer to class object
- return m_ptr;
- }
-
- CONSTEXPR14 string_view_iterator &
- operator++() noexcept
- { // preincrement
- ++m_ptr;
- return *this;
- }
-
- CONSTEXPR14 string_view_iterator
- operator++(int) noexcept
- { // postincrement
- string_view_iterator tmp{*this};
- ++*this;
- return tmp;
- }
-
- CONSTEXPR14 string_view_iterator &
- operator--() noexcept
- { // predecrement
- --m_ptr;
- return *this;
- }
-
- CONSTEXPR14 string_view_iterator
- operator--(int) noexcept
- { // postdecrement
- string_view_iterator tmp{*this};
- --*this;
- return tmp;
- }
-
- CONSTEXPR14 string_view_iterator &
- operator+=(const difference_type offset) noexcept
- { // increment by integer
- m_ptr += offset;
- return *this;
- }
-
- CONSTEXPR14 string_view_iterator
- operator+(const difference_type offset) const noexcept
- { // return this + integer
- string_view_iterator tmp{*this};
- tmp += offset;
- return tmp;
- }
-
- CONSTEXPR14 string_view_iterator &
- operator-=(const difference_type offset) noexcept
- { // decrement by integer
- m_ptr -= offset;
- return *this;
- }
-
- CONSTEXPR14 string_view_iterator
- operator-(const difference_type offset) const noexcept
- { // return this - integer
- string_view_iterator tmp{*this};
- tmp -= offset;
- return tmp;
- }
-
- constexpr difference_type
- operator-(const string_view_iterator &rhs) const noexcept
- { // return difference of iterators
- return m_ptr - rhs.m_ptr;
- }
-
- constexpr reference operator[](const difference_type offset) const noexcept
- { // subscript
- return *(*this) + offset;
- }
-
- constexpr bool
- operator==(const string_view_iterator &rhs) const noexcept
- { // test for iterator equality
- return m_ptr == rhs.m_ptr;
- }
-
- constexpr bool
- operator!=(const string_view_iterator &rhs) const noexcept
- { // test for iterator inequality
- return !(*this == rhs);
- }
-
- constexpr bool
- operator<(const string_view_iterator &rhs) const noexcept
- { // test if this < rhs
- return m_ptr < rhs.m_ptr;
- }
-
- constexpr bool
- operator>(const string_view_iterator &rhs) const noexcept
- { // test if this > rhs
- return rhs < *this;
- }
-
- constexpr bool
- operator<=(const string_view_iterator &rhs) const noexcept
- { // test if this <= rhs
- return !(rhs < *this);
- }
-
- constexpr bool
- operator>=(const string_view_iterator &rhs) const noexcept
- { // test if this >= rhs
- return !(*this < rhs);
- }
-
- private:
- pointer m_ptr = nullptr;
- };
-} // namespace _private_
-
-template <typename _CharTraits>
-CONSTEXPR14 _private_::string_view_iterator<_CharTraits>
-operator+(const typename _private_::string_view_iterator<_CharTraits>::difference_type offset,
- _private_::string_view_iterator<_CharTraits> rhs) noexcept
-{ // return integer + _Right
- rhs += offset;
- return rhs;
-}
-
-/// the main class
-
-template <typename _Type, typename _CharTraits> class basic_string_view
-{ // wrapper for any kind of contiguous character buffer
-public:
- // some standard junk to say hey.. you are messing up something important.. stop it
- static_assert(std::is_same<_Type, typename _CharTraits::char_type>::value,
- "Bad char_traits for basic_string_view; "
- "N4606 21.4.2 [string.view.template] \"the type traits::char_type shall name the same type as charT.\"");
-
- using traits_type = _CharTraits;
- using value_type = _Type;
- using pointer = _Type *;
- using const_pointer = const _Type *;
- using reference = _Type &;
- using const_reference = const _Type &;
- using const_iterator = _private_::string_view_iterator<_CharTraits>;
- using iterator = const_iterator;
- using const_reverse_iterator = std::reverse_iterator<const_iterator>;
- using reverse_iterator = const_reverse_iterator;
- using size_type = std::size_t;
- using difference_type = ptrdiff_t;
- using self_type = basic_string_view<value_type, traits_type>;
- static constexpr size_type npos{~0ULL};
-
- constexpr basic_string_view() noexcept {}
-
- constexpr basic_string_view(basic_string_view const &) noexcept = default;
- CONSTEXPR14 basic_string_view &operator=(basic_string_view const &) noexcept = default;
-
- /* implicit */
- // Note that with constexpr enabled and modern g++ and clang ( icpc)
- // there is a optmization to strlen and traits_type::length for
- // literals in which the compiler will replace it with the size
- // at compile time. With c++ 17 the constexpr guarrentee
- // that the literal length is optimized out
- constexpr basic_string_view(const_pointer rhs) noexcept : m_data(rhs), m_size(traits_type::length(rhs)) {}
-
- constexpr basic_string_view(const_pointer rhs, const size_type length) noexcept // strengthened
- : m_data(rhs), m_size(length)
- {
- }
-
- // std::string constructor
- constexpr basic_string_view(std::string const &rhs) noexcept : m_data(rhs.data()), m_size(rhs.size()) {}
-
- // For iterator on string_view we don't need to deal with const and non-const as different types
- // they are all const iterators as the string values are immutable
- // keep in mind that the string view is mutable in what it points to
-
- constexpr const_iterator
- begin() const noexcept
- { // get the beginning of the range
- return const_iterator(m_data);
- }
-
- constexpr const_iterator
- end() const noexcept
- { // get the end of the range
- return const_iterator(m_data + m_size);
- }
-
- constexpr const_iterator
- cbegin() const noexcept
- { // get the beginning of the range
- return begin();
- }
-
- constexpr const_iterator
- cend() const noexcept
- { // get the end of the range
- return end();
- }
-
- constexpr const_reverse_iterator
- rbegin() const noexcept
- { // get the beginning of the reversed range
- return const_reverse_iterator{end()};
- }
-
- constexpr const_reverse_iterator
- rend() const noexcept
- { // get the end of the reversed range
- return const_reverse_iterator{begin()};
- }
-
- constexpr const_reverse_iterator
- crbegin() const noexcept
- { // get the beginning of the reversed range
- return rbegin();
- }
-
- constexpr const_reverse_iterator
- crend() const noexcept
- { // get the end of the reversed range
- return rend();
- }
-
- constexpr size_type
- size() const noexcept
- { // get the size of this basic_string_view
- return m_size;
- }
-
- constexpr size_type
- length() const noexcept
- { // get the size of this basic_string_view
- return m_size;
- }
-
- constexpr bool
- empty() const noexcept
- { // check whether this basic_string_view is empty
- return m_size == 0;
- }
-
- constexpr const_pointer
- data() const noexcept
- { // get the base pointer of this basic_string_view
- // std says data does not have to have a NULL terminator
- return m_data;
- }
-
- constexpr size_type
- max_size() const noexcept
- {
- // max size of byte we could make - 1 for npos divided my size of char
- // to return the number of "character sized bytes" we can allocate
- return (UINTPTR_MAX - 1) / sizeof(_Type);
- }
-
- CONSTEXPR14 const_reference operator[](const size_type index) const // strengthened
- {
-// get character at offset
-// assume index is in range
-#ifdef _DEBUG
- check_index_bound(index); // for debug
-#endif
- return m_data[index];
- }
-
- CONSTEXPR14 const_reference
- at(const size_type index) const
- { // get the character at offset or throw if that is out of range
- check_index_bound(index); // add bound check
- return m_data[index];
- }
-
- constexpr const_reference front() const noexcept // strengthened
- {
- // std is undefined for empty string
- return m_data[0];
- }
-
- constexpr const_reference
- back() const
- {
- // std is undefined for empty string
- return m_data[m_size - 1];
- }
-
- CONSTEXPR14 void remove_prefix(const size_type length) noexcept // strengthened
- { // chop off the beginning
- m_data += length;
- m_size -= length;
- }
-
- CONSTEXPR14 void remove_suffix(const size_type length) noexcept // strengthened
- { // chop off the end
- m_size -= std::min(length, m_size);
- }
-
- CONSTEXPR14 void
- swap(basic_string_view &rhs) noexcept
- { // swap contents
- const basic_string_view tmp{rhs}; // note: std::swap is not constexpr
- rhs = *this;
- *this = tmp;
- }
-
- // possibly unsafe.. look for linux equal to a windows copy_s version if it exists
- CONSTEXPR14 size_type
- copy(_Type *const rhs, size_type length, const size_type offset = 0) const
- {
- check_offset_bound(offset);
- length = std::min(length, m_size - offset);
- traits_type::copy(rhs, m_data + offset, length);
- return length;
- }
-
- CONSTEXPR14 basic_string_view
- substr(const size_type offset = 0, size_type length = npos) const
- {
- check_offset_bound(offset);
- length = std::min(length, m_size - offset);
- return basic_string_view(m_data + offset, length);
- }
-
- // this is not a std function.. but is needed in some form for ==, != operators
- // I could make this _equal to say don't call it.. but I won't
- constexpr bool
- _equal(const basic_string_view rhs) const noexcept
- {
- return m_size == rhs.m_size && traits_type::compare(m_data, rhs.m_data, m_size) == 0;
- }
-
- constexpr bool
- _equal(std::string const &rhs) const noexcept
- {
- return m_size == rhs.size() && traits_type::compare(m_data, rhs.data(), m_size) == 0;
- }
-
- CONSTEXPR14 bool
- _equal(value_type const *const rhs) const noexcept
- {
- self_type tmp(rhs);
- return m_size == tmp.size() && traits_type::compare(m_data, tmp.data(), m_size) == 0;
- }
-
- //////////////////////////////////////////////
- // Compare
-
- CONSTEXPR14 int
- compare(const basic_string_view rhs) const noexcept
- {
- const int result = traits_type::compare(m_data, rhs.m_data, std::min(m_size, rhs.size()));
-
- if (result != 0) {
- return result;
- }
-
- if (m_size < rhs.m_size) {
- return -1;
- }
-
- if (m_size > rhs.m_size) {
- return 1;
- }
-
- return 0;
- }
-
- constexpr int
- compare(const size_type offset, const size_type length, const basic_string_view rhs) const
- {
- return substr(offset, length).compare(rhs);
- }
-
- constexpr int
- compare(const size_type offset, const size_type length, const basic_string_view rhs, const size_type rhsoffsetset,
- const size_type rhs_length) const
- {
- return substr(offset, length).compare(rhs.substr(rhsoffsetset, rhs_length));
- }
-
- constexpr int
- compare(const _Type *const rhs) const
- {
- return compare(basic_string_view(rhs));
- }
-
- constexpr int
- compare(const size_type offset, const size_type length, const _Type *const rhs) const
- {
- return substr(offset, length).compare(basic_string_view(rhs));
- }
-
- constexpr int
- compare(const size_type offset, const size_type length, const _Type *const rhs, const size_type rhs_length) const
- {
- return substr(offset, length).compare(basic_string_view(rhs, rhs_length));
- }
-
- //////////////////////
- // find -- string
-
- CONSTEXPR14 size_type find(const _Type *const rhs, const size_type offset, const size_type rhs_length) const
- noexcept // strengthened
- {
- // do we have space to find the string given the offset
- if (rhs_length > m_size || offset > m_size - rhs_length) {
- // no match found
- return npos;
- }
-
- if (rhs_length == 0) { // empty string always matches to offset
- return offset;
- }
-
- // this is the point in which we can stop checking
- const auto end_ptr = m_data + (m_size - rhs_length) + 1;
- // start looking
- for (auto curr = m_data + offset; curr < end_ptr; ++curr) {
- // try to first char
- curr = traits_type::find(curr, end_ptr - curr, *rhs);
- if (!curr) { // didn't find first character; report failure
- return npos;
- }
- // given we found it, see if it compares ( matches)
- if (traits_type::compare(curr, rhs, rhs_length) == 0) { // found match
- return curr - m_data;
- }
- // else try again till we run out of string space
- }
- // no match found
- return npos;
- }
-
- constexpr size_type
- find(const basic_string_view rhs, const size_type offset = 0) const noexcept
- {
- return find(rhs.m_data, offset, rhs.size());
- }
-
- constexpr size_type find(const _Type *const rhs, const size_type offset = 0) const noexcept // strengthened
- {
- return find(rhs, offset, traits_type::length(rhs));
- }
-
- // character form
-
- CONSTEXPR14 size_type
- find(const _Type c, const size_type offset = 0) const noexcept
- {
- if (offset < m_size) {
- const auto found_at = traits_type::find(m_data + offset, m_size - offset, c);
- if (found_at) {
- return found_at - m_data;
- }
- }
- // no match found
- return npos;
- }
-
- /////////////////////////////
- // rfind -- string
-
- CONSTEXPR14 size_type rfind(const _Type *const rhs, const size_type offset, const size_type rhs_length) const
- noexcept // strengthened
- {
- if (rhs_length == 0) {
- return std::min(offset, m_size); // empty string always matches
- }
-
- if (rhs_length <= m_size) {
- // room for match, look for it
- for (auto curr = m_data + std::min(offset, m_size - rhs_length);; --curr) {
- // do we have a match
- if (traits_type::eq(*curr, *rhs) && traits_type::compare(curr, rhs, rhs_length) == 0) {
- // found a match
- return curr - m_data;
- }
-
- // at beginning, no more chance for match?
- if (curr == m_data) {
- break;
- }
- }
- }
-
- return npos;
- }
-
- constexpr size_type rfind(const _Type *const rhs, const size_type offset = npos) const noexcept // strengthened
- {
- return rfind(rhs, offset, traits_type::length(rhs));
- }
-
- constexpr size_type
- rfind(const basic_string_view rhs, const size_type offset = npos) const noexcept
- {
- return rfind(rhs.m_data, offset, rhs.m_size);
- }
-
- // character version
-
- CONSTEXPR14 size_type
- rfind(const _Type c, const size_type offset = npos) const noexcept
- {
- if (m_data != 0) {
- for (auto curr = m_data + std::min(offset, m_size - 1);; --curr) {
- if (traits_type::eq(*curr, c)) {
- // found a match
- return curr - m_data;
- }
-
- if (curr == m_data) {
- // at beginning, no more chances for match
- break;
- }
- }
- }
- // no match found
- return npos;
- }
-
- //////////////////////////////////////
- // find_first_of
-
- CONSTEXPR14 size_type find_first_of(const _Type *const rhs, const size_type offset, const size_type rhs_length) const
- noexcept // strengthened
- {
- if (rhs_length != 0 && offset < m_size) {
- const auto _End = m_data + m_size;
- for (auto curr = m_data + offset; curr < _End; ++curr) {
- if (traits_type::find(rhs, rhs_length, *curr)) {
- // found a match
- return curr - m_data;
- }
- }
- }
-
- // no match found
- return npos;
- }
-
- constexpr size_type find_first_of(const _Type *const rhs, const size_type offset = 0) const noexcept // strengthened
- {
- return find_first_of(rhs, offset, traits_type::length(rhs));
- }
-
- constexpr size_type
- find_first_of(const basic_string_view rhs, const size_type offset = 0) const noexcept
- {
- return find_first_of(rhs.m_data, offset, rhs.m_size);
- }
-
- // character version
-
- CONSTEXPR14 size_type
- find_first_of(const _Type c, const size_type offset = 0) const noexcept
- {
- if (offset < m_size) {
- const auto found_at = traits_type::find(m_data + offset, m_size - offset, c);
- if (found_at) {
- return found_at - m_data;
- }
- }
-
- // no match found
- return npos;
- }
-
- //////////////////////////////
- // find_last_of
-
- CONSTEXPR14 size_type find_last_of(const _Type *const rhs, const size_type offset, const size_type rhs_length) const
- noexcept // strengthened
- {
- if (rhs_length != 0 && m_size != 0) {
- for (auto curr = m_data + std::min(offset, m_size - 1);; --curr) {
- if (traits_type::find(rhs, rhs_length, *curr)) {
- // found a match
- return curr - m_data;
- }
-
- if (curr == m_data) {
- // at beginning, no more chances for match
- break;
- }
- }
- }
-
- // no match found
- return npos;
- }
-
- constexpr size_type find_last_of(const _Type *const rhs, const size_type offset = npos) const noexcept // strengthened
- {
- return find_last_of(rhs, offset, traits_type::length(rhs));
- }
-
- constexpr size_type
- find_last_of(const basic_string_view rhs, const size_type offset = npos) const noexcept
- {
- return find_last_of(rhs.m_data, offset, rhs.m_size);
- }
-
- // character version
-
- CONSTEXPR14 size_type
- find_last_of(const _Type c, const size_type offset = npos) const noexcept
- {
- if (m_size != 0) { // room for match, look for it
- for (auto curr = m_data + std::min(offset, m_size - 1);; --curr) {
- if (traits_type::eq(*curr, c)) {
- // found a match
- return curr - m_data;
- }
-
- if (curr == m_data) {
- // at beginning, no more chances for match
- break;
- }
- }
- }
-
- // no match found
- return npos;
- }
-
- //////////////////////////////
- // find_first_not_of
-
- CONSTEXPR14 size_type find_first_not_of(const _Type *const rhs, const size_type offset, const size_type rhs_length) const
- noexcept // strengthened
- {
- if (offset < m_size) {
- const auto _End = m_data + m_size;
- for (auto curr = m_data + offset; curr < _End; ++curr) {
- if (!traits_type::find(rhs, rhs_length, *curr)) {
- // found a match
- return curr - m_data;
- }
- }
- }
-
- // no match found
- return npos;
- }
-
- constexpr size_type find_first_not_of(const _Type *const rhs, const size_type offset = 0) const noexcept // strengthened
- {
- return find_first_not_of(rhs, offset, traits_type::length(rhs));
- }
-
- constexpr size_type
- find_first_not_of(const basic_string_view rhs, const size_type offset = 0) const noexcept
- {
- return find_first_not_of(rhs.m_data, offset, rhs.m_size);
- }
-
- // character version
-
- CONSTEXPR14 size_type
- find_first_not_of(const _Type c, const size_type offset = 0) const noexcept
- {
- if (offset < m_size) {
- const auto _End = m_data + m_size;
- for (auto curr = m_data + offset; curr < _End; ++curr) {
- if (!traits_type::eq(*curr, c)) {
- // found a match
- return curr - m_data;
- }
- }
- }
-
- // no match found
- return npos;
- }
-
- //////////////////////////////
- // find_last_not_of
-
- CONSTEXPR14 size_type find_last_not_of(const _Type *const rhs, const size_type offset, const size_type rhs_length) const
- noexcept // strengthened
- {
- if (m_size != 0) {
- for (auto curr = m_data + std::min(offset, m_size - 1);; --curr) {
- if (!traits_type::find(rhs, rhs_length, *curr)) {
- // found a match
- return curr - m_data;
- }
-
- if (curr == m_data) {
- // at beginning, no more chances for match
- break;
- }
- }
- }
-
- // no match found
- return npos;
- }
-
- constexpr size_type find_last_not_of(const _Type *const rhs, const size_type offset = npos) const noexcept // strengthened
- {
- return find_last_not_of(rhs, offset, traits_type::length(rhs));
- }
-
- constexpr size_type
- find_last_not_of(const basic_string_view rhs, const size_type offset = npos) const noexcept
- {
- return find_last_not_of(rhs.m_data, offset, rhs.m_size);
- }
-
- // character version
-
- CONSTEXPR14 size_type
- find_last_not_of(const _Type c, const size_type offset = npos) const noexcept
- {
- if (m_size != 0) { // room for match, look for it
- for (auto curr = m_data + std::min(offset, m_size - 1);; --curr) {
- if (!traits_type::eq(*curr, c)) {
- // found a match
- return curr - m_data;
- }
-
- if (curr == m_data) {
- // at beginning, no more chances for match
- break;
- }
- }
- }
- // no match found
- return npos;
- }
-
-private:
- CONSTEXPR14 void
- check_offset_bound(size_type offset) const
- {
- // check that the offset is not greater than the size
- if (offset > m_size) {
- throw std::out_of_range("invalid string_view position");
- }
- }
-
- CONSTEXPR14 void
- check_index_bound(size_type index) const
- {
- // check that the offset is not greater than the size
- if (index >= m_size) {
- throw std::out_of_range("invalid string_view position");
- }
- }
-
-private:
- const_pointer m_data = nullptr;
- size_type m_size = 0;
-};
-
-// operators for basic_string_view<>
-////////////////////////////
-// ==
-template <typename _Type, typename _Traits>
-inline bool
-operator==(basic_string_view<_Type, _Traits> const lhs, basic_string_view<_Type, _Traits> const rhs)
-{
- return lhs._equal(rhs);
-}
-template <typename _Type, typename _Traits>
-inline bool
-operator==(std::string const &lhs, basic_string_view<_Type, _Traits> const rhs)
-{
- return rhs._equal(lhs);
-}
-template <typename _Type, typename _Traits>
-inline bool
-operator==(basic_string_view<_Type, _Traits> const lhs, std::string const &rhs)
-{
- return lhs._equal(rhs);
-}
-template <typename _Type, typename _Traits>
-inline bool
-operator==(basic_string_view<_Type, _Traits> const lhs, char const *const rhs)
-{
- return lhs.compare(rhs) == 0;
-}
-template <typename _Type, typename _Traits>
-inline bool
-operator==(char const *const lhs, basic_string_view<_Type, _Traits> const rhs)
-{
- return rhs.compare(lhs) == 0;
-}
-////////////////////////////
-// !=
-template <typename _Type, typename _Traits>
-inline bool
-operator!=(basic_string_view<_Type, _Traits> const lhs, basic_string_view<_Type, _Traits> const rhs)
-{
- return !lhs._equal(rhs);
-}
-template <typename _Type, typename _Traits>
-inline bool
-operator!=(std::string const &lhs, basic_string_view<_Type, _Traits> const rhs)
-{
- return !rhs._equal(lhs);
-}
-template <typename _Type, typename _Traits>
-inline bool
-operator!=(basic_string_view<_Type, _Traits> const lhs, std::string const &rhs)
-{
- return !lhs._equal(rhs);
-}
-template <typename _Type, typename _Traits>
-inline bool
-operator!=(basic_string_view<_Type, _Traits> const lhs, char const *const rhs)
-{
- return lhs.compare(rhs) != 0;
-}
-template <typename _Type, typename _Traits>
-inline bool
-operator!=(char const *const lhs, basic_string_view<_Type, _Traits> const rhs)
-{
- return rhs.compare(lhs) != 0;
-}
-////////////////////////////
-// <
-template <typename _Type, typename _Traits>
-inline bool
-operator<(basic_string_view<_Type, _Traits> const lhs, basic_string_view<_Type, _Traits> const rhs)
-{
- return lhs.compare(rhs) < 0;
-}
-template <typename _Type, typename _Traits>
-inline bool
-operator<(std::string const &lhs, basic_string_view<_Type, _Traits> const rhs)
-{
- return lhs.compare(rhs) < 0;
-}
-template <typename _Type, typename _Traits>
-inline bool
-operator<(basic_string_view<_Type, _Traits> const lhs, std::string const &rhs)
-{
- return lhs.compare(rhs) < 0;
-}
-template <typename _Type, typename _Traits>
-inline bool
-operator<(basic_string_view<_Type, _Traits> const lhs, char const *const rhs)
-{
- return lhs.compare(rhs) < 0;
-}
-template <typename _Type, typename _Traits>
-inline bool
-operator<(char const *const lhs, basic_string_view<_Type, _Traits> const rhs)
-{
- return rhs.compare(lhs) < 0;
-}
-////////////////////////////
-// >
-
-template <typename _Type, typename _Traits>
-inline bool
-operator>(basic_string_view<_Type, _Traits> const lhs, basic_string_view<_Type, _Traits> const rhs)
-{
- return lhs.compare(rhs) > 0;
-}
-template <typename _Type, typename _Traits>
-inline bool
-operator>(std::string const &lhs, basic_string_view<_Type, _Traits> const rhs)
-{
- return lhs.compare(rhs) > 0;
-}
-template <typename _Type, typename _Traits>
-inline bool
-operator>(basic_string_view<_Type, _Traits> const lhs, std::string const &rhs)
-{
- return lhs.compare(rhs) > 0;
-}
-template <typename _Type, typename _Traits>
-inline bool
-operator>(basic_string_view<_Type, _Traits> const lhs, char const *const rhs)
-{
- return lhs.compare(rhs) > 0;
-}
-template <typename _Type, typename _Traits>
-inline bool
-operator>(char const *const lhs, basic_string_view<_Type, _Traits> const rhs)
-{
- return rhs.compare(lhs) < 0;
-}
-
-////////////////////////////
-// <=
-template <typename _Type, typename _Traits>
-inline bool
-operator<=(basic_string_view<_Type, _Traits> const lhs, basic_string_view<_Type, _Traits> const rhs)
-{
- return lhs.compare(rhs) <= 0;
-}
-template <typename _Type, typename _Traits>
-inline bool
-operator<=(std::string const &lhs, basic_string_view<_Type, _Traits> const rhs)
-{
- return lhs.compare(rhs) <= 0;
-}
-template <typename _Type, typename _Traits>
-inline bool
-operator<=(basic_string_view<_Type, _Traits> const lhs, std::string const &rhs)
-{
- return lhs.compare(rhs) <= 0;
-}
-template <typename _Type, typename _Traits>
-inline bool
-operator<=(basic_string_view<_Type, _Traits> const lhs, char const *const rhs)
-{
- return lhs.compare(rhs) <= 0;
-}
-template <typename _Type, typename _Traits>
-inline bool
-operator<=(char const *const lhs, basic_string_view<_Type, _Traits> const rhs)
-{
- return rhs.compare(lhs) <= 0;
-}
-////////////////////////////
-// >=
-template <typename _Type, typename _Traits>
-inline bool
-operator>=(basic_string_view<_Type, _Traits> const lhs, basic_string_view<_Type, _Traits> const rhs)
-{
- return lhs.compare(rhs) >= 0;
-}
-template <typename _Type, typename _Traits>
-inline bool
-operator>=(std::string const &lhs, basic_string_view<_Type, _Traits> const rhs)
-{
- return lhs.compare(rhs) >= 0;
-}
-template <typename _Type, typename _Traits>
-inline bool
-operator>=(basic_string_view<_Type, _Traits> const lhs, std::string const &rhs)
-{
- return lhs.compare(rhs) >= 0;
-}
-template <typename _Type, typename _Traits>
-inline bool
-operator>=(basic_string_view<_Type, _Traits> const lhs, char const *const rhs)
-{
- return lhs.compare(rhs) >= 0;
-}
-template <typename _Type, typename _Traits>
-inline bool
-operator>=(char const *const lhs, basic_string_view<_Type, _Traits> const rhs)
-{
- return rhs.compare(lhs) >= 0;
-}
-
-// stream operator
-
-template <typename _Type, typename _Traits>
-inline std::basic_ostream<_Type, _Traits> &
-operator<<(std::basic_ostream<_Type, _Traits> &os, const basic_string_view<_Type, _Traits> lhs)
-{
- return os.write(lhs.data(), lhs.size());
-}
-using string_view = basic_string_view<char>;
-
-} // namespace ts
-
-namespace std
-{
-template <class _Type, class _Traits> struct hash<ts::basic_string_view<_Type, _Traits>> {
- using string_type = ts::basic_string_view<_Type, _Traits>;
-
- size_t
- operator()(string_type const &x) const
- {
-// not what I would normally do.. but better than making a custom hash function at the moment.
-// This should also mean we have some consistent behavior with std code
-#if defined(__GLIBCXX__)
- return std::_Hash_impl::hash(x.data(), x.length() * sizeof(typename string_type::value_type));
-#elif defined(_LIBCPP_VERSION)
- return __do_string_hash(x.data(), x.data() + x.size());
-#endif
- }
-};
-} // namespace std
-#endif
-
-/// Literal suffix for string_view.
-/// @note This enables @c string_view literals from C++ string literals in @c constexpr contexts, which
-/// is not the case for the character pointer constructor.
-/// @internal This must be in the global namespace to be found.
-constexpr ts::string_view operator"" _sv(const char *str, size_t len) noexcept
-{
- return ts::string_view(str, len);
-}
-
-//////////////////////////////////////////////////////////////////////////////////////
-// TS local extensions, not dependent on our local implementation of std::string_view.
-
-/// Check for prefix.
-/// @return @c true if @a lhs is a prefix (ignoring case) of @a rhs.
-inline bool
-IsNoCasePrefixOf(ts::string_view const &lhs, ts::string_view const &rhs)
-{
- return lhs.size() <= rhs.size() && 0 == strncasecmp(lhs.data(), rhs.data(), lhs.size());
-}
-/// Check for prefix.
-/// @return @c true if @a lhs is a prefix of @a rhs.
-inline bool
-IsPrefixOf(ts::string_view const &lhs, ts::string_view const &rhs)
-{
- return lhs.size() <= rhs.size() && 0 == memcmp(lhs.data(), rhs.data(), lhs.size());
-}
diff --git a/lib/ts/unit-tests/test_BufferWriter.cc b/lib/ts/unit-tests/test_BufferWriter.cc
index 4675060..d4139e2 100644
--- a/lib/ts/unit-tests/test_BufferWriter.cc
+++ b/lib/ts/unit-tests/test_BufferWriter.cc
@@ -23,12 +23,11 @@
#include "catch.hpp"
#include <ts/BufferWriter.h>
-#include <ts/string_view.h>
#include <cstring>
namespace
{
-ts::string_view three[] = {"a", "", "bcd"};
+std::string_view three[] = {"a", "", "bcd"};
}
TEST_CASE("BufferWriter::write(StringView)", "[BWWSV]")
@@ -174,7 +173,7 @@ twice(BWType &bw)
bw.reduce(0);
- bw.write("The", 3).write(' ').write("quick", 5).write(' ').write(ts::string_view("brown", 5));
+ bw.write("The", 3).write(' ').write("quick", 5).write(' ').write(std::string_view("brown", 5));
if ((bw.capacity() != 20) or bw.error() or (bw.remaining() != (21 - sizeof("The quick brown")))) {
return false;
@@ -315,7 +314,7 @@ TEST_CASE("Discard Buffer Writer", "[BWD]")
bw.reduce(0);
- bw.write("The", 3).write(' ').write("quick", 5).write(' ').write(ts::string_view("brown", 5));
+ bw.write("The", 3).write(' ').write("quick", 5).write(' ').write(std::string_view("brown", 5));
REQUIRE(bw.size() == 0);
REQUIRE(bw.extent() == (sizeof("The quick brown") - 1));
diff --git a/lib/ts/unit-tests/test_BufferWriterFormat.cc b/lib/ts/unit-tests/test_BufferWriterFormat.cc
index db07736..14986f8 100644
--- a/lib/ts/unit-tests/test_BufferWriterFormat.cc
+++ b/lib/ts/unit-tests/test_BufferWriterFormat.cc
@@ -30,6 +30,8 @@
#include <ts/INK_MD5.h>
#include <ts/CryptoHash.h>
+using namespace std::literals;
+
TEST_CASE("Buffer Writer << operator", "[bufferwriter][stream]")
{
ts::LocalBufferWriter<50> bw;
@@ -46,7 +48,7 @@ TEST_CASE("Buffer Writer << operator", "[bufferwriter][stream]")
TEST_CASE("bwprint basics", "[bwprint]")
{
ts::LocalBufferWriter<256> bw;
- ts::string_view fmt1{"Some text"_sv};
+ std::string_view fmt1{"Some text"sv};
bw.print(fmt1);
REQUIRE(bw.view() == fmt1);
@@ -138,7 +140,7 @@ TEST_CASE("BWFormat numerics", "[bwprint][bwformat]")
{
ts::LocalBufferWriter<256> bw;
ts::BWFormat fmt("left >{0:<9}< right >{0:>9}< center >{0:^9}<");
- ts::string_view text{"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"};
+ std::string_view text{"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"};
bw.reduce(0);
static const ts::BWFormat bad_arg_fmt{"{{BAD_ARG_INDEX:{} of {}}}"};
@@ -187,7 +189,7 @@ TEST_CASE("BWFormat numerics", "[bwprint][bwformat]")
bw.print("{:#:d}", ts::MemSpan(const_cast<char *>(char_ptr), 4));
REQUIRE(bw.view() == "0x676f6f64");
- ts::string_view sv{"abc123"};
+ std::string_view sv{"abc123"};
bw.reduce(0);
bw.print("{}", sv);
REQUIRE(bw.view() == sv);
@@ -261,7 +263,7 @@ TEST_CASE("bwstring", "[bwprint][bwstring]")
{
std::string s;
ts::TextView fmt("{} -- {}");
- ts::string_view text{"e99a18c428cb38d5f260853678922e03"};
+ std::string_view text{"e99a18c428cb38d5f260853678922e03"};
ts::bwprint(s, fmt, "string", 956);
REQUIRE(s.size() == 13);
@@ -275,10 +277,10 @@ TEST_CASE("bwstring", "[bwprint][bwstring]")
ts::LocalBufferWriter<128> bw;
char buff[128];
- snprintf(buff, sizeof(buff), "|%s|", bw.print("Deep Silent Complete by {}\0", "Nightwish"_sv).data());
- REQUIRE(ts::string_view(buff) == "|Deep Silent Complete by Nightwish|");
- snprintf(buff, sizeof(buff), "|%s|", bw.reset().print("Deep Silent Complete by {}\0elided junk", "Nightwish"_sv).data());
- REQUIRE(ts::string_view(buff) == "|Deep Silent Complete by Nightwish|");
+ snprintf(buff, sizeof(buff), "|%s|", bw.print("Deep Silent Complete by {}\0", "Nightwish"sv).data());
+ REQUIRE(std::string_view(buff) == "|Deep Silent Complete by Nightwish|");
+ snprintf(buff, sizeof(buff), "|%s|", bw.reset().print("Deep Silent Complete by {}\0elided junk", "Nightwish"sv).data());
+ REQUIRE(std::string_view(buff) == "|Deep Silent Complete by Nightwish|");
}
TEST_CASE("BWFormat integral", "[bwprint][bwformat]")
@@ -491,7 +493,7 @@ TEST_CASE("bwperf", "[bwprint][performance]")
static constexpr const char * FMT = "Format |{:#010x}| '{}'";
static constexpr ts::TextView fmt{FMT, strlen(FMT)};
- static constexpr ts::string_view text{"e99a18c428cb38d5f260853678922e03"_sv};
+ static constexpr std::string_view text{"e99a18c428cb38d5f260853678922e03"sv};
ts::LocalBufferWriter<256> bw;
ts::BWFSpec spec;
diff --git a/lib/ts/unit-tests/test_TextView.cc b/lib/ts/unit-tests/test_TextView.cc
index 718c052..0be0c73 100644
--- a/lib/ts/unit-tests/test_TextView.cc
+++ b/lib/ts/unit-tests/test_TextView.cc
@@ -28,6 +28,7 @@
#include <catch.hpp>
using TV = ts::TextView;
+using namespace std::literals;
TEST_CASE("TextView Constructor", "[libts][TextView]")
{
@@ -35,8 +36,8 @@ TEST_CASE("TextView Constructor", "[libts][TextView]")
ts::TextView tv(base);
ts::TextView a{"Evil Dave Rulez"};
ts::TextView b{base.data(), base.size()};
- ts::TextView c{ts::string_view(base)};
- constexpr ts::TextView d{"Grigor!"_sv};
+ ts::TextView c{std::string_view(base)};
+ constexpr ts::TextView d{"Grigor!"sv};
}
TEST_CASE("TextView Operations", "[libts][TextView]")
diff --git a/lib/ts/unit-tests/test_ink_inet.cc b/lib/ts/unit-tests/test_ink_inet.cc
index ac25bb8..b00ff7e 100644
--- a/lib/ts/unit-tests/test_ink_inet.cc
+++ b/lib/ts/unit-tests/test_ink_inet.cc
@@ -30,6 +30,8 @@
#include <ts/ink_inet.h>
#include <ts/BufferWriter.h>
+using namespace std::literals;
+
TEST_CASE("ink_inet", "[libts][inet][ink_inet]")
{
// Use TextView because string_view(nullptr) fails. Gah.
@@ -56,7 +58,7 @@ TEST_CASE("ink_inet", "[libts][inet][ink_inet]")
};
for (auto const &s : names) {
- ts::string_view host, port, rest;
+ std::string_view host, port, rest;
REQUIRE(0 == ats_ip_parse(s.hostspec, &host, &port, &rest));
REQUIRE(s.host == host);
@@ -87,7 +89,7 @@ TEST_CASE("ats_ip_pton", "[libts][inet][ink_inet]")
REQUIRE(TS_SUCCESS != addr.load("Evil Dave Rulz!"));
- REQUIRE(TS_SUCCESS == ats_ip_range_parse("1.1.1.1-2.2.2.2"_sv, lower, upper));
+ REQUIRE(TS_SUCCESS == ats_ip_range_parse("1.1.1.1-2.2.2.2"sv, lower, upper));
REQUIRE(TS_SUCCESS != ats_ip_range_parse("172.16.39.0/", lower, upper));
REQUIRE(TS_SUCCESS == ats_ip_range_parse("172.16.39.0/24", lower, upper));
REQUIRE(TS_SUCCESS != ats_ip_range_parse("172.16.39.0-", lower, upper));
@@ -114,20 +116,20 @@ TEST_CASE("ats_ip_pton", "[libts][inet][ink_inet]")
REQUIRE(lower == IpAddr{INADDR_ANY});
REQUIRE(upper == IpAddr{INADDR_BROADCAST});
- REQUIRE(TS_SUCCESS == ats_ip_range_parse("c600::-d900::"_sv, lower, upper));
+ REQUIRE(TS_SUCCESS == ats_ip_range_parse("c600::-d900::"sv, lower, upper));
REQUIRE(TS_SUCCESS == ats_ip_range_parse("1300::/96", lower, upper));
REQUIRE(TS_SUCCESS != ats_ip_range_parse("ffee::24c3:3349:3cee:0143/", lower, upper));
REQUIRE(TS_SUCCESS == ats_ip_range_parse("ffee:1337:beef:dead:24c3:3349:3cee:0143/80", lower, upper));
- addr.load("ffee:1337:beef:dead:24c3::"_sv);
+ addr.load("ffee:1337:beef:dead:24c3::"sv);
REQUIRE(lower == addr);
- addr.load("ffee:1337:beef:dead:24c3:FFFF:FFFF:FFFF"_sv);
+ addr.load("ffee:1337:beef:dead:24c3:FFFF:FFFF:FFFF"sv);
REQUIRE(upper == addr);
REQUIRE(TS_SUCCESS == ats_ip_range_parse("ffee:1337:beef:dead:24c3:3349:3cee:0143/57", lower, upper));
- addr.load("ffee:1337:beef:de80::"_sv);
+ addr.load("ffee:1337:beef:de80::"sv);
REQUIRE(lower == addr);
- addr.load("ffee:1337:beef:deff:FFFF:FFFF:FFFF:FFFF"_sv);
+ addr.load("ffee:1337:beef:deff:FFFF:FFFF:FFFF:FFFF"sv);
REQUIRE(upper == addr);
REQUIRE(TS_SUCCESS == ats_ip_range_parse("ffee::24c3:3349:3cee:0143", lower, upper));
@@ -149,14 +151,14 @@ TEST_CASE("ats_ip_pton", "[libts][inet][ink_inet]")
TEST_CASE("inet formatting", "[libts][ink_inet][bwformat]")
{
IpEndpoint ep;
- ts::string_view addr_1{"[ffee::24c3:3349:3cee:143]:8080"};
- ts::string_view addr_2{"172.17.99.231:23995"};
- ts::string_view addr_3{"[1337:ded:BEEF::]:53874"};
- ts::string_view addr_4{"[1337::ded:BEEF]:53874"};
- ts::string_view addr_5{"[1337:0:0:ded:BEEF:0:0:956]:53874"};
- ts::string_view addr_6{"[1337:0:0:ded:BEEF:0:0:0]:53874"};
- ts::string_view addr_7{"172.19.3.105:4951"};
- ts::string_view addr_null{"[::]:53874"};
+ std::string_view addr_1{"[ffee::24c3:3349:3cee:143]:8080"};
+ std::string_view addr_2{"172.17.99.231:23995"};
+ std::string_view addr_3{"[1337:ded:BEEF::]:53874"};
+ std::string_view addr_4{"[1337::ded:BEEF]:53874"};
+ std::string_view addr_5{"[1337:0:0:ded:BEEF:0:0:956]:53874"};
+ std::string_view addr_6{"[1337:0:0:ded:BEEF:0:0:0]:53874"};
+ std::string_view addr_7{"172.19.3.105:4951"};
+ std::string_view addr_null{"[::]:53874"};
ts::LocalBufferWriter<1024> w;
REQUIRE(0 == ats_ip_pton(addr_1, &ep.sa));
diff --git a/lib/ts/unit-tests/test_layout.cc b/lib/ts/unit-tests/test_layout.cc
index fa368f2..ee1d11e 100644
--- a/lib/ts/unit-tests/test_layout.cc
+++ b/lib/ts/unit-tests/test_layout.cc
@@ -66,7 +66,7 @@ TEST_CASE("layout create test", "[create]")
TEST_CASE("relative test", "[relative]")
{
// relative (1 argument)
- ts::string_view sv("file");
+ std::string_view sv("file");
std::string str1 = append_slash(TS_BUILD_PREFIX) + "file";
REQUIRE(Layout::get()->relative(sv) == str1);
}
diff --git a/lib/ts/unit-tests/test_string_view.cc b/lib/ts/unit-tests/test_string_view.cc
deleted file mode 100644
index f1a28aa..0000000
--- a/lib/ts/unit-tests/test_string_view.cc
+++ /dev/null
@@ -1,552 +0,0 @@
-/** @file
- Test file for basic_string_view class
- @section license License
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- */
-
-#include "catch.hpp"
-
-#include "string_view.h"
-#include <functional>
-#include <iostream>
-#include <string>
-#include <vector>
-
-using namespace std;
-
-constexpr auto npos = ts::string_view::npos;
-
-// ======= test for string_view ========
-// test cases:
-//[constructor] [operator] [type] [access] [capacity] [modifier] [operation] [compare] [find]
-
-TEST_CASE("constructor calls", "[string_view] [constructor]")
-{
- SECTION("Literal look for NULL")
- {
- ts::string_view sv("hello");
- REQUIRE(sv.size() == 5);
- REQUIRE(sv.length() == 5);
- REQUIRE(sv.empty() == false);
- REQUIRE(sv == "hello");
-
- constexpr ts::string_view a{"evil dave"_sv};
- REQUIRE(a.size() == 9);
- REQUIRE(a.length() == 9);
- REQUIRE(a.empty() == false);
- REQUIRE(a == "evil dave");
-
- auto b = "grigor rulz"_sv;
- REQUIRE((std::is_same<decltype(b), ts::string_view>::value) == true);
- REQUIRE(b.size() == 11);
- REQUIRE(b.length() == 11);
- REQUIRE(b.empty() == false);
- REQUIRE(b == "grigor rulz");
- }
-
- SECTION("operator =")
- {
- ts::string_view sv;
- sv = "hello";
- REQUIRE(sv.size() == 5);
- REQUIRE(sv.length() == 5);
- REQUIRE(sv.empty() == false);
- REQUIRE(sv == "hello");
- }
-
- SECTION("Literal with NULL")
- {
- ts::string_view sv("hello\0world");
- REQUIRE(sv.size() == 5);
- REQUIRE(sv.length() == 5);
- REQUIRE(sv.empty() == false);
- REQUIRE(sv == "hello");
- }
-
- SECTION("Literal with NULL and size given")
- {
- ts::string_view sv("hello\0world", 11);
- REQUIRE(sv.size() == 11);
- REQUIRE(sv.length() == 11);
- REQUIRE(sv.empty() == false);
- REQUIRE(sv[6] == 'w');
- REQUIRE(sv == ts::string_view("hello\0world", 11));
- }
-
- SECTION("Literal length given")
- {
- ts::string_view sv("hello", 5);
- REQUIRE(sv.size() == 5);
- REQUIRE(sv.length() == 5);
- REQUIRE(sv.empty() == false);
- REQUIRE(sv == "hello");
-
- ts::string_view sv2("0123456789", 6);
- REQUIRE(sv2.size() == 6);
- REQUIRE(sv2 == "012345");
- }
-
- SECTION("Literal length equal 0")
- {
- ts::string_view sv("hello", 0);
- REQUIRE(sv.size() == 0);
- REQUIRE(sv.length() == 0);
- REQUIRE(sv.empty() == true);
- REQUIRE(sv == "");
- }
-
- SECTION("constructor using std string")
- {
- string std_string = "hello";
- ts::string_view sv(std_string);
-
- REQUIRE(sv.size() == std_string.size());
- REQUIRE(sv.size() == std_string.size());
- REQUIRE(sv.empty() == false);
- REQUIRE(sv == "hello");
- }
-
- SECTION("= operator")
- {
- string std_string = "hello";
- ts::string_view sv = std_string;
- char str1[10] = "hello";
- ts::string_view sv2 = str1;
- char const *str2 = "hello";
- ts::string_view sv3 = str2;
-
- REQUIRE(sv == "hello");
- REQUIRE(sv2 == "hello");
- REQUIRE(sv3 == "hello");
- }
-}
-
-TEST_CASE("operators", "[string_view] [operator]")
-{
- SECTION("==")
- {
- ts::string_view sv("hello");
-
- char str1[10] = "hello";
- char const *str2 = "hello";
- string str3 = "hello";
-
- REQUIRE(str2 == str3);
- REQUIRE(str1 == str3);
-
- REQUIRE(sv == "hello");
- REQUIRE(sv == str1);
- REQUIRE(sv == str2);
- REQUIRE(sv == str3);
- }
- SECTION("!=")
- {
- ts::string_view sv("hello");
-
- char str1[10] = "hhhhhhhhh";
- char const *str2 = "hella";
- string str3 = "";
-
- REQUIRE(str2 != str3);
- REQUIRE(str1 != str3);
-
- REQUIRE(sv != str1);
- REQUIRE(sv != str2);
- REQUIRE(sv != str3);
- }
- SECTION(">")
- {
- ts::string_view sv("hello");
-
- char str1[10] = "a";
- char const *str2 = "abcdefg";
- string str3 = "";
-
- REQUIRE(sv > str1);
- REQUIRE(sv > str2);
- REQUIRE(sv > str3);
- }
- SECTION("<")
- {
- ts::string_view sv("hello");
-
- char str1[10] = "z";
- char const *str2 = "zaaaaaa";
- string str3 = "hellz";
-
- REQUIRE(sv < str1);
- REQUIRE(sv < str2);
- REQUIRE(sv < str3);
- }
- SECTION(">=")
- {
- ts::string_view sv("hello");
-
- char str1[10] = "hello";
- char const *str2 = "abcdefg";
- string str3 = "";
-
- REQUIRE(sv >= str1);
- REQUIRE(sv >= str2);
- REQUIRE(sv >= str3);
- }
- SECTION("<=")
- {
- ts::string_view sv("hello");
-
- char str1[10] = "hello";
- char const *str2 = "zaaaaaa";
- string str3 = "hellz";
-
- REQUIRE(sv <= str1);
- REQUIRE(sv <= str2);
- REQUIRE(sv <= str3);
- }
-}
-
-TEST_CASE("Pass in type checking", "[string_view] [type]")
-{
- SECTION("char [] type")
- {
- char str[10] = "hello";
- ts::string_view sv(str);
- REQUIRE(sv == "hello");
- REQUIRE(sv.size() == 5);
- REQUIRE(sv.empty() == false);
-
- char str2[10] = {};
- ts::string_view sv2(str2);
- REQUIRE(sv2 == "");
- REQUIRE(sv2.empty() == true);
- }
-
- SECTION("char * type")
- {
- char const *str = "hello";
- ts::string_view sv(str);
- REQUIRE(sv == "hello");
- REQUIRE(sv.size() == 5);
- REQUIRE(sv.empty() == false);
- }
-
- SECTION("literal type")
- {
- ts::string_view sv("hello");
- REQUIRE(sv == "hello");
- }
-}
-
-TEST_CASE("Access & iterators", "[string_view] [access]")
-{
- SECTION("iterators: begin, end, rbegin, rend")
- {
- ts::string_view sv("abcde");
- ts::string_view::iterator spot;
- ts::string_view::reverse_iterator rspot;
-
- REQUIRE(*sv.begin() == 'a');
- REQUIRE(*sv.cbegin() == 'a');
- REQUIRE(*(--(spot = sv.end())) == 'e');
- REQUIRE(*(--(spot = sv.cend())) == 'e');
- REQUIRE(*sv.rbegin() == 'e');
- REQUIRE(*sv.crbegin() == 'e');
- REQUIRE(*(--(rspot = sv.rend())) == 'a');
- REQUIRE(*(--(rspot = sv.crend())) == 'a');
-
- int n = 0;
- for (auto it : sv) {
- REQUIRE(it == sv[n]);
- n++;
- }
- }
-
- SECTION("access: [], at, front, back, data")
- {
- ts::string_view sv("abcde");
- REQUIRE(sv[0] == 'a');
- REQUIRE(sv[4] == 'e');
-
- REQUIRE(sv.at(0) == 'a');
- REQUIRE(sv.at(4) == 'e');
-
- REQUIRE(sv.front() == 'a');
- REQUIRE(sv.back() == 'e');
-
- REQUIRE(sv.data()[1] == 'b');
- }
-
- SECTION("exception case")
- {
- ts::string_view sv("abcde");
-
- REQUIRE_THROWS_AS(sv.at(100), std::out_of_range);
- REQUIRE_THROWS_AS(sv.at(-1), std::out_of_range);
-
-#if defined(_DEBUG) && __cplusplus <= 201402L
- REQUIRE_THROWS_AS(sv[100], std::out_of_range);
- REQUIRE_THROWS_AS(sv[-1], std::out_of_range);
-#else
- REQUIRE_NOTHROW(sv[100]);
- REQUIRE_NOTHROW(sv[-1]);
-#endif
- }
-}
-
-TEST_CASE("Capacity", "[string_view] [capacity]")
-{
- SECTION("empty string")
- {
- ts::string_view sv;
- REQUIRE(sv.size() == 0);
- REQUIRE(sv.length() == 0);
- REQUIRE(sv.empty() == true);
- REQUIRE(sv.max_size() >= 0x3ffffffffffffffb);
- }
-
- SECTION("literal string")
- {
- ts::string_view sv("abcde");
- REQUIRE(sv.size() == 5);
- REQUIRE(sv.length() == 5);
- REQUIRE(sv.empty() == false);
- REQUIRE(sv.max_size() >= 0x3ffffffffffffffb);
- }
-}
-
-TEST_CASE("Modifier", "[string_view] [modifier]")
-{
- SECTION("remove prefix")
- {
- ts::string_view sv("abcde");
-
- sv.remove_prefix(0);
- REQUIRE(sv == "abcde");
-
- sv.remove_prefix(3);
- REQUIRE(sv == "de");
-
- sv.remove_prefix(2);
- REQUIRE(sv == "");
- }
-
- SECTION("remove suffix")
- {
- ts::string_view sv("abcde");
-
- sv.remove_suffix(0);
- REQUIRE(sv == "abcde");
-
- sv.remove_suffix(3);
- REQUIRE(sv == "ab");
-
- sv.remove_suffix(2);
- REQUIRE(sv.size() == 0);
- }
-
- SECTION("swap")
- {
- ts::string_view sv1("hello");
- ts::string_view sv2("world");
-
- sv1.swap(sv2);
-
- REQUIRE(sv1 == "world");
- REQUIRE(sv2 == "hello");
- }
-}
-
-TEST_CASE("Operations", "[string_view] [operation]")
-{
- SECTION("copy")
- {
- // weird copy
-
- // char str[10];
- // ts::string_view sv("hello");
- // sv.copy(str, 6, 0);
- // REQUIRE(str == "hello");
- }
- SECTION("substr")
- {
- ts::string_view sv("hello");
- REQUIRE(sv.substr(0, 3) == "hel");
- REQUIRE(sv.substr(1, 3) == "ell");
- REQUIRE(sv.substr(0, 100) == "hello");
- }
- SECTION("exception case")
- {
- ts::string_view sv("hello");
- REQUIRE_THROWS_AS(sv.substr(100, 0), std::out_of_range);
- REQUIRE_THROWS_AS(sv.substr(-1, -1), std::out_of_range);
- }
-}
-
-TEST_CASE("Compare", "[string_view] [compare]")
-{
- SECTION("compare pass in char")
- {
- ts::string_view sv("hello");
- REQUIRE(sv.compare("hello") == 0);
- REQUIRE(sv.compare("hella") > 0);
- REQUIRE(sv.compare("hellz") < 0);
- REQUIRE(sv.compare("aaaaaaa") > 0);
- REQUIRE(sv.compare("zzzzzzz") < 0);
- REQUIRE(sv.compare("") > 0);
-
- ts::string_view sv2("hello");
- REQUIRE(sv2.compare(0, 3, "hel") == 0);
- REQUIRE(sv2.compare(1, 3, "ello", 0, 3) == 0);
-
- ts::string_view sv3("");
- REQUIRE(sv3.compare("hello") < 0);
- }
-
- SECTION("compare pass in string view")
- {
- ts::string_view sv("hello");
- ts::string_view sv_test1("hello");
- ts::string_view sv_test2("aello");
- ts::string_view sv_test3("zello");
- REQUIRE(sv.compare(sv_test1) == 0);
- REQUIRE(sv.compare(sv_test2) > 0);
- REQUIRE(sv.compare(sv_test3) < 0);
-
- ts::string_view sv2("hello");
- ts::string_view sv_test4("hel");
- ts::string_view sv_test5("ello");
- REQUIRE(sv.compare(0, 3, sv_test4) == 0);
- REQUIRE(sv.compare(1, 3, sv_test5, 0, 3) == 0);
- }
-
- SECTION("exception case")
- {
- ts::string_view sv("hello");
- REQUIRE_THROWS_AS(sv.compare(100, 1, "hel"), std::out_of_range);
- REQUIRE_THROWS_AS(sv.compare(100, 100, "hel"), std::out_of_range);
- REQUIRE_THROWS_AS(sv.compare(-1, -1, "hel"), std::out_of_range);
- }
-}
-
-TEST_CASE("Find", "[string_view] [find]")
-{
- SECTION("find")
- {
- ts::string_view sv("abcdabcd");
- ts::string_view svtest("bcd");
-
- REQUIRE(sv.find("abcdabcd", 100, 10) == npos);
-
- REQUIRE(sv.find('a') == 0);
- REQUIRE(sv.find(svtest) == 1);
- REQUIRE(sv.find(svtest, 2) == 5);
-
- REQUIRE(sv.find("bcd") == 1);
- REQUIRE(sv.find("bcd", 6) == npos);
-
- REQUIRE(sv.find("bcdx", 0, 3) == 1);
- REQUIRE(sv.find("bcdx", 0, 4) == npos);
-
- ts::string_view sv2;
- REQUIRE(sv2.find('a') == npos);
- }
-
- SECTION("rfind")
- {
- ts::string_view sv("abcdabcd");
- ts::string_view svtest("bcd");
- REQUIRE(sv.find('a') == 0);
- REQUIRE(sv.rfind(svtest) == 5);
-
- REQUIRE(sv.rfind("bcd") == 5);
- REQUIRE(sv.rfind("bcd", 3) == 1);
- REQUIRE(sv.rfind("bcd", 0) == npos);
-
- REQUIRE(sv.rfind("bcdx", 3, 3) == 1);
- REQUIRE(sv.rfind("bcdx", 3, 4) == npos);
- }
-
- SECTION("find_first_of")
- {
- ts::string_view sv("abcdefgabcdefg");
- ts::string_view svtest("hijklma");
-
- REQUIRE(sv.find_first_of('c') == 2);
-
- REQUIRE(sv.find_first_of(svtest) == 0);
- REQUIRE(sv.find_first_of("hijklmb") == 1);
- REQUIRE(sv.find_first_of("hijklmn") == npos);
- REQUIRE(sv.find_first_of("hijkla", 1) == 7);
-
- REQUIRE(sv.find_first_of("hijkla", 1, 0) == npos);
- REQUIRE(sv.find_first_of("hijkla", 1, 5) == npos);
- REQUIRE(sv.find_first_of("hijkla", 1, 6) == 7);
- }
-
- SECTION("find_last_of")
- {
- ts::string_view sv("abcdefgabcdefg");
- ts::string_view svtest("hijklma");
-
- REQUIRE(sv.find_last_of('c') == 9);
-
- REQUIRE(sv.find_last_of(svtest) == 7);
- REQUIRE(sv.find_last_of("hijklmb") == 8);
- REQUIRE(sv.find_last_of("hijklmn") == npos);
-
- REQUIRE(sv.find_last_of("hijkla", 1, 0) == npos);
- REQUIRE(sv.find_last_of("hijkla", 1, 5) == npos);
- REQUIRE(sv.find_last_of("hijkla", 1, 6) == 0);
- }
- SECTION("find_first_not_of")
- {
- ts::string_view sv("abcdefg");
- ts::string_view svtest("abcdxyz");
-
- REQUIRE(sv.find_first_not_of('x') == 0);
-
- REQUIRE(sv.find_first_not_of(svtest) == 4);
- REQUIRE(sv.find_first_not_of("abcdxyz") == 4);
- REQUIRE(sv.find_first_not_of("abcdefg") == npos);
-
- REQUIRE(sv.find_first_not_of("abcdxyz", 1, 0) == 1);
- REQUIRE(sv.find_first_not_of("abcdxyz", 1, 5) == 4);
- REQUIRE(sv.find_first_not_of("aaaaaaaa", 1, 5) == 1);
- }
-
- SECTION("find_last_not_of")
- {
- ts::string_view sv("abcdefg");
- ts::string_view svtest("abcdxyz");
-
- REQUIRE(sv.find_last_not_of('x') == 6);
-
- REQUIRE(sv.find_last_not_of(svtest) == 6);
- REQUIRE(sv.find_last_not_of("abcdxyz") == 6);
- REQUIRE(sv.find_last_not_of("abcdefg") == npos);
- REQUIRE("abcdexyzqqq"_sv.find_last_not_of('q') == 7);
-
- REQUIRE(sv.find_last_not_of("abcdxyz", 1, 0) == 1);
- REQUIRE(sv.find_last_not_of("abcdxyz", 1, 5) == npos);
- REQUIRE(sv.find_last_not_of("aaaaaaaa", 1, 5) == 1);
- }
-
- SECTION("hash")
- {
- ts::string_view sv1("hello");
- ts::string_view sv2("hello world", 5);
- std::hash<ts::string_view> h;
- REQUIRE(h(sv1) == h(sv2));
- }
-}
diff --git a/lib/tsconfig/TsConfigLua.h b/lib/tsconfig/TsConfigLua.h
index fb3b90d..8edfcf2 100644
--- a/lib/tsconfig/TsConfigLua.h
+++ b/lib/tsconfig/TsConfigLua.h
@@ -30,16 +30,16 @@
#ifndef TSCONFIGLUA_H
#define TSCONFIGLUA_H
+#include <iostream>
+#include <string_view>
+#include <unordered_map>
#include "tsconfig/Errata.h"
-#include <unordered_map>
#include "luajit/src/lua.hpp"
-#include <iostream>
-#include <ts/string_view.h>
#include <ts/HashFNV.h>
/// Hash functor for @c string_view
-inline size_t TsLuaConfigSVHash(ts::string_view const& sv)
+inline size_t TsLuaConfigSVHash(std::string_view const& sv)
{
ATSHash64FNV1a h;
h.update(sv.data(), sv.size());
@@ -72,9 +72,9 @@ struct TsConfigDescriptor {
}
* */
Type type; ///< Value type.
- ts::string_view type_name; ///< Literal type name used in the schema.
- ts::string_view name; ///< Name of the configuration value.
- ts::string_view description; ///< Description of the value.
+ std::string_view type_name; ///< Literal type name used in the schema.
+ std::string_view name; ///< Name of the configuration value.
+ std::string_view description; ///< Description of the value.
};
/** Configuration item instance data.
@@ -145,8 +145,8 @@ class TsConfigEnumDescriptor : public TsConfigDescriptor {
using self_type = TsConfigEnumDescriptor;
using super_type = TsConfigDescriptor;
public:
- struct Pair { ts::string_view key; int value; };
- TsConfigEnumDescriptor(Type t, ts::string_view t_name, ts::string_view n, ts::string_view d, std::initializer_list<Pair> pairs)
+ struct Pair { std::string_view key; int value; };
+ TsConfigEnumDescriptor(Type t, std::string_view t_name, std::string_view n, std::string_view d, std::initializer_list<Pair> pairs)
: super_type{t, t_name, n, d}, values{pairs.size(), &TsLuaConfigSVHash}, keys{pairs.size()}
{
for ( auto& p : pairs ) {
@@ -154,9 +154,9 @@ public:
keys[p.value] = p.key;
}
}
- std::unordered_map<ts::string_view, int, size_t(*)(ts::string_view const&) > values;
- std::unordered_map<int, ts::string_view> keys;
- int get(ts::string_view key)
+ std::unordered_map<std::string_view, int, size_t(*)(std::string_view const&) > values;
+ std::unordered_map<int, std::string_view> keys;
+ int get(std::string_view key)
{
return values[key];
}
@@ -176,7 +176,7 @@ public:
{
ts::Errata zret;
std::string key(lua_tostring(L,-1));
- ref = edescriptor.get(ts::string_view(key));
+ ref = edescriptor.get(std::string_view(key));
return zret;
}
};
diff --git a/mgmt/LocalManager.cc b/mgmt/LocalManager.cc
index beb2bc8..18fb027 100644
--- a/mgmt/LocalManager.cc
+++ b/mgmt/LocalManager.cc
@@ -31,7 +31,7 @@
#include "MgmtSocket.h"
#include "ts/ink_cap.h"
#include "FileManager.h"
-#include <ts/string_view.h>
+#include <string_view>
#if TS_USE_POSIX_CAP
#include <sys/capability.h>
@@ -974,7 +974,7 @@ LocalManager::listenForProxy()
// read backlong configuration value and overwrite the default value if found
bool found;
- ts::string_view fam{ats_ip_family_name(p.m_family)};
+ std::string_view fam{ats_ip_family_name(p.m_family)};
RecInt backlog = REC_readInteger("proxy.config.net.listen_backlog", &found);
backlog = (found && backlog >= 0) ? backlog : ats_tcp_somaxconn();
diff --git a/plugins/experimental/ssl_cert_loader/ssl-cert-loader.cc b/plugins/experimental/ssl_cert_loader/ssl-cert-loader.cc
index 0692c8e..ef89cfa 100644
--- a/plugins/experimental/ssl_cert_loader/ssl-cert-loader.cc
+++ b/plugins/experimental/ssl_cert_loader/ssl-cert-loader.cc
@@ -81,15 +81,15 @@ using IpRangeQueue = std::deque<IpRange>;
Configuration Config; // global configuration
void
-Parse_Addr_String(ts::string_view const &text, IpRange &range)
+Parse_Addr_String(std::string_view const &text, IpRange &range)
{
IpAddr newAddr;
// Is there a hyphen?
size_t hyphen_pos = text.find('-');
- if (hyphen_pos != ts::string_view::npos) {
- ts::string_view addr1 = text.substr(0, hyphen_pos);
- ts::string_view addr2 = text.substr(hyphen_pos + 1);
+ if (hyphen_pos != std::string_view::npos) {
+ std::string_view addr1 = text.substr(0, hyphen_pos);
+ std::string_view addr2 = text.substr(hyphen_pos + 1);
range.first.load(addr1);
range.second.load(addr2);
} else { // Assume it is a single address
@@ -267,7 +267,7 @@ Parse_Config(Value &parent, ParsedSslValues &orig_values)
IpRange ipRange;
auto txt = val.getText();
- Parse_Addr_String(ts::string_view(txt._ptr, txt._size), ipRange);
+ Parse_Addr_String(std::string_view(txt._ptr, txt._size), ipRange);
cur_values.server_ips.push_back(ipRange);
}
val = parent.find("server-name");
diff --git a/plugins/experimental/tls_bridge/regex.cc b/plugins/experimental/tls_bridge/regex.cc
index c7405f5..fd1fcc2 100644
--- a/plugins/experimental/tls_bridge/regex.cc
+++ b/plugins/experimental/tls_bridge/regex.cc
@@ -100,14 +100,14 @@ Regex::get_capture_count()
}
bool
-Regex::exec(ts::string_view src) const
+Regex::exec(std::string_view src) const
{
int ovector[30];
return exec(src, ovector, 30);
}
bool
-Regex::exec(ts::string_view src, int *ovector, int ovecsize) const
+Regex::exec(std::string_view src, int *ovector, int ovecsize) const
{
int rv;
diff --git a/plugins/experimental/tls_bridge/regex.h b/plugins/experimental/tls_bridge/regex.h
index 0cb5215..4771dff 100644
--- a/plugins/experimental/tls_bridge/regex.h
+++ b/plugins/experimental/tls_bridge/regex.h
@@ -25,7 +25,7 @@
#include <pcre.h>
#include <algorithm>
-#include <ts/string_view.h>
+#include <string_view>
class Regex
{
@@ -43,8 +43,8 @@ public:
bool compile(const char *pattern, const unsigned flags = 0);
// It is safe to call exec() concurrently on the same object instance
- bool exec(ts::string_view src) const;
- bool exec(ts::string_view src, int *ovector, int ovecsize) const;
+ bool exec(std::string_view src) const;
+ bool exec(std::string_view src, int *ovector, int ovecsize) const;
int get_capture_count();
~Regex();
diff --git a/plugins/experimental/webp_transform/ImageTransform.cc b/plugins/experimental/webp_transform/ImageTransform.cc
index 967b4db..56c09c4 100644
--- a/plugins/experimental/webp_transform/ImageTransform.cc
+++ b/plugins/experimental/webp_transform/ImageTransform.cc
@@ -18,7 +18,7 @@
#include <sstream>
#include <iostream>
-#include <ts/string_view.h>
+#include <string_view>
#include <atscppapi/PluginInit.h>
#include <atscppapi/GlobalPlugin.h>
#include <atscppapi/TransformationPlugin.h>
@@ -51,7 +51,7 @@ public:
}
void
- consume(ts::string_view data) override
+ consume(std::string_view data) override
{
_img.write(data.data(), data.length());
}
@@ -67,7 +67,7 @@ public:
Blob output_blob;
image.magick("WEBP");
image.write(&output_blob);
- produce(ts::string_view(reinterpret_cast<const char *>(output_blob.data()), output_blob.length()));
+ produce(std::string_view(reinterpret_cast<const char *>(output_blob.data()), output_blob.length()));
setOutputComplete();
}
diff --git a/proxy/InkAPI.cc b/proxy/InkAPI.cc
index 9507e67..b1bf3fe 100644
--- a/proxy/InkAPI.cc
+++ b/proxy/InkAPI.cc
@@ -63,7 +63,7 @@
#include "I_RecCore.h"
#include "I_Machine.h"
#include "HttpProxyServerMain.h"
-#include <ts/string_view.h>
+#include <string_view>
#include "api/ts/ts.h"
@@ -2445,7 +2445,7 @@ TSIpStringToAddr(const char *str, size_t str_len, sockaddr *addr)
{
sdk_assert(sdk_sanity_check_null_ptr((void *)str) == TS_SUCCESS);
- if (0 != ats_ip_pton(ts::string_view(str, str_len), addr)) {
+ if (0 != ats_ip_pton(std::string_view(str, str_len), addr)) {
return TS_ERROR;
}
@@ -5951,7 +5951,7 @@ TSHttpArgIndexNameLookup(UserArg::Type type, const char *name, int *arg_idx, con
sdk_assert(sdk_sanity_check_null_ptr(arg_idx) == TS_SUCCESS);
sdk_assert(0 <= type && type < UserArg::Type::COUNT);
- ts::string_view n{name};
+ std::string_view n{name};
for (UserArg *arg = UserArgTable[type], *limit = arg + UserArgIdx[type]; arg < limit; ++arg) {
if (arg->name == n) {
@@ -8401,7 +8401,7 @@ TSHttpTxnConfigStringSet(TSHttpTxn txnp, TSOverridableConfigKey conf, const char
case TS_CONFIG_HTTP_INSERT_FORWARDED:
if (value && length > 0) {
ts::LocalBufferWriter<1024> error;
- HttpForwarded::OptionBitSet bs = HttpForwarded::optStrToBitset(ts::string_view(value, length), error);
+ HttpForwarded::OptionBitSet bs = HttpForwarded::optStrToBitset(std::string_view(value, length), error);
if (!error.size()) {
s->t_state.txn_conf->insert_forwarded = bs;
} else {
@@ -9577,7 +9577,7 @@ TSHttpTxnClientProtocolStackGet(TSHttpTxn txnp, int n, const char **result, int
HttpSM *sm = reinterpret_cast<HttpSM *>(txnp);
int count = 0;
if (sm && n > 0) {
- auto mem = static_cast<ts::string_view *>(alloca(sizeof(ts::string_view) * n));
+ auto mem = static_cast<std::string_view *>(alloca(sizeof(std::string_view) * n));
count = sm->populate_client_protocol(mem, n);
for (int i = 0; i < count; ++i) {
result[i] = mem[i].data();
@@ -9597,7 +9597,7 @@ TSHttpSsnClientProtocolStackGet(TSHttpSsn ssnp, int n, const char **result, int
ProxyClientSession *cs = reinterpret_cast<ProxyClientSession *>(ssnp);
int count = 0;
if (cs && n > 0) {
- auto mem = static_cast<ts::string_view *>(alloca(sizeof(ts::string_view) * n));
+ auto mem = static_cast<std::string_view *>(alloca(sizeof(std::string_view) * n));
count = cs->populate_protocol(mem, n);
for (int i = 0; i < count; ++i) {
result[i] = mem[i].data();
@@ -9620,7 +9620,7 @@ TSHttpTxnClientProtocolStackContains(TSHttpTxn txnp, const char *tag)
{
sdk_assert(sdk_sanity_check_txn(txnp) == TS_SUCCESS);
HttpSM *sm = (HttpSM *)txnp;
- return sm->client_protocol_contains(ts::string_view{tag});
+ return sm->client_protocol_contains(std::string_view{tag});
}
const char *
@@ -9628,7 +9628,7 @@ TSHttpSsnClientProtocolStackContains(TSHttpSsn ssnp, const char *tag)
{
sdk_assert(sdk_sanity_check_http_ssn(ssnp) == TS_SUCCESS);
ProxyClientSession *cs = reinterpret_cast<ProxyClientSession *>(ssnp);
- return cs->protocol_contains(ts::string_view{tag});
+ return cs->protocol_contains(std::string_view{tag});
}
const char *
diff --git a/proxy/ProxyClientSession.h b/proxy/ProxyClientSession.h
index 20f1539..1730ef7 100644
--- a/proxy/ProxyClientSession.h
+++ b/proxy/ProxyClientSession.h
@@ -25,7 +25,7 @@
#include <ts/ink_platform.h>
#include <ts/ink_resolver.h>
-#include <ts/string_view.h>
+#include <string_view>
#include "P_Net.h"
#include "InkAPIInternal.h"
#include "http/HttpServerSession.h"
@@ -238,14 +238,14 @@ public:
}
virtual int
- populate_protocol(ts::string_view *result, int size) const
+ populate_protocol(std::string_view *result, int size) const
{
auto vc = this->get_netvc();
return vc ? vc->populate_protocol(result, size) : 0;
}
virtual const char *
- protocol_contains(ts::string_view tag_prefix) const
+ protocol_contains(std::string_view tag_prefix) const
{
auto vc = this->get_netvc();
return vc ? vc->protocol_contains(tag_prefix) : nullptr;
diff --git a/proxy/ProxyClientTransaction.h b/proxy/ProxyClientTransaction.h
index 8d768dc..12fcf30 100644
--- a/proxy/ProxyClientTransaction.h
+++ b/proxy/ProxyClientTransaction.h
@@ -24,7 +24,7 @@
#pragma once
#include "ProxyClientSession.h"
-#include <ts/string_view.h>
+#include <string_view>
class HttpSM;
class HttpServerSession;
@@ -255,13 +255,13 @@ public:
}
virtual int
- populate_protocol(ts::string_view *result, int size) const
+ populate_protocol(std::string_view *result, int size) const
{
return parent ? parent->populate_protocol(result, size) : 0;
}
virtual const char *
- protocol_contains(ts::string_view tag_prefix) const
+ protocol_contains(std::string_view tag_prefix) const
{
return parent ? parent->protocol_contains(tag_prefix) : nullptr;
}
diff --git a/proxy/hdrs/HTTP.cc b/proxy/hdrs/HTTP.cc
index 32b5aba..dad3210 100644
--- a/proxy/hdrs/HTTP.cc
+++ b/proxy/hdrs/HTTP.cc
@@ -1139,7 +1139,7 @@ validate_hdr_host(HTTPHdrImpl *hh)
} else {
int host_len = 0;
const char *host_val = host_field->value_get(&host_len);
- ts::string_view addr, port, rest, host(host_val, host_len);
+ std::string_view addr, port, rest, host(host_val, host_len);
if (0 == ats_ip_parse(host, &addr, &port, &rest)) {
if (!port.empty()) {
if (port.size() > 5) {
diff --git a/proxy/hdrs/URL.cc b/proxy/hdrs/URL.cc
index 352a557..3daea05 100644
--- a/proxy/hdrs/URL.cc
+++ b/proxy/hdrs/URL.cc
@@ -109,7 +109,7 @@ is_host_char(char c)
// Checks if `addr` is a valid FQDN string
bool
-validate_host_name(ts::string_view addr)
+validate_host_name(std::string_view addr)
{
return std::all_of(addr.begin(), addr.end(), &is_host_char);
}
@@ -1312,7 +1312,7 @@ url_parse_internet(HdrHeap *heap, URLImpl *url, const char **start, char const *
}
}
if (host._size) {
- if (validate_host_name(ts::string_view(host._ptr, host._size))) {
+ if (validate_host_name(std::string_view(host._ptr, host._size))) {
url_host_set(heap, url, host._ptr, host._size, copy_strings_p);
} else {
return PARSE_RESULT_ERROR;
diff --git a/proxy/hdrs/URL.h b/proxy/hdrs/URL.h
index 162f886..c2bb0f9 100644
--- a/proxy/hdrs/URL.h
+++ b/proxy/hdrs/URL.h
@@ -28,7 +28,7 @@
#include "HdrHeap.h"
#include "ts/CryptoHash.h"
#include "MIME.h"
-#include <ts/string_view.h>
+#include <string_view>
#include "ts/ink_apidefs.h"
@@ -155,7 +155,7 @@ extern int URL_LEN_MMST;
void url_adjust(MarshalXlate *str_xlate, int num_xlate);
/* Public */
-bool validate_host_name(ts::string_view addr);
+bool validate_host_name(std::string_view addr);
void url_init();
URLImpl *url_create(HdrHeap *heap);
diff --git a/proxy/http/ForwardedConfig.cc b/proxy/http/ForwardedConfig.cc
index 6663d1d..1365dd8 100644
--- a/proxy/http/ForwardedConfig.cc
+++ b/proxy/http/ForwardedConfig.cc
@@ -25,7 +25,7 @@
#include <string>
#include <cctype>
-#include <ts/string_view.h>
+#include <string_view>
#include <ts/TextView.h>
#include <HttpConfig.h>
@@ -121,7 +121,7 @@ eqIgnoreCaseWs(ts::TextView sv, const char *target)
namespace HttpForwarded
{
OptionBitSet
-optStrToBitset(ts::string_view optConfigStr, ts::FixedBufferWriter &error)
+optStrToBitset(std::string_view optConfigStr, ts::FixedBufferWriter &error)
{
const ts::TextView Delimiters(":|");
diff --git a/proxy/http/HttpConfig.cc b/proxy/http/HttpConfig.cc
index 0660f7d..97ea45e 100644
--- a/proxy/http/HttpConfig.cc
+++ b/proxy/http/HttpConfig.cc
@@ -188,7 +188,7 @@ http_insert_forwarded_cb(const char *name, RecDataT dtype, RecData data, void *c
if (0 == strcasecmp("proxy.config.http.insert_forwarded", name)) {
if (RECD_STRING == dtype) {
ts::LocalBufferWriter<1024> error;
- HttpForwarded::OptionBitSet bs = HttpForwarded::optStrToBitset(ts::string_view(data.rec_string), error);
+ HttpForwarded::OptionBitSet bs = HttpForwarded::optStrToBitset(std::string_view(data.rec_string), error);
if (!error.size()) {
c->oride.insert_forwarded = bs;
valid_p = true;
@@ -981,7 +981,7 @@ HttpConfig::startup()
if (REC_ERR_OKAY == RecGetRecordString("proxy.config.http.insert_forwarded", str, sizeof(str))) {
ts::LocalBufferWriter<1024> error;
- HttpForwarded::OptionBitSet bs = HttpForwarded::optStrToBitset(ts::string_view(str), error);
+ HttpForwarded::OptionBitSet bs = HttpForwarded::optStrToBitset(std::string_view(str), error);
if (!error.size()) {
c.oride.insert_forwarded = bs;
} else {
diff --git a/proxy/http/HttpConfig.h b/proxy/http/HttpConfig.h
index f0acf74..3518dce 100644
--- a/proxy/http/HttpConfig.h
+++ b/proxy/http/HttpConfig.h
@@ -44,7 +44,7 @@
#include "ts/ink_platform.h"
#include "ts/ink_inet.h"
#include "ts/Regex.h"
-#include "ts/string_view.h"
+#include "string_view"
#include "ts/BufferWriter.h"
#include "HttpProxyAPIEnums.h"
#include "ProxyConfig.h"
@@ -387,7 +387,7 @@ using OptionBitSet = std::bitset<NUM_OPTIONS>;
// Converts string specifier for Forwarded options to bitset of options, and return the result. If there are errors, an error
// message will be inserted into 'error'.
//
-OptionBitSet optStrToBitset(ts::string_view optConfigStr, ts::FixedBufferWriter &error);
+OptionBitSet optStrToBitset(std::string_view optConfigStr, ts::FixedBufferWriter &error);
} // namespace HttpForwarded
diff --git a/proxy/http/HttpSM.cc b/proxy/http/HttpSM.cc
index 8197a36..765a014 100644
--- a/proxy/http/HttpSM.cc
+++ b/proxy/http/HttpSM.cc
@@ -7978,11 +7978,11 @@ HttpSM::is_redirect_required()
// Fill in the client protocols used. Return the number of entries returned
int
-HttpSM::populate_client_protocol(ts::string_view *result, int n) const
+HttpSM::populate_client_protocol(std::string_view *result, int n) const
{
int retval = 0;
if (n > 0) {
- ts::string_view proto = HttpSM::find_proto_string(t_state.hdr_info.client_request.version_get());
+ std::string_view proto = HttpSM::find_proto_string(t_state.hdr_info.client_request.version_get());
if (!proto.empty()) {
result[retval++] = proto;
if (n > retval && ua_txn) {
@@ -7995,12 +7995,12 @@ HttpSM::populate_client_protocol(ts::string_view *result, int n) const
// Look for a specific protocol
const char *
-HttpSM::client_protocol_contains(ts::string_view tag_prefix) const
+HttpSM::client_protocol_contains(std::string_view tag_prefix) const
{
- const char *retval = nullptr;
- ts::string_view proto = HttpSM::find_proto_string(t_state.hdr_info.client_request.version_get());
+ const char *retval = nullptr;
+ std::string_view proto = HttpSM::find_proto_string(t_state.hdr_info.client_request.version_get());
if (!proto.empty()) {
- ts::string_view prefix(tag_prefix);
+ std::string_view prefix(tag_prefix);
if (prefix.size() <= proto.size() && 0 == strncmp(proto.data(), prefix.data(), prefix.size())) {
retval = proto.data();
} else if (ua_txn) {
@@ -8010,7 +8010,7 @@ HttpSM::client_protocol_contains(ts::string_view tag_prefix) const
return retval;
}
-ts::string_view
+std::string_view
HttpSM::find_proto_string(HTTPVersion version) const
{
if (version == HTTPVersion(1, 1)) {
diff --git a/proxy/http/HttpSM.h b/proxy/http/HttpSM.h
index 4bacc2e..6deb150 100644
--- a/proxy/http/HttpSM.h
+++ b/proxy/http/HttpSM.h
@@ -41,7 +41,7 @@
#include "InkAPIInternal.h"
#include "../ProxyClientTransaction.h"
#include "HdrUtils.h"
-#include <ts/string_view.h>
+#include <string_view>
#include <ts/History.h>
//#include "AuthHttpAdapter.h"
@@ -306,9 +306,9 @@ public:
/// Get the protocol stack for the inbound (client, user agent) connection.
/// @arg result [out] Array to store the results
/// @arg n [in] Size of the array @a result.
- int populate_client_protocol(ts::string_view *result, int n) const;
- const char *client_protocol_contains(ts::string_view tag_prefix) const;
- ts::string_view find_proto_string(HTTPVersion version) const;
+ int populate_client_protocol(std::string_view *result, int n) const;
+ const char *client_protocol_contains(std::string_view tag_prefix) const;
+ std::string_view find_proto_string(HTTPVersion version) const;
int64_t sm_id = -1;
unsigned int magic = HTTP_SM_MAGIC_DEAD;
diff --git a/proxy/http/HttpServerSession.h b/proxy/http/HttpServerSession.h
index 548653d..b3a134e 100644
--- a/proxy/http/HttpServerSession.h
+++ b/proxy/http/HttpServerSession.h
@@ -181,14 +181,14 @@ public:
MIOBuffer *read_buffer;
virtual int
- populate_protocol(ts::string_view *result, int size) const
+ populate_protocol(std::string_view *result, int size) const
{
auto vc = this->get_netvc();
return vc ? vc->populate_protocol(result, size) : 0;
}
virtual const char *
- protocol_contains(ts::string_view tag_prefix) const
+ protocol_contains(std::string_view tag_prefix) const
{
auto vc = this->get_netvc();
return vc ? vc->protocol_contains(tag_prefix) : nullptr;
diff --git a/proxy/http/HttpTransactHeaders.cc b/proxy/http/HttpTransactHeaders.cc
index 52f97fd..9168afa 100644
--- a/proxy/http/HttpTransactHeaders.cc
+++ b/proxy/http/HttpTransactHeaders.cc
@@ -23,10 +23,11 @@
#include <bitset>
#include <algorithm>
+#include <array>
+#include <string_view>
#include <ts/ink_platform.h>
#include <ts/BufferWriter.h>
-#include <ts/string_view.h>
#include "HttpTransact.h"
#include "HttpTransactHeaders.h"
@@ -37,7 +38,7 @@
#include "I_Machine.h"
-#include <array>
+using namespace std::literals;
bool
HttpTransactHeaders::is_method_cacheable(const HttpConfigParams *http_config_param, const int method)
@@ -694,7 +695,7 @@ HttpTransactHeaders::insert_server_header_in_response(const char *server_tag, in
/// Returns the number of characters appended to hdr_string (no nul appended).
int
HttpTransactHeaders::write_hdr_protocol_stack(char *hdr_string, size_t len, ProtocolStackDetail pSDetail,
- ts::string_view *proto_buf, int n_proto, char separator)
+ std::string_view *proto_buf, int n_proto, char separator)
{
char *hdr = hdr_string; // keep original pointer for size computation later.
char *limit = hdr_string + len;
@@ -702,7 +703,7 @@ HttpTransactHeaders::write_hdr_protocol_stack(char *hdr_string, size_t len, Prot
if (n_proto <= 0 || hdr == nullptr || len <= 0) {
// nothing
} else if (ProtocolStackDetail::Full == pSDetail) {
- for (ts::string_view *v = proto_buf, *v_limit = proto_buf + n_proto; v < v_limit && (hdr + v->size() + 1) < limit; ++v) {
+ for (std::string_view *v = proto_buf, *v_limit = proto_buf + n_proto; v < v_limit && (hdr + v->size() + 1) < limit; ++v) {
if (v != proto_buf) {
*hdr++ = separator;
}
@@ -710,12 +711,12 @@ HttpTransactHeaders::write_hdr_protocol_stack(char *hdr_string, size_t len, Prot
hdr += v->size();
}
} else {
- ts::string_view *proto_end = proto_buf + n_proto;
- bool http_1_0_p = std::find(proto_buf, proto_end, IP_PROTO_TAG_HTTP_1_0) != proto_end;
- bool http_1_1_p = std::find(proto_buf, proto_end, IP_PROTO_TAG_HTTP_1_1) != proto_end;
+ std::string_view *proto_end = proto_buf + n_proto;
+ bool http_1_0_p = std::find(proto_buf, proto_end, IP_PROTO_TAG_HTTP_1_0) != proto_end;
+ bool http_1_1_p = std::find(proto_buf, proto_end, IP_PROTO_TAG_HTTP_1_1) != proto_end;
if ((http_1_0_p || http_1_1_p) && hdr + 10 < limit) {
- bool tls_p = std::find_if(proto_buf, proto_end, [](ts::string_view tag) { return IsPrefixOf("tls/"_sv, tag); }) != proto_end;
+ bool tls_p = std::find_if(proto_buf, proto_end, [](std::string_view tag) { return IsPrefixOf("tls/"sv, tag); }) != proto_end;
memcpy(hdr, "http", 4);
hdr += 4;
@@ -800,7 +801,7 @@ HttpTransactHeaders::insert_via_header_in_request(HttpTransact::State *s, HTTPHd
}
char *incoming_via = s->via_string;
- std::array<ts::string_view, 10> proto_buf; // 10 seems like a reasonable number of protos to print
+ std::array<std::string_view, 10> proto_buf; // 10 seems like a reasonable number of protos to print
int n_proto = s->state_machine->populate_client_protocol(proto_buf.data(), proto_buf.size());
via_string +=
@@ -882,7 +883,7 @@ HttpTransactHeaders::insert_via_header_in_response(HttpTransact::State *s, HTTPH
}
char *incoming_via = s->via_string;
- std::array<ts::string_view, 10> proto_buf; // 10 seems like a reasonable number of protos to print
+ std::array<std::string_view, 10> proto_buf; // 10 seems like a reasonable number of protos to print
int n_proto = 0;
// Should suffice - if we're adding a response VIA, the connection is HTTP and only 1.0 and 1.1 are supported outbound.
@@ -1102,8 +1103,8 @@ HttpTransactHeaders::add_forwarded_field_to_request(HttpTransact::State *s, HTTP
}
}
- std::array<ts::string_view, 10> protoBuf; // 10 seems like a reasonable number of protos to print
- int n_proto = 0; // Indulge clang's incorrect claim that this need to be initialized.
+ std::array<std::string_view, 10> protoBuf; // 10 seems like a reasonable number of protos to print
+ int n_proto = 0; // Indulge clang's incorrect claim that this need to be initialized.
static const HttpForwarded::OptionBitSet OptionsNeedingProtocol = HttpForwarded::OptionBitSet()
.set(HttpForwarded::PROTO)
@@ -1133,9 +1134,9 @@ HttpTransactHeaders::add_forwarded_field_to_request(HttpTransact::State *s, HTTP
const MIMEField *hostField = s->hdr_info.client_request.field_find(MIME_FIELD_HOST, MIME_LEN_HOST);
if (hostField and hostField->m_len_value) {
- ts::string_view hSV{hostField->m_ptr_value, hostField->m_len_value};
+ std::string_view hSV{hostField->m_ptr_value, hostField->m_len_value};
- bool needsDoubleQuotes = hSV.find(':') != ts::string_view::npos;
+ bool needsDoubleQuotes = hSV.find(':') != std::string_view::npos;
if (hdr.size()) {
hdr << ';';
@@ -1186,7 +1187,7 @@ HttpTransactHeaders::add_forwarded_field_to_request(HttpTransact::State *s, HTTP
// it's size is exactly the capacity of the buffer.
//
if (hdr.size() and !hdr.error() and (hdr.size() < hdr.capacity())) {
- ts::string_view sV = hdr.view();
+ std::string_view sV = hdr.view();
request->value_append(MIME_FIELD_FORWARDED, MIME_LEN_FORWARDED, sV.data(), sV.size(), true, ','); // true => separator must
// be inserted
diff --git a/proxy/http/HttpTransactHeaders.h b/proxy/http/HttpTransactHeaders.h
index 023490b..657340d 100644
--- a/proxy/http/HttpTransactHeaders.h
+++ b/proxy/http/HttpTransactHeaders.h
@@ -63,7 +63,7 @@ public:
enum class ProtocolStackDetail { Compact, Standard, Full };
- static int write_hdr_protocol_stack(char *hdr_string, size_t len, ProtocolStackDetail pSDetail, ts::string_view *proto_buf,
+ static int write_hdr_protocol_stack(char *hdr_string, size_t len, ProtocolStackDetail pSDetail, std::string_view *proto_buf,
int n_proto, char separator = ' ');
// Removing handle_conditional_headers. Functionality appears to be elsewhere (issue_revalidate)
diff --git a/proxy/http/unit-tests/test_ForwardedConfig.cc b/proxy/http/unit-tests/test_ForwardedConfig.cc
index 0069de4..7835648 100644
--- a/proxy/http/unit-tests/test_ForwardedConfig.cc
+++ b/proxy/http/unit-tests/test_ForwardedConfig.cc
@@ -89,7 +89,7 @@ public:
s += nextWs();
}
- operator ts::string_view() const { return ts::string_view(s.c_str()); }
+ operator std::string_view() const { return std::string_view(s.c_str()); }
};
void
diff --git a/proxy/http2/Http2ClientSession.h b/proxy/http2/Http2ClientSession.h
index fe05e52..4f69dc9 100644
--- a/proxy/http2/Http2ClientSession.h
+++ b/proxy/http2/Http2ClientSession.h
@@ -27,7 +27,7 @@
#include "Plugin.h"
#include "ProxyClientSession.h"
#include "Http2ConnectionState.h"
-#include <ts/string_view.h>
+#include <string_view>
#include <ts/ink_inet.h>
// Name Edata Description
@@ -260,7 +260,7 @@ public:
}
int
- populate_protocol(ts::string_view *result, int size) const override
+ populate_protocol(std::string_view *result, int size) const override
{
int retval = 0;
if (size > retval) {
@@ -273,7 +273,7 @@ public:
}
const char *
- protocol_contains(ts::string_view prefix) const override
+ protocol_contains(std::string_view prefix) const override
{
const char *retval = nullptr;
diff --git a/proxy/logging/LogHost.cc b/proxy/logging/LogHost.cc
index 40a940d..fbbc034 100644
--- a/proxy/logging/LogHost.cc
+++ b/proxy/logging/LogHost.cc
@@ -158,8 +158,8 @@ bool
LogHost::set_name_or_ipstr(const char *name_or_ip)
{
if (name_or_ip && name_or_ip[0] != '\0') {
- ts::string_view addr, port;
- if (ats_ip_parse(ts::string_view(name_or_ip), &addr, &port) == 0) {
+ std::string_view addr, port;
+ if (ats_ip_parse(std::string_view(name_or_ip), &addr, &port) == 0) {
uint16_t p = port.empty() ? Log::config->collation_port : atoi(port.data());
char *n = const_cast<char *>(addr.data());
// Force termination. We know we can do this because the address
--
To stop receiving notification emails like this one, please contact
bcall@apache.org.