Skip to content

Commit 7d05fc4

Browse files
libswoc - replace string_view_util with libswoc version.
1 parent a270bcd commit 7d05fc4

12 files changed

Lines changed: 46 additions & 72 deletions

File tree

include/tscpp/util/Makefile.am

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,5 @@ library_include_HEADERS = \
2323
LocalBuffer.h \
2424
PostScript.h \
2525
Strerror.h \
26-
string_view_util.h \
2726
TextView.h \
2827
TsSharedMutex.h

include/tscpp/util/TextView.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
#include <string_view>
3535
#include <limits>
3636

37-
#include "tscpp/util/string_view_util.h"
37+
#include "swoc/string_view_util.h"
3838

3939
namespace ts
4040
{

lib/Makefile.am

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,9 @@ all-local:: swoc
4444

4545
clean-local::
4646
$(MAKE) -C swoc clean
47-
endif
4847

49-
if EXPORT_SWOC_HEADERS
5048
install-data-local::
5149
$(MAKE) -C swoc install
50+
5251
endif
5352

lib/swoc/Makefile.am

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,17 @@
1616
# See the License for the specific language governing permissions and
1717
# limitations under the License.
1818

19-
include $(top_srcdir)/build/tidy.mk
20-
21-
noinst_LTLIBRARIES = libtsswoc.la
19+
lib_LTLIBRARIES = libtsswoc.la
2220

2321
library_includedir=$(includedir)/swoc
2422

25-
AM_CPPFLAGS += -I$(abs_top_srcdir)/include -I$(abs_top_srcdir)/lib/swoc/include
26-
27-
libtsswoc_la_LDFLAGS = @AM_LDFLAGS@ -no-undefined -version-info @TS_LIBTOOL_VERSION@
23+
AM_CPPFLAGS += @SWOC_INCLUDES@
2824

25+
libtsswoc_la_LDFLAGS = @AM_LDFLAGS@ -no-undefined -release 1.4.0
2926
libtsswoc_la_SOURCES = \
30-
src/ArenaWriter.cc src/bw_format.cc src/bw_ip_format.cc src/Errata.cc src/MemArena.cc src/RBTree.cc src/swoc_file.cc src/swoc_ip.cc src/TextView.cc
27+
src/ArenaWriter.cc src/bw_format.cc src/bw_ip_format.cc src/Errata.cc src/MemArena.cc src/RBTree.cc src/swoc_file.cc src/swoc_ip.cc src/TextView.cc src/string_view_util.cc
3128

29+
if EXPORT_SWOC_HEADERS
3230
library_include_HEADERS = \
3331
include/swoc/ArenaWriter.h \
3432
include/swoc/BufferWriter.h \
@@ -41,22 +39,24 @@ library_include_HEADERS = \
4139
include/swoc/Errata.h \
4240
include/swoc/IntrusiveDList.h \
4341
include/swoc/IntrusiveHashMap.h \
42+
include/swoc/IPAddr.h \
43+
include/swoc/IPEndpoint.h \
44+
include/swoc/IPRange.h \
45+
include/swoc/IPSrv.h \
4446
include/swoc/Lexicon.h \
4547
include/swoc/MemArena.h \
4648
include/swoc/MemSpan.h \
4749
include/swoc/RBTree.h \
4850
include/swoc/Scalar.h \
4951
include/swoc/swoc_file.h \
50-
include/swoc/IPEndpoint.h \
51-
include/swoc/IPAddr.h \
52-
include/swoc/IPSrv.h \
53-
include/swoc/IPRange.h \
5452
include/swoc/swoc_ip.h \
5553
include/swoc/swoc_meta.h \
5654
include/swoc/swoc_version.h\
55+
include/swoc/string_view_util.h \
5756
include/swoc/TextView.h \
5857
include/swoc/Vectray.h \
5958
include/swoc/HashFNV.h
59+
endif
6060

6161
clean-local:
6262

lib/swoc/include/swoc/TextView.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
#include <limits>
2121

2222
#include "swoc/swoc_version.h"
23-
#include "tscpp/util/string_view_util.h"
23+
#include "swoc/string_view_util.h"
2424

2525
namespace swoc { inline namespace SWOC_VERSION_NS {
2626

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,17 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// Copyright Apache Software Foundation 2019
13
/** @file
24
3-
Utility overloads for @c std::string_view
4-
5-
@section license License
6-
7-
Licensed to the Apache Software Foundation (ASF) under one or more contributor license
8-
agreements. See the NOTICE file distributed with this work for additional information regarding
9-
copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0
10-
(the "License"); you may not use this file except in compliance with the License. You may obtain
11-
a copy of the License at
12-
13-
http://www.apache.org/licenses/LICENSE-2.0
14-
15-
Unless required by applicable law or agreed to in writing, software distributed under the License
16-
is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
17-
or implied. See the License for the specific language governing permissions and limitations under
18-
the License.
19-
*/
5+
Additional handy utilities for @c string_view and hence also @c TextView.
6+
*/
207

218
#pragma once
9+
#include <bitset>
10+
#include <iosfwd>
11+
#include <memory.h>
12+
#include <string>
2213
#include <string_view>
23-
#include <string.h>
24-
#include <strings.h>
14+
#include <limits>
2515

2616
/** Compare views with ordering, ignoring case.
2717
*
@@ -70,8 +60,7 @@ int memcmp(const std::string_view &lhs, const std::string_view &rhs);
7060
* @see memcmp
7161
*/
7262
inline int
73-
strcmp(const std::string_view &lhs, const std::string_view &rhs)
74-
{
63+
strcmp(const std::string_view &lhs, const std::string_view &rhs) {
7564
return memcmp(lhs, rhs);
7665
}
7766

@@ -93,7 +82,6 @@ strcmp(const std::string_view &lhs, const std::string_view &rhs)
9382
*
9483
*/
9584
inline void *
96-
memcpy(void *dst, const std::string_view &src)
97-
{
85+
memcpy(void *dst, const std::string_view &src) {
9886
return memcpy(dst, src.data(), src.size());
9987
}

lib/swoc/src/Errata.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ Errata::Severity Errata::FAILURE_SEVERITY(2);
4242
Errata::Severity Errata::FILTER_SEVERITY(0);
4343

4444
/// Default set of severity names.
45-
std::array<swoc::TextView, 4> Severity_Names{{"Info", "Warning", "Error"}};
45+
std::array<swoc::TextView, 3> Severity_Names{{"Info", "Warning", "Error"}};
4646

4747
swoc::MemSpan<TextView const> Errata::SEVERITY_NAMES{Severity_Names.data(), Severity_Names.size()};
4848

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,14 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
// Copyright Apache Software Foundation 2019
13
/** @file
24
3-
Utilities for @c std::string_view
4-
5-
@section license License
6-
7-
Licensed to the Apache Software Foundation (ASF) under one or more
8-
contributor license agreements. See the NOTICE file distributed with this
9-
work for additional information regarding copyright ownership. The ASF
10-
licenses this file to you under the Apache License, Version 2.0 (the
11-
"License"); you may not use this file except in compliance with the License.
12-
You may obtain a copy of the License at
13-
14-
http://www.apache.org/licenses/LICENSE-2.0
15-
16-
Unless required by applicable law or agreed to in writing, software
17-
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
18-
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
19-
License for the specific language governing permissions and limitations under
20-
the License.
5+
Additional handy utilities for @c string_view and hence also @c TextView.
216
*/
22-
#include "tscpp/util/string_view_util.h"
7+
8+
#include "swoc/string_view_util.h"
239

2410
int
25-
memcmp(std::string_view const &lhs, std::string_view const &rhs)
26-
{
11+
memcmp(std::string_view const &lhs, std::string_view const &rhs) {
2712
int zret = 0;
2813
size_t n = rhs.size();
2914

@@ -42,8 +27,7 @@ memcmp(std::string_view const &lhs, std::string_view const &rhs)
4227
}
4328

4429
int
45-
strcasecmp(const std::string_view &lhs, const std::string_view &rhs)
46-
{
30+
strcasecmp(const std::string_view &lhs, const std::string_view &rhs) {
4731
int zret = 0;
4832
size_t n = rhs.size();
4933

proxy/http/remap/Makefile.am

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ test_NextHopStrategyFactory_LDADD = \
142142
$(top_builddir)/mgmt/libmgmt_p.la \
143143
$(top_builddir)/iocore/utils/libinkutils.a \
144144
$(top_builddir)/src/tscpp/util/libtscpputil.la \
145+
@SWOC_LIBS@ \
145146
@YAMLCPP_LIBS@ \
146147
@HWLOC_LIBS@
147148

@@ -173,6 +174,7 @@ test_NextHopRoundRobin_LDADD = \
173174
$(top_builddir)/mgmt/libmgmt_p.la \
174175
$(top_builddir)/iocore/utils/libinkutils.a \
175176
$(top_builddir)/src/tscpp/util/libtscpputil.la \
177+
@SWOC_LIBS@ \
176178
@YAMLCPP_LIBS@ \
177179
@HWLOC_LIBS@
178180

@@ -204,6 +206,7 @@ test_NextHopConsistentHash_LDADD = \
204206
$(top_builddir)/mgmt/libmgmt_p.la \
205207
$(top_builddir)/iocore/utils/libinkutils.a \
206208
$(top_builddir)/src/tscpp/util/libtscpputil.la \
209+
@SWOC_LIBS@ \
207210
@YAMLCPP_LIBS@ \
208211
@HWLOC_LIBS@
209212

proxy/http2/Makefile.am

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ test_libhttp2_SOURCES = \
100100

101101
test_Http2DependencyTree_LDADD = \
102102
$(top_builddir)/src/tscore/libtscore.la \
103-
$(top_builddir)/src/tscpp/util/libtscpputil.la
103+
$(top_builddir)/src/tscpp/util/libtscpputil.la \
104+
@SWOC_LIBS@
104105

105106
test_Http2DependencyTree_CPPFLAGS = $(AM_CPPFLAGS)\
106107
-I$(abs_top_srcdir)/tests/include
@@ -112,7 +113,8 @@ test_Http2DependencyTree_SOURCES = \
112113
test_Http2FrequencyCounter_LDADD = \
113114
$(top_builddir)/iocore/eventsystem/libinkevent.a \
114115
$(top_builddir)/src/tscore/libtscore.la \
115-
$(top_builddir)/src/tscpp/util/libtscpputil.la
116+
$(top_builddir)/src/tscpp/util/libtscpputil.la \
117+
@SWOC_LIBS@
116118

117119
test_Http2FrequencyCounter_CPPFLAGS = $(AM_CPPFLAGS)\
118120
-I$(abs_top_srcdir)/tests/include
@@ -130,7 +132,7 @@ test_HPACK_LDADD = \
130132
$(top_builddir)/src/records/librecords_p.a \
131133
$(top_builddir)/mgmt/libmgmt_p.la \
132134
$(top_builddir)/proxy/shared/libUglyLogStubs.a \
133-
@HWLOC_LIBS@
135+
@SWOC_LIBS@ @HWLOC_LIBS@
134136

135137
test_HPACK_SOURCES = \
136138
test_HPACK.cc \

0 commit comments

Comments
 (0)