mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
@@ -41,12 +41,10 @@ endfunction()
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
|
||||
|
||||
include(TestCXX11)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED true)
|
||||
include(TestCXX17)
|
||||
if(NOT CYGWIN)
|
||||
# We don't want to use -std=gnu++11 instead of -std=c++11, but among other
|
||||
# things, -std=c++11 on cygwin defines __STRICT_ANSI__ which makes cygwin
|
||||
# We don't want to use -std=gnu++17 instead of -std=c++17, but among other
|
||||
# things, -std=c++17 on cygwin defines __STRICT_ANSI__ which makes cygwin
|
||||
# not to compile: undefined references to strerror_r, to fdopen, to
|
||||
# strcasecmp, etc (their declarations in system headers are between ifdef)
|
||||
set(CMAKE_CXX_EXTENSIONS false)
|
||||
|
||||
1
NOTICE
1
NOTICE
@@ -16,7 +16,6 @@ ZNC includes code from jQuery UI (http://jqueryui.com/), licensed under the MIT
|
||||
ZNC includes code from Selectize (http://brianreavis.github.io/selectize.js/), licensed under the Apache License 2.0.
|
||||
ZNC includes modified code from CMakeFindFrameworks.cmake by Kitware, Inc., licensed under BSD License.
|
||||
ZNC includes modified code from TestLargeFiles.cmake, licensed under Boost Software License, Version 1.0.
|
||||
ZNC includes code from BackportCpp (https://github.com/bitwizeshift/string_view-standalone), licensed under the MIT license.
|
||||
ZNC includes code from cctz (https://github.com/google/cctz), licensed under the Apache License 2.0.
|
||||
|
||||
ZNC is developed by these people:
|
||||
|
||||
@@ -24,7 +24,7 @@ Core:
|
||||
|
||||
* GNU make
|
||||
* pkg-config
|
||||
* GCC 4.8 or clang 3.2
|
||||
* GCC 8 or clang 5
|
||||
* CMake
|
||||
|
||||
## Optional Requirements
|
||||
|
||||
@@ -14,26 +14,26 @@
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
if(NOT DEFINED cxx11check)
|
||||
message(STATUS "Checking for C++11 support")
|
||||
get_filename_component(_CXX11Check_dir "${CMAKE_CURRENT_LIST_FILE}"
|
||||
if(NOT DEFINED cxx17check)
|
||||
message(STATUS "Checking for C++17 support")
|
||||
get_filename_component(_CXX17Check_dir "${CMAKE_CURRENT_LIST_FILE}"
|
||||
DIRECTORY)
|
||||
try_compile(cxx11_supported
|
||||
"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/cxx11check"
|
||||
"${_CXX11Check_dir}/cxx11check" cxx11check
|
||||
OUTPUT_VARIABLE _CXX11Check_tryout)
|
||||
if(cxx11_supported)
|
||||
message(STATUS "Checking for C++11 support - supported")
|
||||
SET(cxx11check 1 CACHE INTERNAL "C++11 support")
|
||||
try_compile(cxx17_supported
|
||||
"${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/cxx17check"
|
||||
"${_CXX17Check_dir}/cxx17check" cxx17check
|
||||
OUTPUT_VARIABLE _CXX17Check_tryout)
|
||||
if(cxx17_supported)
|
||||
message(STATUS "Checking for C++17 support - supported")
|
||||
SET(cxx17check 1 CACHE INTERNAL "C++17 support")
|
||||
file(APPEND
|
||||
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log"
|
||||
"Output of C++11 check:\n${_CXX11Check_tryout}\n")
|
||||
"Output of C++17 check:\n${_CXX17Check_tryout}\n")
|
||||
else()
|
||||
file(APPEND
|
||||
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log"
|
||||
"Error in C++11 check:\n${_CXX11Check_tryout}\n")
|
||||
message(STATUS "Checking for C++11 support - not supported")
|
||||
"Error in C++17 check:\n${_CXX17Check_tryout}\n")
|
||||
message(STATUS "Checking for C++17 support - not supported")
|
||||
message(FATAL_ERROR " Upgrade your compiler.\n"
|
||||
" GCC 4.8+ and Clang 3.2+ are known to work.")
|
||||
" GCC 8+ and Clang 5+ should work.")
|
||||
endif()
|
||||
endif()
|
||||
@@ -18,6 +18,6 @@ cmake_minimum_required(VERSION 3.13)
|
||||
project(cxx11check LANGUAGES CXX)
|
||||
set(CMAKE_VERBOSE_MAKEFILE true)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED true)
|
||||
add_executable(main main.cpp)
|
||||
@@ -11,6 +11,7 @@
|
||||
// warranty.
|
||||
|
||||
#include <map>
|
||||
#include <string_view>
|
||||
|
||||
template <typename T>
|
||||
struct check {
|
||||
@@ -59,5 +60,6 @@ void test() { func<foo>(0); }
|
||||
int main() {
|
||||
std::map<int, int> m;
|
||||
m.emplace(2, 4);
|
||||
auto [x, y] = *m.begin();
|
||||
return 0;
|
||||
}
|
||||
@@ -17,19 +17,6 @@
|
||||
#ifndef ZNC_MESSAGE_H
|
||||
#define ZNC_MESSAGE_H
|
||||
|
||||
// Remove this after Feb 2016 when Debian 7 is EOL
|
||||
#if __cpp_ref_qualifiers >= 200710
|
||||
#define ZNC_LVREFQUAL &
|
||||
#elif defined(__clang__)
|
||||
#define ZNC_LVREFQUAL &
|
||||
#elif __GNUC__ > 4 || \
|
||||
__GNUC__ == 4 && (__GNUC_MINOR__ > 8 || \
|
||||
__GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ >= 1)
|
||||
#define ZNC_LVREFQUAL &
|
||||
#else
|
||||
#define ZNC_LVREFQUAL
|
||||
#endif
|
||||
|
||||
#ifdef SWIG
|
||||
#define ZNC_MSG_DEPRECATED(msg)
|
||||
#else
|
||||
@@ -166,7 +153,7 @@ class CMessage {
|
||||
// Implicit and explicit conversion to a subclass reference.
|
||||
#ifndef SWIG
|
||||
template <typename M>
|
||||
M& As() ZNC_LVREFQUAL {
|
||||
M& As() & {
|
||||
static_assert(std::is_base_of<CMessage, M>{},
|
||||
"Must be subclass of CMessage");
|
||||
static_assert(sizeof(M) == sizeof(CMessage),
|
||||
@@ -175,7 +162,7 @@ class CMessage {
|
||||
}
|
||||
|
||||
template <typename M>
|
||||
const M& As() const ZNC_LVREFQUAL {
|
||||
const M& As() const& {
|
||||
static_assert(std::is_base_of<CMessage, M>{},
|
||||
"Must be subclass of CMessage");
|
||||
static_assert(sizeof(M) == sizeof(CMessage),
|
||||
@@ -185,12 +172,12 @@ class CMessage {
|
||||
|
||||
template <typename M, typename = typename std::enable_if<
|
||||
std::is_base_of<CMessage, M>{}>::type>
|
||||
operator M&() ZNC_LVREFQUAL {
|
||||
operator M&() & {
|
||||
return As<M>();
|
||||
}
|
||||
template <typename M, typename = typename std::enable_if<
|
||||
std::is_base_of<CMessage, M>{}>::type>
|
||||
operator const M&() const ZNC_LVREFQUAL {
|
||||
operator const M&() const& {
|
||||
return As<M>();
|
||||
}
|
||||
// REGISTER_ZNC_MESSAGE allows SWIG to instantiate correct .As<> calls.
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
|
||||
#include <znc/ZNCString.h>
|
||||
#include <unordered_map>
|
||||
#include <variant>
|
||||
|
||||
struct CTranslationInfo {
|
||||
static std::map<CString, CTranslationInfo> GetTranslations();
|
||||
@@ -83,20 +84,18 @@ class CDelayedTranslation {
|
||||
|
||||
class COptionalTranslation {
|
||||
public:
|
||||
COptionalTranslation(const CString& sText)
|
||||
: m_bTranslating(false), m_sText(sText) {}
|
||||
COptionalTranslation(const CString& sText) : m_text(sText) {}
|
||||
COptionalTranslation(const char* s) : COptionalTranslation(CString(s)) {}
|
||||
COptionalTranslation(const CDelayedTranslation& dTranslation)
|
||||
: m_bTranslating(true), m_dTranslation(dTranslation) {}
|
||||
COptionalTranslation(const CDelayedTranslation& dTranslation) : m_text(dTranslation) {}
|
||||
CString Resolve() const {
|
||||
return m_bTranslating ? m_dTranslation.Resolve() : m_sText;
|
||||
if (m_text.index() == 0) {
|
||||
return std::get<0>(m_text);
|
||||
}
|
||||
return std::get<1>(m_text).Resolve();
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_bTranslating;
|
||||
// TODO switch to std::variant<CString, CDelayedTranslation> after C++17
|
||||
CString m_sText;
|
||||
CDelayedTranslation m_dTranslation;
|
||||
std::variant<CString, CDelayedTranslation> m_text;
|
||||
};
|
||||
|
||||
// Used by everything except modules.
|
||||
|
||||
@@ -56,7 +56,6 @@ add_custom_target(version
|
||||
add_dependencies(znclib copy_csocket_h copy_csocket_cc version)
|
||||
|
||||
set(znc_include_dirs
|
||||
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third_party/bpstd>"
|
||||
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
|
||||
"$<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>"
|
||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_FULL_INCLUDEDIR}>")
|
||||
@@ -87,16 +86,11 @@ set_target_properties(znclib PROPERTIES
|
||||
OUTPUT_NAME "znc"
|
||||
SOVERSION "${ZNC_VERSION}")
|
||||
|
||||
# CMake started supporting metafeature cxx_std_11 only in 3.8
|
||||
set(required_cxx11_features
|
||||
cxx_range_for cxx_nullptr cxx_override
|
||||
cxx_lambdas cxx_auto_type)
|
||||
target_compile_features(znc PUBLIC ${required_cxx11_features})
|
||||
target_compile_features(znclib PUBLIC ${required_cxx11_features})
|
||||
|
||||
add_library(ZNC INTERFACE)
|
||||
target_link_libraries(ZNC INTERFACE ${znc_link} ${zncpubdeps})
|
||||
target_compile_definitions(ZNC INTERFACE "znc_export_lib_EXPORTS")
|
||||
target_compile_features(ZNC INTERFACE cxx_std_17)
|
||||
target_compile_features(znclib PUBLIC cxx_std_17)
|
||||
|
||||
if(HAVE_I18N)
|
||||
add_subdirectory(po)
|
||||
|
||||
@@ -14,9 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <string_view>
|
||||
|
||||
#include <znc/Message.h>
|
||||
#include <znc/Utils.h>
|
||||
#include "bpstd/string_view.hpp"
|
||||
|
||||
CMessage::CMessage(const CString& sMessage) {
|
||||
Parse(sMessage);
|
||||
@@ -165,7 +166,7 @@ void CMessage::Parse(const CString& sMessage) {
|
||||
// Find the end of the first word
|
||||
const char* p = begin;
|
||||
while (p < end && *p != ' ') ++p;
|
||||
bpstd::string_view result(begin, p - begin);
|
||||
std::string_view result(begin, p - begin);
|
||||
begin = p;
|
||||
// Prepare for the following word
|
||||
while (begin < end && *begin == ' ') ++begin;
|
||||
@@ -175,12 +176,12 @@ void CMessage::Parse(const CString& sMessage) {
|
||||
// <tags>
|
||||
m_mssTags.clear();
|
||||
if (begin < end && *begin == '@') {
|
||||
bpstd::string_view svTags = next_word().substr(1);
|
||||
std::vector<bpstd::string_view> vsTags;
|
||||
std::string_view svTags = next_word().substr(1);
|
||||
std::vector<std::string_view> vsTags;
|
||||
// Split by ';'
|
||||
while (true) {
|
||||
auto delim = svTags.find_first_of(';');
|
||||
if (delim == bpstd::string_view::npos) {
|
||||
if (delim == std::string_view::npos) {
|
||||
vsTags.push_back(svTags);
|
||||
break;
|
||||
}
|
||||
@@ -188,10 +189,10 @@ void CMessage::Parse(const CString& sMessage) {
|
||||
svTags = svTags.substr(delim + 1);
|
||||
}
|
||||
// Save key and value
|
||||
for (bpstd::string_view svTag : vsTags) {
|
||||
for (std::string_view svTag : vsTags) {
|
||||
auto delim = svTag.find_first_of('=');
|
||||
CString sKey = std::string(delim == bpstd::string_view::npos ? svTag : svTag.substr(0, delim));
|
||||
CString sValue = delim == bpstd::string_view::npos ? std::string() : std::string(svTag.substr(delim + 1));
|
||||
CString sKey = std::string(delim == std::string_view::npos ? svTag : svTag.substr(0, delim));
|
||||
CString sValue = delim == std::string_view::npos ? std::string() : std::string(svTag.substr(delim + 1));
|
||||
m_mssTags[sKey] =
|
||||
sValue.Escape(CString::EMSGTAG, CString::CString::EASCII);
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
project(ZNCIntegrationTest LANGUAGES CXX)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED true)
|
||||
|
||||
set(CMAKE_THREAD_PREFER_PTHREAD true)
|
||||
|
||||
1424
third_party/bpstd/bpstd/string_view.hpp
vendored
1424
third_party/bpstd/bpstd/string_view.hpp
vendored
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user