Skip to content

Commit

Permalink
Remove C++11 only code
Browse files Browse the repository at this point in the history
  • Loading branch information
rmisev committed Sep 26, 2024
1 parent 850adef commit ff9b6aa
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 265 deletions.
9 changes: 0 additions & 9 deletions include/upa/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,6 @@
# define UPA_NOEXCEPT_17
#endif

// Define UPA_CPP_14 if compiler supports C++14 or later
// Note: Visual Studio 2015 (14.0; _MSC_VER == 1900) lacks sufficient C++14 support
#if defined(_MSVC_LANG) ? (_MSVC_LANG >= 201402 && _MSC_VER > 1900) : (__cplusplus >= 201402)
# define UPA_CPP_14
# define UPA_CONSTEXPR_14 constexpr
#else
# define UPA_CONSTEXPR_14 inline
#endif

// Barrier for pointer anti-aliasing optimizations even across function boundaries.
// This is a slightly modified U_ALIASING_BARRIER macro from the char16ptr.h file
// of the ICU 75.1 library.
Expand Down
12 changes: 2 additions & 10 deletions include/upa/str_arg.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,19 @@ inline void procfn(Args&&... args) {
#ifndef UPA_STR_ARG_H
#define UPA_STR_ARG_H

#include "config.h"
#include "url_utf.h"
#include <cassert>
#include <cstddef>
#include <string>
#include <string_view>
#include <type_traits>
#include <utility>

#ifdef UPA_CPP_17
# include <string_view>
# define UPA_STRING_VIEW_TYPE std::string_view
#else
# include "str_view.h"
# define UPA_STRING_VIEW_TYPE upa::str_view<char>
#endif

namespace upa {

// String view type

using string_view = UPA_STRING_VIEW_TYPE;
using string_view = std::string_view;

// Supported char and size types

Expand Down
145 changes: 0 additions & 145 deletions include/upa/str_view.h

This file was deleted.

47 changes: 0 additions & 47 deletions include/upa/url_percent_encode.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ namespace upa {
///
class code_point_set {
public:
#ifdef UPA_CPP_17
/// @brief constructor for code point set initialization
///
/// Function @a fun must iniatialize @a self object by using code_point_set
Expand Down Expand Up @@ -82,7 +81,6 @@ class code_point_set {
for (auto c = from; c <= to; ++c)
include(c);
}
#endif

/// @brief test code point set contains code point @a c
/// @param[in] c code point to test
Expand All @@ -92,12 +90,6 @@ class code_point_set {
return is_8bit(uc) && (arr_[uc >> 3] & (1u << (uc & 0x07))) != 0;
}

#ifdef UPA_CPP_17
// for dump program
static constexpr std::size_t arr_size() noexcept { return arr_size_; }
constexpr uint8_t arr_val(std::size_t i) const { return arr_[i]; }
#endif

private:
// Check code point value is 8 bit (<=0xFF)
static constexpr bool is_8bit(unsigned char) noexcept {
Expand All @@ -111,19 +103,12 @@ class code_point_set {

// Data
static const std::size_t arr_size_ = 32;
#ifdef UPA_CPP_17
uint8_t arr_[arr_size_] = {};
#else
public:
uint8_t arr_[arr_size_];
#endif
};


// Percent encode sets

#ifdef UPA_CPP_17

// If you edit following data, then please compile tools/dumpCharBitSets.cpp program
// with C++17 compiler, run it and copy output to the url_percent_encode.cpp file.
// This is required to support C++11, C++14 compilers.
Expand Down Expand Up @@ -185,21 +170,6 @@ inline constexpr code_point_set component_no_encode_set{ [](code_point_set& self
} };


#else

// For C++11, C++14

extern const code_point_set fragment_no_encode_set;
extern const code_point_set query_no_encode_set;
extern const code_point_set special_query_no_encode_set;
extern const code_point_set path_no_encode_set;
extern const code_point_set raw_path_no_encode_set;
extern const code_point_set posix_path_no_encode_set;
extern const code_point_set userinfo_no_encode_set;
extern const code_point_set component_no_encode_set;

#endif

namespace detail {

// Code point sets in one bytes array
Expand All @@ -215,7 +185,6 @@ enum CP_SET : std::uint8_t {

class code_points_multiset {
public:
#ifdef UPA_CPP_17
constexpr code_points_multiset() {
// Forbidden host code points: U+0000 NULL, U+0009 TAB, U+000A LF, U+000D CR,
// U+0020 SPACE, U+0023 (#), U+002F (/), U+003A (:), U+003C (<), U+003E (>),
Expand Down Expand Up @@ -260,11 +229,6 @@ class code_points_multiset {
include(SCHEME_SET, { 0x2B, 0x2D, 0x2E });
}

// for dump program
static constexpr std::size_t arr_size() noexcept { return arr_size_; }
constexpr uint8_t arr_val(std::size_t i) const { return arr_[i]; }
#endif

/// @brief test the @a cps code points set contains code point @a c
/// @param[in] c code point to test
/// @param[in] cps code point set
Expand All @@ -275,7 +239,6 @@ class code_points_multiset {
}

private:
#ifdef UPA_CPP_17
/// @brief include @a c code point to @a cpsbits sets
/// @param[in] cpsbits code points sets
/// @param[in] c code point to include
Expand Down Expand Up @@ -313,7 +276,6 @@ class code_points_multiset {
for (auto c : clist)
exclude(cpsbits, c);
}
#endif

// Check code point value is 8 bit (<=0xFF)
static constexpr bool is_8bit(unsigned char) noexcept {
Expand All @@ -327,19 +289,10 @@ class code_points_multiset {

// Data
static const std::size_t arr_size_ = 256;
#ifdef UPA_CPP_17
uint8_t arr_[arr_size_] = {};
#else
public:
uint8_t arr_[arr_size_];
#endif
};

#ifdef UPA_CPP_17
inline constexpr code_points_multiset code_points;
#else
extern const code_points_multiset code_points;
#endif

// ----------------------------------------------------------------------------
// Check char is in predefined set
Expand Down
5 changes: 1 addition & 4 deletions include/upa/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,9 @@ inline void append_tr(std::string& dest, const CharT* first, const CharT* last,
std::transform(first, last, buff + old_size, unary_op);
return new_size;
});
#elif defined(UPA_CPP_17)
#else
dest.resize(new_size);
std::transform(first, last, dest.data() + old_size, unary_op);
#else
dest.reserve(new_size);
std::transform(first, last, std::back_inserter(dest), unary_op);
#endif
}

Expand Down
44 changes: 0 additions & 44 deletions src/url_percent_encode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,50 +10,6 @@
#include "upa/url_percent_encode.h"

namespace upa { // NOLINT(modernize-concat-nested-namespaces)

#ifndef UPA_CPP_17

// These data were generated by tools/dumpCharBitSets.cpp program.
const code_point_set fragment_no_encode_set = {
0x00, 0x00, 0x00, 0x00, 0xfa, 0xff, 0xff, 0xaf, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0x7f
};
const code_point_set query_no_encode_set = {
0x00, 0x00, 0x00, 0x00, 0xf2, 0xff, 0xff, 0xaf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f
};
const code_point_set special_query_no_encode_set = {
0x00, 0x00, 0x00, 0x00, 0x72, 0xff, 0xff, 0xaf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f
};
const code_point_set path_no_encode_set = {
0x00, 0x00, 0x00, 0x00, 0xf2, 0xff, 0xff, 0x2f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0x57
};
const code_point_set raw_path_no_encode_set = {
0x00, 0x00, 0x00, 0x00, 0xd2, 0xff, 0xff, 0x2f, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0x57
};
const code_point_set posix_path_no_encode_set = {
0x00, 0x00, 0x00, 0x00, 0xd2, 0xff, 0xff, 0x2b, 0xff, 0xff, 0xff, 0xef, 0xfe, 0xff, 0xff, 0x47
};
const code_point_set userinfo_no_encode_set = {
0x00, 0x00, 0x00, 0x00, 0xf2, 0x7f, 0xff, 0x03, 0xfe, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x47
};
const code_point_set component_no_encode_set = {
0x00, 0x00, 0x00, 0x00, 0x82, 0x67, 0xff, 0x03, 0xfe, 0xff, 0xff, 0x87, 0xfe, 0xff, 0xff, 0x47
};

namespace detail {
const code_points_multiset code_points = {
0x06, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x06, 0x06, 0x02, 0x02, 0x06, 0x02, 0x02,
0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
0x06, 0x01, 0x01, 0x06, 0x01, 0x02, 0x01, 0x01, 0x01, 0x01, 0x01, 0x21, 0x01, 0x21, 0x31, 0x06,
0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x06, 0x01, 0x06, 0x01, 0x06, 0x06,
0x06, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21,
0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x31, 0x21, 0x21, 0x06, 0x06, 0x06, 0x06, 0x01,
0x01, 0x39, 0x39, 0x39, 0x39, 0x39, 0x39, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21,
0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x21, 0x31, 0x21, 0x21, 0x01, 0x06, 0x01, 0x01, 0x02
};
} // namespace detail

#endif

namespace detail {

// Maps hex numerical values to ASCII digits
Expand Down
6 changes: 0 additions & 6 deletions test/test-utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,7 @@ inline bool param_eq(const std::string* pval, const T& value) {

template <class List, class T>
inline bool list_eq(const List& val, std::initializer_list<T> lst) {
#ifdef UPA_CPP_14
return std::equal(std::begin(val), std::end(val), std::begin(lst), std::end(lst));
#else
return
val.size() == lst.size() &&
std::equal(std::begin(val), std::end(val), std::begin(lst));
#endif
}

template <class T>
Expand Down

0 comments on commit ff9b6aa

Please sign in to comment.