Remove deprecated class binary and string_view operators. Move string_view into its own files. Update version to 0.2.0.
This commit is contained in:
parent
e5cf445f19
commit
3fc89111ea
@ -2,9 +2,9 @@ project(librexy)
|
|||||||
cmake_minimum_required(VERSION 3.0.2)
|
cmake_minimum_required(VERSION 3.0.2)
|
||||||
include(GNUInstallDirs)
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
set(librexy_VERSION_STRING "000010000L")
|
set(librexy_VERSION_STRING "000020000L")
|
||||||
set(librexy_VERSION_MAJOR 0)
|
set(librexy_VERSION_MAJOR 0)
|
||||||
set(librexy_VERSION_MINOR 1)
|
set(librexy_VERSION_MINOR 2)
|
||||||
set(librexy_VERSION_REVISION 0)
|
set(librexy_VERSION_REVISION 0)
|
||||||
set(INCLUDE_PATH ${CMAKE_SOURCE_DIR}/include)
|
set(INCLUDE_PATH ${CMAKE_SOURCE_DIR}/include)
|
||||||
include_directories(BEFORE SYSTEM "${INCLUDE_PATH}")
|
include_directories(BEFORE SYSTEM "${INCLUDE_PATH}")
|
||||||
@ -15,7 +15,7 @@ option(ENABLE_PROFILING "Enable asan" OFF)
|
|||||||
option(BUILD_TESTS "Enable testing" OFF)
|
option(BUILD_TESTS "Enable testing" OFF)
|
||||||
mark_as_advanced(ENABLE_PROFILING)
|
mark_as_advanced(ENABLE_PROFILING)
|
||||||
|
|
||||||
set(SOURCE_LIST "src/filerd.cpp" "src/string.cpp" "src/binary.cpp" "src/static_string.cpp" "src/threadpool.cpp" "src/demangle.cpp")
|
set(SOURCE_LIST "src/filerd.cpp" "src/string.cpp" "src/string_view.cpp" "src/threadpool.cpp" "src/demangle.cpp")
|
||||||
add_library(ensure OBJECT "src/ensure.cpp")
|
add_library(ensure OBJECT "src/ensure.cpp")
|
||||||
target_compile_options(ensure PRIVATE -Wall -Wextra -pedantic -std=c++20)
|
target_compile_options(ensure PRIVATE -Wall -Wextra -pedantic -std=c++20)
|
||||||
if(ENABLE_SHARED)
|
if(ENABLE_SHARED)
|
||||||
@ -39,7 +39,7 @@ if(BUILD_TESTS)
|
|||||||
add_subdirectory(tests)
|
add_subdirectory(tests)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(LIBREXY_PUBLIC_HEADERS "include/rexy/rexy.hpp" "include/rexy/algorithm.hpp" "include/rexy/utility.hpp" "include/rexy/basic_string_hash.hpp" "include/rexy/hash.hpp" "include/rexy/static_string_hash.hpp" "include/rexy/string_hash.hpp" "include/rexy/mpmc_queue.hpp" "include/rexy/mpmc_queue.tpp" "include/rexy/traits.hpp" "include/rexy/steal.hpp" "include/rexy/binary.hpp" "include/rexy/expression.hpp" "include/rexy/binary_base.hpp" "include/rexy/binary_base.tpp" "include/rexy/string_base.hpp" "include/rexy/string.hpp" "include/rexy/filerd.hpp" "include/rexy/string_base.tpp" "include/rexy/allocator.hpp" "include/rexy/meta.hpp" "include/rexy/buffer.hpp" "include/rexy/buffer.tpp" "include/rexy/debug_print.hpp" "include/rexy/deferred.hpp" "include/rexy/demangle.hpp" "include/rexy/enum_traits.hpp" "include/rexy/storage_for.hpp" "include/rexy/storage_for.tpp" "include/rexy/visitor.hpp")
|
set(LIBREXY_PUBLIC_HEADERS "include/rexy/rexy.hpp" "include/rexy/algorithm.hpp" "include/rexy/utility.hpp" "include/rexy/basic_string_hash.hpp" "include/rexy/hash.hpp" "include/rexy/string_view_hash.hpp" "include/rexy/string_hash.hpp" "include/rexy/mpmc_queue.hpp" "include/rexy/mpmc_queue.tpp" "include/rexy/traits.hpp" "include/rexy/steal.hpp" "include/rexy/expression.hpp" "include/rexy/string_base.hpp" "include/rexy/string.hpp" "include/rexy/filerd.hpp" "include/rexy/string_base.tpp" "include/rexy/allocator.hpp" "include/rexy/meta.hpp" "include/rexy/buffer.hpp" "include/rexy/buffer.tpp" "include/rexy/debug_print.hpp" "include/rexy/deferred.hpp" "include/rexy/demangle.hpp" "include/rexy/enum_traits.hpp" "include/rexy/storage_for.hpp" "include/rexy/storage_for.tpp" "include/rexy/visitor.hpp" "include/rexy/string_view.hpp" "include/rexy/string_view.tpp")
|
||||||
target_compile_options(rexy PRIVATE -Wall -Wextra -pedantic -std=c++20)
|
target_compile_options(rexy PRIVATE -Wall -Wextra -pedantic -std=c++20)
|
||||||
|
|
||||||
install(TARGETS rexy
|
install(TARGETS rexy
|
||||||
|
|||||||
@ -1,257 +0,0 @@
|
|||||||
/**
|
|
||||||
This file is a part of rexy's general purpose library
|
|
||||||
Copyright (C) 2020 rexy712
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef REXY_BINARY_BASE_HPP
|
|
||||||
#define REXY_BINARY_BASE_HPP
|
|
||||||
|
|
||||||
#include <cstdlib> //size_t
|
|
||||||
#include <utility> //move
|
|
||||||
#include <cstring> //memcpy
|
|
||||||
#include <cstddef> //ptrdiff_t
|
|
||||||
#include <type_traits>
|
|
||||||
#include <iterator> //reverse_iterator
|
|
||||||
|
|
||||||
#include "utility.hpp" //max
|
|
||||||
#include "steal.hpp"
|
|
||||||
#include "expression.hpp"
|
|
||||||
#include "traits.hpp"
|
|
||||||
#include "detail/string_appender.hpp"
|
|
||||||
#include "detail/hasallocator.hpp"
|
|
||||||
#include "rexy.hpp"
|
|
||||||
|
|
||||||
namespace rexy{
|
|
||||||
|
|
||||||
class binary_base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
using value_type = char;
|
|
||||||
using size_type = size_t;
|
|
||||||
using difference_type = ptrdiff_t;
|
|
||||||
using pointer = value_type*;
|
|
||||||
using const_pointer = const value_type*;
|
|
||||||
using reference = value_type&;
|
|
||||||
using const_reference = const value_type&;
|
|
||||||
using iterator = pointer;
|
|
||||||
using const_iterator = const_pointer;
|
|
||||||
using reverse_iterator = std::reverse_iterator<iterator>;
|
|
||||||
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
|
||||||
|
|
||||||
protected:
|
|
||||||
pointer m_data = nullptr;
|
|
||||||
size_type m_size = 0;
|
|
||||||
size_type m_cap = 0;
|
|
||||||
protected:
|
|
||||||
constexpr binary_base(void)noexcept = default;
|
|
||||||
constexpr binary_base(size_type len)noexcept;
|
|
||||||
constexpr binary_base(pointer data, size_type size)noexcept;
|
|
||||||
constexpr binary_base(pointer data, size_type size, size_type cap)noexcept;
|
|
||||||
constexpr binary_base(const binary_base& b)noexcept;
|
|
||||||
~binary_base(void)noexcept = default;
|
|
||||||
|
|
||||||
public:
|
|
||||||
constexpr pointer release(void)noexcept;
|
|
||||||
|
|
||||||
constexpr size_type size(void)const;
|
|
||||||
constexpr size_type capacity(void)const;
|
|
||||||
constexpr pointer get(void);
|
|
||||||
constexpr const_pointer get(void)const;
|
|
||||||
constexpr operator bool(void)const;
|
|
||||||
|
|
||||||
constexpr reference operator[](size_type i)noexcept;
|
|
||||||
constexpr const_reference operator[](size_type i)const noexcept;
|
|
||||||
|
|
||||||
constexpr iterator begin(void);
|
|
||||||
constexpr const_iterator begin(void)const;
|
|
||||||
constexpr iterator end(void);
|
|
||||||
constexpr const_iterator end(void)const;
|
|
||||||
constexpr const_iterator cbegin(void)const;
|
|
||||||
constexpr const_iterator cend(void)const;
|
|
||||||
|
|
||||||
constexpr reverse_iterator rbegin(void);
|
|
||||||
constexpr const_reverse_iterator rbegin(void)const;
|
|
||||||
constexpr reverse_iterator rend(void);
|
|
||||||
constexpr const_reverse_iterator rend(void)const;
|
|
||||||
constexpr const_reverse_iterator crbegin(void)const;
|
|
||||||
constexpr const_reverse_iterator crend(void)const;
|
|
||||||
};
|
|
||||||
template<class Allocator>
|
|
||||||
class basic_binary : protected detail::hasallocator<Allocator>, public binary_base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
using allocator_type = Allocator;
|
|
||||||
|
|
||||||
public:
|
|
||||||
constexpr basic_binary(void)noexcept;
|
|
||||||
constexpr basic_binary(rexy::steal<pointer> data, size_type size)noexcept;
|
|
||||||
constexpr basic_binary(rexy::steal<pointer> data, size_type cap, size_type size)noexcept;
|
|
||||||
constexpr basic_binary(rexy::steal<pointer> data)noexcept;
|
|
||||||
basic_binary(const_pointer data, size_type size)noexcept(noexcept(this->allocate(0)));
|
|
||||||
basic_binary(const_pointer data)noexcept(noexcept(this->allocate(0)));
|
|
||||||
basic_binary(const_pointer data, size_type size, size_type cap)noexcept(noexcept(this->allocate(0)));
|
|
||||||
explicit basic_binary(size_type size)noexcept(noexcept(this->allocate(0)));
|
|
||||||
basic_binary(size_type size, size_type cap)noexcept(noexcept(this->allocate(0)));
|
|
||||||
|
|
||||||
basic_binary(const basic_binary& b)noexcept(noexcept(this->allocate(0)));
|
|
||||||
constexpr basic_binary(basic_binary&& b)noexcept;
|
|
||||||
basic_binary(const binary_base& b)noexcept(noexcept(this->allocate(0)));
|
|
||||||
|
|
||||||
~basic_binary(void)noexcept(noexcept(this->deallocate(nullptr,0)));
|
|
||||||
|
|
||||||
basic_binary& operator=(const basic_binary& b)noexcept(noexcept(this->allocate(0)));
|
|
||||||
constexpr basic_binary& operator=(basic_binary&& b)noexcept;
|
|
||||||
basic_binary& operator=(const_pointer c)noexcept(noexcept(this->allocate(0)));
|
|
||||||
basic_binary& operator=(const binary_base& b)noexcept(noexcept(this->allocate(0)));
|
|
||||||
|
|
||||||
void reset(void)
|
|
||||||
noexcept(noexcept(this->deallocate(nullptr,0)));
|
|
||||||
void reset(pointer val, size_type cap, size_type size = 0)
|
|
||||||
noexcept(noexcept(this->deallocate(nullptr,0)));
|
|
||||||
bool resize(size_type newsize)
|
|
||||||
noexcept(noexcept(this->allocate(0)) &&
|
|
||||||
noexcept(this->deallocate(nullptr,0)));
|
|
||||||
void append(const_pointer data, size_type len)
|
|
||||||
noexcept(noexcept(this->allocate(0)) &&
|
|
||||||
noexcept(this->deallocate(nullptr,0)));
|
|
||||||
|
|
||||||
using detail::hasallocator<Allocator>::allocator;
|
|
||||||
|
|
||||||
private:
|
|
||||||
basic_binary& _copy_data(const_pointer data, size_type len)
|
|
||||||
noexcept(noexcept(this->allocate(0)) &&
|
|
||||||
noexcept(this->deallocate(nullptr,0)));
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class Left, class Right>
|
|
||||||
class binary_cat_expr : public rexy::binary_expression<Left,Right>
|
|
||||||
{
|
|
||||||
private:
|
|
||||||
using left_t = std::decay_t<Left>;
|
|
||||||
using right_t = std::decay_t<Right>;
|
|
||||||
static_assert(std::is_same<typename left_t::value_type,typename right_t::value_type>::value);
|
|
||||||
public:
|
|
||||||
using value_type = typename left_t::value_type;
|
|
||||||
using size_type = decltype(typename left_t::size_type{0} + typename right_t::size_type{0});
|
|
||||||
using difference_type = decltype(typename left_t::difference_type{0} - typename right_t::difference_type{0});
|
|
||||||
using pointer = value_type*;
|
|
||||||
using const_pointer = const value_type*;
|
|
||||||
using reference = value_type&;
|
|
||||||
using const_reference = const value_type&;
|
|
||||||
using iterator = pointer;
|
|
||||||
using const_iterator = const_pointer;
|
|
||||||
|
|
||||||
public:
|
|
||||||
using binary_expression<Left,Right>::binary_expression;
|
|
||||||
|
|
||||||
constexpr binary_cat_expr(const binary_cat_expr&) = default;
|
|
||||||
constexpr binary_cat_expr(binary_cat_expr&&) = default;
|
|
||||||
|
|
||||||
constexpr size_type size(void)const noexcept;
|
|
||||||
|
|
||||||
template<class Alloc>
|
|
||||||
operator basic_binary<Alloc>(void)
|
|
||||||
noexcept(std::is_nothrow_constructible<basic_binary<Alloc>, typename basic_binary<Alloc>::size_type>::value &&
|
|
||||||
std::is_nothrow_invocable<detail::string_appender<basic_binary<Alloc>>,decltype(*this)>::value);
|
|
||||||
};
|
|
||||||
|
|
||||||
class static_binary : public binary_base
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
constexpr static_binary(void)noexcept = default;
|
|
||||||
constexpr static_binary(const_pointer str, size_type len)noexcept;
|
|
||||||
constexpr static_binary(const_pointer str)noexcept;
|
|
||||||
constexpr static_binary(const static_binary&)noexcept;
|
|
||||||
constexpr static_binary(static_binary&&)noexcept;
|
|
||||||
~static_binary(void)noexcept = default;
|
|
||||||
|
|
||||||
constexpr static_binary& operator=(const_pointer str)noexcept;
|
|
||||||
constexpr static_binary& operator=(const static_binary& str)noexcept;
|
|
||||||
constexpr static_binary& operator=(static_binary&& str)noexcept;
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class Left, class Right>
|
|
||||||
binary_cat_expr(Left&&, Right&&) -> binary_cat_expr<Left&&,Right&&>;
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
struct is_binary{
|
|
||||||
static constexpr bool value = rexy::is_type<T,binary_base>::value || rexy::is_template_type<T,binary_cat_expr>::value;
|
|
||||||
};
|
|
||||||
template<class T>
|
|
||||||
struct is_concrete_binary{
|
|
||||||
static constexpr bool value = rexy::is_type<T,binary_base>::value;
|
|
||||||
};
|
|
||||||
namespace detail{
|
|
||||||
template<class... Ts>
|
|
||||||
using enable_if_binary = std::enable_if_t<(is_binary<Ts>::value && ...),int>;
|
|
||||||
template<class... Ts>
|
|
||||||
using enable_if_concrete_binary = std::enable_if_t<(is_concrete_binary<Ts>::value && ...),int>;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Left, class Right, detail::enable_if_concrete_binary<Left,Right> = 0>
|
|
||||||
bool operator==(Left&& l, Right&& r)noexcept{
|
|
||||||
return l && r && l.size() == r.size() && l.capacity() == r.capacity() && !memcmp(l.get(), r.get(), l.size());
|
|
||||||
}
|
|
||||||
template<class Left, class Right, detail::enable_if_concrete_binary<Left,Right> = 0>
|
|
||||||
bool operator!=(Left&& l, Right&& r)noexcept{
|
|
||||||
return !(std::forward<Left>(l) == std::forward<Right>(r));
|
|
||||||
}
|
|
||||||
template<class Left, class Right, detail::enable_if_binary<Left,Right> = 0>
|
|
||||||
auto operator+(Left&& l, Right&& r)
|
|
||||||
noexcept(noexcept(::new (nullptr) binary_cat_expr(std::forward<Left>(l), std::forward<Right>(r))))
|
|
||||||
{
|
|
||||||
return binary_cat_expr(std::forward<Left>(l), std::forward<Right>(r));
|
|
||||||
}
|
|
||||||
template<class Left, detail::enable_if_binary<Left> = 0>
|
|
||||||
auto operator+(Left&& l, const char* c)
|
|
||||||
noexcept(noexcept(::new (nullptr) binary_cat_expr(std::forward<Left>(l), rexy::static_binary(c))))
|
|
||||||
{
|
|
||||||
return binary_cat_expr(std::forward<Left>(l), rexy::static_binary(c));
|
|
||||||
}
|
|
||||||
template<class Right, detail::enable_if_binary<Right> = 0>
|
|
||||||
auto operator+(const char* c, Right&& r)
|
|
||||||
noexcept(noexcept(::new (nullptr) binary_cat_expr(rexy::static_binary(c), std::forward<Right>(r))))
|
|
||||||
{
|
|
||||||
return binary_cat_expr(rexy::static_binary(c), std::forward<Right>(r));
|
|
||||||
}
|
|
||||||
template<class Left, class Right, detail::enable_if_concrete_binary<Left> = 0, detail::enable_if_binary<Right> = 0>
|
|
||||||
decltype(auto) operator+=(Left& l, Right&& r)
|
|
||||||
noexcept(noexcept(l + std::forward<Right>(r)) && std::is_nothrow_assignable<Left,decltype(l + std::forward<Right>(r))>::value)
|
|
||||||
{
|
|
||||||
return l = (l + std::forward<Right>(r));
|
|
||||||
}
|
|
||||||
template<class Left, detail::enable_if_concrete_binary<Left> = 0>
|
|
||||||
decltype(auto) operator+=(Left& l, const char* c)
|
|
||||||
noexcept(noexcept(l + c) && std::is_nothrow_assignable<Left, decltype(l + c)>::value)
|
|
||||||
{
|
|
||||||
return l = (l + c);
|
|
||||||
}
|
|
||||||
} //namespace rexy
|
|
||||||
|
|
||||||
#include "binary_base.tpp"
|
|
||||||
|
|
||||||
namespace{
|
|
||||||
constexpr inline rexy::static_binary operator"" _sb(const char* str, size_t len)noexcept{
|
|
||||||
return rexy::static_binary(str, len);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef REXY_STRING_HPP
|
|
||||||
#include "detail/binary_string_conv.hpp"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -1,313 +0,0 @@
|
|||||||
/**
|
|
||||||
This file is a part of rexy's general purpose library
|
|
||||||
Copyright (C) 2020 rexy712
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef REXY_BINARY_BASE_TPP
|
|
||||||
#define REXY_BINARY_BASE_TPP
|
|
||||||
|
|
||||||
#include <cstdlib> //size_t
|
|
||||||
#include <utility> //move
|
|
||||||
#include <cstring> //memcpy
|
|
||||||
#include <type_traits>
|
|
||||||
#include "utility.hpp" //max
|
|
||||||
#include "steal.hpp"
|
|
||||||
#include "detail/string_appender.hpp"
|
|
||||||
|
|
||||||
#define STOP_STRICT_ALIAS_WARNING(x) (x)
|
|
||||||
|
|
||||||
namespace rexy{
|
|
||||||
|
|
||||||
constexpr binary_base::binary_base(size_type len)noexcept:
|
|
||||||
m_cap(len){}
|
|
||||||
constexpr binary_base::binary_base(pointer data, size_type size)noexcept:
|
|
||||||
m_data(data), m_cap(size){}
|
|
||||||
constexpr binary_base::binary_base(pointer data, size_type size, size_type cap)noexcept:
|
|
||||||
m_data(data), m_size(size), m_cap(cap){}
|
|
||||||
constexpr binary_base::binary_base(const binary_base&)noexcept{}
|
|
||||||
|
|
||||||
constexpr auto binary_base::release(void)noexcept -> pointer{
|
|
||||||
return exchange(m_data, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr auto binary_base::size(void)const -> size_type{
|
|
||||||
return m_size;
|
|
||||||
}
|
|
||||||
constexpr auto binary_base::capacity(void)const -> size_type{
|
|
||||||
return m_cap;
|
|
||||||
}
|
|
||||||
constexpr auto binary_base::get(void) -> pointer{
|
|
||||||
return m_data;
|
|
||||||
}
|
|
||||||
constexpr auto binary_base::get(void)const -> const_pointer{
|
|
||||||
return m_data;
|
|
||||||
}
|
|
||||||
constexpr binary_base::operator bool(void)const{
|
|
||||||
return m_data;
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr auto binary_base::operator[](size_type i)noexcept -> reference{
|
|
||||||
return m_data[i];
|
|
||||||
}
|
|
||||||
constexpr auto binary_base::operator[](size_type i)const noexcept -> const_reference{
|
|
||||||
return m_data[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr auto binary_base::begin(void) -> iterator{
|
|
||||||
return m_data;
|
|
||||||
}
|
|
||||||
constexpr auto binary_base::begin(void)const -> const_iterator{
|
|
||||||
return m_data;
|
|
||||||
}
|
|
||||||
constexpr auto binary_base::end(void) -> iterator{
|
|
||||||
return m_data + m_size;
|
|
||||||
}
|
|
||||||
constexpr auto binary_base::end(void)const -> const_iterator{
|
|
||||||
return m_data + m_size;
|
|
||||||
}
|
|
||||||
constexpr auto binary_base::cbegin(void)const -> const_iterator{
|
|
||||||
return m_data;
|
|
||||||
}
|
|
||||||
constexpr auto binary_base::cend(void)const -> const_iterator{
|
|
||||||
return m_data + m_size;
|
|
||||||
}
|
|
||||||
constexpr auto binary_base::rbegin(void) -> reverse_iterator{
|
|
||||||
return reverse_iterator(m_data + m_size);
|
|
||||||
}
|
|
||||||
constexpr auto binary_base::rbegin(void)const -> const_reverse_iterator{
|
|
||||||
return reverse_iterator(m_data + m_size);
|
|
||||||
}
|
|
||||||
constexpr auto binary_base::rend(void) -> reverse_iterator{
|
|
||||||
return reverse_iterator(m_data - 1);
|
|
||||||
}
|
|
||||||
constexpr auto binary_base::rend(void)const -> const_reverse_iterator{
|
|
||||||
return reverse_iterator(m_data - 1);
|
|
||||||
}
|
|
||||||
constexpr auto binary_base::crbegin(void)const -> const_reverse_iterator{
|
|
||||||
return rbegin();
|
|
||||||
}
|
|
||||||
constexpr auto binary_base::crend(void)const -> const_reverse_iterator{
|
|
||||||
return rend();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Allocator>
|
|
||||||
constexpr basic_binary<Allocator>::basic_binary(void)noexcept{}
|
|
||||||
template<class Allocator>
|
|
||||||
constexpr basic_binary<Allocator>::basic_binary(rexy::steal<pointer> data)noexcept:
|
|
||||||
binary_base(data.value() ? strlen(data.value()) : 0)
|
|
||||||
{
|
|
||||||
m_data = data.value();
|
|
||||||
m_size = m_cap;
|
|
||||||
}
|
|
||||||
template<class Allocator>
|
|
||||||
constexpr basic_binary<Allocator>::basic_binary(rexy::steal<pointer> data, size_type size)noexcept:
|
|
||||||
binary_base(data.value(), size){}
|
|
||||||
template<class Allocator>
|
|
||||||
constexpr basic_binary<Allocator>::basic_binary(rexy::steal<pointer> data, size_type cap, size_type size)noexcept:
|
|
||||||
binary_base(data.value(), cap, size){}
|
|
||||||
|
|
||||||
template<class Allocator>
|
|
||||||
basic_binary<Allocator>::basic_binary(const_pointer data, size_type size)
|
|
||||||
noexcept(noexcept(this->allocate(0))):
|
|
||||||
binary_base(size ? this->allocate(size) : nullptr, size)
|
|
||||||
{
|
|
||||||
if(size)
|
|
||||||
memcpy(m_data, data, size);
|
|
||||||
}
|
|
||||||
template<class Allocator>
|
|
||||||
basic_binary<Allocator>::basic_binary(const_pointer data)
|
|
||||||
noexcept(noexcept(this->allocate(0))):
|
|
||||||
basic_binary(data ? this->allocate(strlen(data)) : nullptr, strlen(data))
|
|
||||||
{
|
|
||||||
if(data)
|
|
||||||
memcpy(m_data, data, m_cap);
|
|
||||||
}
|
|
||||||
template<class Allocator>
|
|
||||||
basic_binary<Allocator>::basic_binary(const_pointer data, size_type size, size_type cap)
|
|
||||||
noexcept(noexcept(this->allocate(0))):
|
|
||||||
binary_base(size ? this->allocate(size) : nullptr, size, cap)
|
|
||||||
{
|
|
||||||
if(size)
|
|
||||||
memcpy(m_data, data, size);
|
|
||||||
}
|
|
||||||
template<class Allocator>
|
|
||||||
basic_binary<Allocator>::basic_binary(size_type size)
|
|
||||||
noexcept(noexcept(this->allocate(0))):
|
|
||||||
binary_base(this->allocate(size), size){}
|
|
||||||
template<class Allocator>
|
|
||||||
basic_binary<Allocator>::basic_binary(size_type size, size_type cap)
|
|
||||||
noexcept(noexcept(this->allocate(0))):
|
|
||||||
binary_base(size ? this->allocate(size) : nullptr, size, cap){}
|
|
||||||
template<class Allocator>
|
|
||||||
basic_binary<Allocator>::basic_binary(const basic_binary& b)
|
|
||||||
noexcept(noexcept(this->allocate(0))):
|
|
||||||
binary_base(b.m_size ? this->allocate(b.m_size) : nullptr, b.m_size, b.m_size)
|
|
||||||
{
|
|
||||||
if(b.m_size)
|
|
||||||
memcpy(m_data, b.m_data, b.m_size);
|
|
||||||
}
|
|
||||||
template<class Allocator>
|
|
||||||
constexpr basic_binary<Allocator>::basic_binary(basic_binary&& b)noexcept:
|
|
||||||
binary_base(exchange(b.m_data, nullptr), b.m_size, b.m_cap){}
|
|
||||||
template<class Allocator>
|
|
||||||
basic_binary<Allocator>::basic_binary(const binary_base& b)
|
|
||||||
noexcept(noexcept(this->allocate(0))):
|
|
||||||
binary_base(b.size() ? this->allocate(b.size()) : nullptr, b.size(), b.size())
|
|
||||||
{
|
|
||||||
if(b.size())
|
|
||||||
memcpy(m_data, b.get(), b.size());
|
|
||||||
}
|
|
||||||
template<class Allocator>
|
|
||||||
basic_binary<Allocator>::~basic_binary(void)
|
|
||||||
noexcept(noexcept(this->deallocate(nullptr,0)))
|
|
||||||
{
|
|
||||||
this->deallocate(m_data, m_cap);
|
|
||||||
}
|
|
||||||
template<class Allocator>
|
|
||||||
basic_binary<Allocator>& basic_binary<Allocator>::operator=(const basic_binary& b)
|
|
||||||
noexcept(noexcept(this->allocate(0)))
|
|
||||||
{
|
|
||||||
return _copy_data(b.get(), b.size());
|
|
||||||
}
|
|
||||||
template<class Allocator>
|
|
||||||
constexpr basic_binary<Allocator>& basic_binary<Allocator>::operator=(basic_binary&& b)noexcept{
|
|
||||||
m_size = b.m_size;
|
|
||||||
m_cap = b.m_cap;
|
|
||||||
swap(m_data, b.m_data);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
template<class Allocator>
|
|
||||||
basic_binary<Allocator>& basic_binary<Allocator>::operator=(const_pointer c)
|
|
||||||
noexcept(noexcept(this->allocate(0)))
|
|
||||||
{
|
|
||||||
return _copy_data(c, strlen(c));
|
|
||||||
}
|
|
||||||
template<class Allocator>
|
|
||||||
basic_binary<Allocator>& basic_binary<Allocator>::operator=(const binary_base& b)
|
|
||||||
noexcept(noexcept(this->allocate(0)))
|
|
||||||
{
|
|
||||||
return _copy_data(b.get(), b.size());
|
|
||||||
}
|
|
||||||
template<class Allocator>
|
|
||||||
void basic_binary<Allocator>::reset(void)
|
|
||||||
noexcept(noexcept(this->deallocate(nullptr,0)))
|
|
||||||
{
|
|
||||||
this->deallocate(m_data, m_cap);
|
|
||||||
m_data = nullptr;
|
|
||||||
m_cap = m_size = 0;
|
|
||||||
}
|
|
||||||
template<class Allocator>
|
|
||||||
void basic_binary<Allocator>::reset(pointer val, size_type cap, size_type size)
|
|
||||||
noexcept(noexcept(this->deallocate(nullptr,0)))
|
|
||||||
{
|
|
||||||
this->deallocate(m_data, m_cap);
|
|
||||||
m_data = val;
|
|
||||||
m_cap = cap;
|
|
||||||
m_size = size;
|
|
||||||
}
|
|
||||||
template<class Allocator>
|
|
||||||
bool basic_binary<Allocator>::resize(size_type newsize)
|
|
||||||
noexcept(noexcept(this->allocate(0)) &&
|
|
||||||
noexcept(this->deallocate(nullptr,0)))
|
|
||||||
{
|
|
||||||
if(newsize < m_cap)
|
|
||||||
return false;
|
|
||||||
basic_binary<allocator_type> tmp(newsize);
|
|
||||||
if(!tmp)
|
|
||||||
return false;
|
|
||||||
memcpy(STOP_STRICT_ALIAS_WARNING(tmp).m_data, m_data, m_size);
|
|
||||||
swap(m_data, STOP_STRICT_ALIAS_WARNING(tmp).m_data);
|
|
||||||
m_cap = STOP_STRICT_ALIAS_WARNING(tmp).m_cap;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
template<class Allocator>
|
|
||||||
void basic_binary<Allocator>::append(const_pointer data, size_type len)
|
|
||||||
noexcept(noexcept(this->allocate(0)) &&
|
|
||||||
noexcept(this->deallocate(nullptr,0)))
|
|
||||||
{
|
|
||||||
if(m_size + len > m_cap)
|
|
||||||
resize(max(m_cap*2, m_size+len));
|
|
||||||
memcpy(m_data+m_size, data, len);
|
|
||||||
m_size += len;
|
|
||||||
}
|
|
||||||
template<class Allocator>
|
|
||||||
basic_binary<Allocator>& basic_binary<Allocator>::_copy_data(const_pointer data, size_type len)
|
|
||||||
noexcept(noexcept(this->allocate(0)) &&
|
|
||||||
noexcept(this->deallocate(nullptr,0)))
|
|
||||||
{
|
|
||||||
if(!len)
|
|
||||||
return (*this = basic_binary(rexy::steal<pointer>(nullptr), 0, 0));
|
|
||||||
if(len <= m_size){
|
|
||||||
m_size = len;
|
|
||||||
memcpy(m_data, data, len);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
return (*this = basic_binary(data, len));
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr static_binary::static_binary(const_pointer str, size_type len)noexcept:
|
|
||||||
binary_base(const_cast<pointer>(str), len, len){}
|
|
||||||
constexpr static_binary::static_binary(const_pointer str)noexcept:
|
|
||||||
static_binary(str, strlen(str)){}
|
|
||||||
constexpr static_binary::static_binary(const static_binary& s)noexcept:
|
|
||||||
static_binary(s.get(), s.size()){}
|
|
||||||
constexpr static_binary::static_binary(static_binary&& s)noexcept:
|
|
||||||
static_binary(s.get(), s.size()){}
|
|
||||||
|
|
||||||
constexpr static_binary& static_binary::operator=(const_pointer str)noexcept{
|
|
||||||
m_data = const_cast<pointer>(str);
|
|
||||||
m_size = strlen(str);
|
|
||||||
m_cap = m_size;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
constexpr static_binary& static_binary::operator=(const static_binary& str)noexcept{
|
|
||||||
m_data = str.m_data;
|
|
||||||
m_size = str.m_size;
|
|
||||||
m_cap = str.m_cap;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
constexpr static_binary& static_binary::operator=(static_binary&& str)noexcept{
|
|
||||||
m_data = str.m_data;
|
|
||||||
m_size = str.m_size;
|
|
||||||
m_cap = str.m_cap;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Left, class Right>
|
|
||||||
constexpr auto binary_cat_expr<Left,Right>::size(void)const noexcept -> size_type{
|
|
||||||
return this->m_l.size() + this->m_r.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Left, class Right>
|
|
||||||
template<class Alloc>
|
|
||||||
binary_cat_expr<Left,Right>::operator basic_binary<Alloc>(void)
|
|
||||||
noexcept(std::is_nothrow_constructible<basic_binary<Alloc>, typename basic_binary<Alloc>::size_type>::value &&
|
|
||||||
std::is_nothrow_invocable<detail::string_appender<basic_binary<Alloc>>,decltype(*this)>::value)
|
|
||||||
{
|
|
||||||
auto sz = size();
|
|
||||||
basic_binary<Alloc> ret(sz);
|
|
||||||
|
|
||||||
detail::string_appender<basic_binary<Alloc>> append(ret);
|
|
||||||
|
|
||||||
append(*this);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#undef STOP_STRICT_ALIAS_WARNING
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -24,6 +24,8 @@
|
|||||||
#include <cstdlib> //size_t, ptrdiff_t
|
#include <cstdlib> //size_t, ptrdiff_t
|
||||||
#include <iterator> //reverse_iterator
|
#include <iterator> //reverse_iterator
|
||||||
|
|
||||||
|
#include "compat/constexpr.hpp"
|
||||||
|
|
||||||
namespace rexy{
|
namespace rexy{
|
||||||
|
|
||||||
template<class T, class Allocator = allocator<T>>
|
template<class T, class Allocator = allocator<T>>
|
||||||
@ -50,22 +52,22 @@ namespace rexy{
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
constexpr buffer(void);
|
constexpr buffer(void);
|
||||||
buffer(const_pointer data, size_type length)noexcept(noexcept(this->allocate(0)));
|
REXY_CPP20_CONSTEXPR buffer(const_pointer data, size_type length)noexcept(noexcept(this->allocate(0)));
|
||||||
template<class Iter>
|
template<class Iter>
|
||||||
buffer(const Iter& start, const Iter& last);
|
REXY_CPP20_CONSTEXPR buffer(const Iter& start, const Iter& last);
|
||||||
buffer(size_type cap)noexcept(noexcept(this->allocate(0)));
|
REXY_CPP20_CONSTEXPR buffer(size_type cap)noexcept(noexcept(this->allocate(0)));
|
||||||
buffer(const buffer& b)noexcept(noexcept(this->allocate(0)));
|
REXY_CPP20_CONSTEXPR buffer(const buffer& b)noexcept(noexcept(this->allocate(0)));
|
||||||
constexpr buffer(buffer&& b)noexcept;
|
constexpr buffer(buffer&& b)noexcept;
|
||||||
~buffer(void)noexcept(noexcept(this->deallocate(nullptr, 0)));
|
REXY_CPP20_CONSTEXPR ~buffer(void)noexcept(noexcept(this->deallocate(nullptr, 0)));
|
||||||
|
|
||||||
buffer& operator=(const buffer& b)
|
REXY_CPP20_CONSTEXPR buffer& operator=(const buffer& b)
|
||||||
noexcept(noexcept(this->allocate(0)) &&
|
noexcept(noexcept(this->allocate(0)) &&
|
||||||
noexcept(this->deallocate(nullptr, 0)));
|
noexcept(this->deallocate(nullptr, 0)));
|
||||||
constexpr buffer& operator=(buffer&& b)noexcept;
|
constexpr buffer& operator=(buffer&& b)noexcept;
|
||||||
|
|
||||||
constexpr pointer data(void);
|
constexpr pointer data(void);
|
||||||
constexpr const_pointer data(void)const;
|
constexpr const_pointer data(void)const;
|
||||||
void resize(size_type new_cap);
|
REXY_CPP20_CONSTEXPR void resize(size_type new_cap);
|
||||||
constexpr void set_size(size_type size);
|
constexpr void set_size(size_type size);
|
||||||
constexpr size_type cap(void)const;
|
constexpr size_type cap(void)const;
|
||||||
constexpr const size_type& size(void)const;
|
constexpr const size_type& size(void)const;
|
||||||
@ -91,6 +93,7 @@ namespace rexy{
|
|||||||
constexpr const_reverse_iterator crbegin(void)const;
|
constexpr const_reverse_iterator crbegin(void)const;
|
||||||
constexpr const_reverse_iterator crend(void)const;
|
constexpr const_reverse_iterator crend(void)const;
|
||||||
|
|
||||||
|
REXY_CPP20_CONSTEXPR void append(const_pointer p, size_type len);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,13 +20,14 @@
|
|||||||
#define REXY_BUFFER_TPP
|
#define REXY_BUFFER_TPP
|
||||||
|
|
||||||
#include <utility> //exchange, swap
|
#include <utility> //exchange, swap
|
||||||
|
#include <algorithm> //max
|
||||||
|
|
||||||
namespace rexy{
|
namespace rexy{
|
||||||
|
|
||||||
template<class T, class Allocator>
|
template<class T, class Allocator>
|
||||||
constexpr buffer<T,Allocator>::buffer(void){}
|
constexpr buffer<T,Allocator>::buffer(void){}
|
||||||
template<class T, class Allocator>
|
template<class T, class Allocator>
|
||||||
buffer<T,Allocator>::buffer(const_pointer data, size_type length)noexcept(noexcept(this->allocate(0))):
|
REXY_CPP20_CONSTEXPR buffer<T,Allocator>::buffer(const_pointer data, size_type length)noexcept(noexcept(this->allocate(0))):
|
||||||
m_data(this->allocate(sizeof(value_type) * length)),
|
m_data(this->allocate(sizeof(value_type) * length)),
|
||||||
m_cap(length),
|
m_cap(length),
|
||||||
m_size(length)
|
m_size(length)
|
||||||
@ -37,7 +38,7 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
template<class T, class Allocator>
|
template<class T, class Allocator>
|
||||||
template<class Iter>
|
template<class Iter>
|
||||||
buffer<T,Allocator>::buffer(const Iter& start, const Iter& last){
|
REXY_CPP20_CONSTEXPR buffer<T,Allocator>::buffer(const Iter& start, const Iter& last){
|
||||||
size_type count = 0;
|
size_type count = 0;
|
||||||
for(auto it = start;it != end;++it){
|
for(auto it = start;it != end;++it){
|
||||||
++count;
|
++count;
|
||||||
@ -53,12 +54,12 @@ namespace rexy{
|
|||||||
m_size = count;
|
m_size = count;
|
||||||
}
|
}
|
||||||
template<class T, class Allocator>
|
template<class T, class Allocator>
|
||||||
buffer<T,Allocator>::buffer(size_type cap)noexcept(noexcept(this->allocate(0))):
|
REXY_CPP20_CONSTEXPR buffer<T,Allocator>::buffer(size_type cap)noexcept(noexcept(this->allocate(0))):
|
||||||
m_data(this->allocate(sizeof(value_type) * cap)),
|
m_data(this->allocate(sizeof(value_type) * cap)),
|
||||||
m_cap(cap),
|
m_cap(cap),
|
||||||
m_size(0){}
|
m_size(0){}
|
||||||
template<class T, class Allocator>
|
template<class T, class Allocator>
|
||||||
buffer<T,Allocator>::buffer(const buffer& b)noexcept(noexcept(this->allocate(0))):
|
REXY_CPP20_CONSTEXPR buffer<T,Allocator>::buffer(const buffer& b)noexcept(noexcept(this->allocate(0))):
|
||||||
m_data(this->allocate(sizeof(value_type) * b.m_cap)),
|
m_data(this->allocate(sizeof(value_type) * b.m_cap)),
|
||||||
m_cap(b.m_cap),
|
m_cap(b.m_cap),
|
||||||
m_size(b.m_size)
|
m_size(b.m_size)
|
||||||
@ -73,14 +74,14 @@ namespace rexy{
|
|||||||
m_cap(b.m_cap),
|
m_cap(b.m_cap),
|
||||||
m_size(b.m_size){}
|
m_size(b.m_size){}
|
||||||
template<class T, class Allocator>
|
template<class T, class Allocator>
|
||||||
buffer<T,Allocator>::~buffer(void)noexcept(noexcept(this->deallocate(nullptr, 0))){
|
REXY_CPP20_CONSTEXPR buffer<T,Allocator>::~buffer(void)noexcept(noexcept(this->deallocate(nullptr, 0))){
|
||||||
for(size_type i = 0;i < m_size;++i){
|
for(size_type i = 0;i < m_size;++i){
|
||||||
m_data[i].~T();
|
m_data[i].~T();
|
||||||
}
|
}
|
||||||
this->deallocate(m_data, m_cap * sizeof(value_type));
|
this->deallocate(m_data, m_cap * sizeof(value_type));
|
||||||
}
|
}
|
||||||
template<class T, class Allocator>
|
template<class T, class Allocator>
|
||||||
buffer<T,Allocator>& buffer<T,Allocator>::operator=(const buffer& b)
|
REXY_CPP20_CONSTEXPR buffer<T,Allocator>& buffer<T,Allocator>::operator=(const buffer& b)
|
||||||
noexcept(noexcept(this->allocate(0)) &&
|
noexcept(noexcept(this->allocate(0)) &&
|
||||||
noexcept(this->deallocate(nullptr, 0)))
|
noexcept(this->deallocate(nullptr, 0)))
|
||||||
{
|
{
|
||||||
@ -102,7 +103,7 @@ namespace rexy{
|
|||||||
return m_data;
|
return m_data;
|
||||||
}
|
}
|
||||||
template<class T, class Allocator>
|
template<class T, class Allocator>
|
||||||
void buffer<T,Allocator>::resize(size_type new_cap){
|
REXY_CPP20_CONSTEXPR void buffer<T,Allocator>::resize(size_type new_cap){
|
||||||
if(new_cap > m_cap){
|
if(new_cap > m_cap){
|
||||||
buffer tmp(new_cap);
|
buffer tmp(new_cap);
|
||||||
for(size_type i = 0;i < m_size;++i){
|
for(size_type i = 0;i < m_size;++i){
|
||||||
@ -199,6 +200,16 @@ namespace rexy{
|
|||||||
return const_reverse_iterator(m_data - 1);
|
return const_reverse_iterator(m_data - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<class T, class Allocator>
|
||||||
|
REXY_CPP20_CONSTEXPR void buffer<T,Allocator>::append(const_pointer p, size_type len){
|
||||||
|
if(len + m_size > m_cap){
|
||||||
|
resize(std::max(m_cap * 2, len + m_size));
|
||||||
|
}
|
||||||
|
for(size_type i = 0;i < len;++i){
|
||||||
|
new (m_data + (m_size + i)) T(p[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
107
include/rexy/compat/cpp17/source_location.hpp
Normal file
107
include/rexy/compat/cpp17/source_location.hpp
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
/**
|
||||||
|
This file is a part of rexy's general purpose library
|
||||||
|
Copyright (C) 2022 rexy712
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef REXY_COMPAT_17_SOURCE_LOCATION_HPP
|
||||||
|
#define REXY_COMPAT_17_SOURCE_LOCATION_HPP
|
||||||
|
|
||||||
|
#include <cstdint> //uint_least32_t
|
||||||
|
|
||||||
|
//clang bug: https://bugs.llvm.org/show_bug.cgi?id=48886
|
||||||
|
#if __cplusplus >= 202002L && !defined(__clang__)
|
||||||
|
#define CONSTEVAL consteval
|
||||||
|
#else
|
||||||
|
#define CONSTEVAL constexpr
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace rexy::compat::cpp17{
|
||||||
|
|
||||||
|
class source_location
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
const char* m_file;
|
||||||
|
const char* m_func;
|
||||||
|
uint_least32_t m_line;
|
||||||
|
uint_least32_t m_column;
|
||||||
|
|
||||||
|
public:
|
||||||
|
constexpr source_location(void)noexcept;
|
||||||
|
constexpr source_location(const source_location&);
|
||||||
|
constexpr source_location(source_location&&)noexcept;
|
||||||
|
|
||||||
|
constexpr uint_least32_t line(void)const noexcept;
|
||||||
|
constexpr uint_least32_t column(void)const noexcept;
|
||||||
|
constexpr const char* file_name(void)const noexcept;
|
||||||
|
constexpr const char* function_name(void)const noexcept;
|
||||||
|
|
||||||
|
public:
|
||||||
|
#if (defined(__clang__) && (__clang_major__ >= 9)) || (defined(_MSC_VER) && (_MSC_VER >= 1926))
|
||||||
|
static CONSTEVAL source_location current(uint_least32_t line = __builtin_LINE(),
|
||||||
|
uint_least32_t col = __builtin_COLUMN(),
|
||||||
|
const char* file = __builtin_FILE(),
|
||||||
|
const char* func = __builtin_FUNCTION())noexcept;
|
||||||
|
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
|
||||||
|
static CONSTEVAL source_location current(uint_least32_t line = __builtin_LINE(),
|
||||||
|
uint_least32_t col = 0,
|
||||||
|
const char* file = __builtin_FILE(),
|
||||||
|
const char* func = __builtin_FUNCTION())noexcept;
|
||||||
|
#else
|
||||||
|
static CONSTEVAL source_location current(uint_least32_t line = 0,
|
||||||
|
uint_least32_t col = 0,
|
||||||
|
const char* file = "unknown",
|
||||||
|
const char* func = "unknown")noexcept;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
constexpr source_location(uint_least32_t line, uint_least32_t col, const char* file, const char* func)noexcept;
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr source_location::source_location(void)noexcept:
|
||||||
|
source_location(0, 0, "unknown", "unknown"){}
|
||||||
|
constexpr source_location::source_location(const source_location& s):
|
||||||
|
source_location(s.m_line, s.m_column, s.m_file, s.m_func){}
|
||||||
|
constexpr source_location::source_location(source_location&& s)noexcept:
|
||||||
|
source_location(s.m_line, s.m_column, s.m_file, s.m_func){}
|
||||||
|
constexpr source_location::source_location(uint_least32_t line, uint_least32_t col, const char* file, const char* func)noexcept:
|
||||||
|
m_file(file),
|
||||||
|
m_func(func),
|
||||||
|
m_line(line),
|
||||||
|
m_column(col){}
|
||||||
|
|
||||||
|
constexpr uint_least32_t source_location::line(void)const noexcept{
|
||||||
|
return m_line;
|
||||||
|
}
|
||||||
|
constexpr uint_least32_t source_location::column(void)const noexcept{
|
||||||
|
return m_column;
|
||||||
|
}
|
||||||
|
constexpr const char* source_location::file_name(void)const noexcept{
|
||||||
|
return m_file;
|
||||||
|
}
|
||||||
|
constexpr const char* source_location::function_name(void)const noexcept{
|
||||||
|
return m_func;
|
||||||
|
}
|
||||||
|
|
||||||
|
CONSTEVAL source_location source_location::current(uint_least32_t line, uint_least32_t col, const char* file, const char* func)noexcept{
|
||||||
|
return source_location(line, col, file, func);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#undef CONSTEVAL
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
This file is a part of rexy's general purpose library
|
This file is a part of rexy's general purpose library
|
||||||
Copyright (C) 2020 rexy712
|
Copyright (C) 2022 rexy712
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -16,18 +16,19 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef REXY_BINARY_HPP
|
#ifndef REXY_COMPAT_17_TO_ADDRESS_HPP
|
||||||
#define REXY_BINARY_HPP
|
#define REXY_COMPAT_17_TO_ADDRESS_HPP
|
||||||
|
|
||||||
#include "binary_base.hpp"
|
namespace rexy::compat::cpp17{
|
||||||
#include "allocator.hpp"
|
|
||||||
#include "rexy.hpp"
|
|
||||||
|
|
||||||
namespace rexy{
|
template<class T>
|
||||||
|
constexpr T* to_address(T* p)noexcept{
|
||||||
using binary = basic_binary<allocator<char>>;
|
return p;
|
||||||
|
}
|
||||||
extern template class basic_binary<allocator<char>>;
|
template<class Ptr>
|
||||||
|
constexpr auto to_address(const Ptr& p)noexcept{
|
||||||
|
return to_address(p.operator->());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
This file is a part of rexy's general purpose library
|
This file is a part of rexy's general purpose library
|
||||||
Copyright (C) 2020 rexy712
|
Copyright (C) 2022 rexy712
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -16,11 +16,15 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "rexy/binary.hpp"
|
#ifndef REXY_COMPAT_20_SOURCE_LOCATION_HPP
|
||||||
#include "rexy/allocator.hpp"
|
#define REXY_COMPAT_20_SOURCE_LOCATION_HPP
|
||||||
|
|
||||||
namespace rexy{
|
#include <source_location>
|
||||||
|
|
||||||
template class basic_binary<allocator<char>>;
|
namespace rexy::compat::cpp20{
|
||||||
|
|
||||||
|
using source_location = std::source_location;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
37
include/rexy/compat/cpp20/to_address.hpp
Normal file
37
include/rexy/compat/cpp20/to_address.hpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/**
|
||||||
|
This file is a part of rexy's general purpose library
|
||||||
|
Copyright (C) 2022 rexy712
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef REXY_COMPAT_20_TO_ADDRESS_HPP
|
||||||
|
#define REXY_COMPAT_20_TO_ADDRESS_HPP
|
||||||
|
|
||||||
|
#include <memory> //to_address
|
||||||
|
|
||||||
|
namespace rexy::compat::cpp20{
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
constexpr T* to_address(T* p)noexcept{
|
||||||
|
return std::to_address(p);
|
||||||
|
}
|
||||||
|
template<class Ptr>
|
||||||
|
constexpr auto to_address(const Ptr& p)noexcept{
|
||||||
|
return std::to_address(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -23,101 +23,26 @@
|
|||||||
|
|
||||||
#ifndef __cpp_lib_source_location
|
#ifndef __cpp_lib_source_location
|
||||||
|
|
||||||
#include <cstdint> //uint_least32_t
|
#include "cpp17/source_location.hpp"
|
||||||
|
|
||||||
//clang bug: https://bugs.llvm.org/show_bug.cgi?id=48886
|
|
||||||
#if __cplusplus >= 202002L && !defined(__clang__)
|
|
||||||
#define CONSTEVAL consteval
|
|
||||||
#else
|
|
||||||
#define CONSTEVAL constexpr
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace rexy::compat{
|
namespace rexy::compat{
|
||||||
|
|
||||||
class source_location
|
using source_location = cpp17::source_location;
|
||||||
{
|
|
||||||
private:
|
|
||||||
const char* m_file;
|
|
||||||
const char* m_func;
|
|
||||||
uint_least32_t m_line;
|
|
||||||
uint_least32_t m_column;
|
|
||||||
|
|
||||||
public:
|
|
||||||
constexpr source_location(void)noexcept;
|
|
||||||
constexpr source_location(const source_location&);
|
|
||||||
constexpr source_location(source_location&&)noexcept;
|
|
||||||
|
|
||||||
constexpr uint_least32_t line(void)const noexcept;
|
|
||||||
constexpr uint_least32_t column(void)const noexcept;
|
|
||||||
constexpr const char* file_name(void)const noexcept;
|
|
||||||
constexpr const char* function_name(void)const noexcept;
|
|
||||||
|
|
||||||
public:
|
|
||||||
#if (defined(__clang__) && (__clang_major__ >= 9)) || (defined(_MSC_VER) && (_MSC_VER >= 1926))
|
|
||||||
static CONSTEVAL source_location current(uint_least32_t line = __builtin_LINE(),
|
|
||||||
uint_least32_t col = __builtin_COLUMN(),
|
|
||||||
const char* file = __builtin_FILE(),
|
|
||||||
const char* func = __builtin_FUNCTION())noexcept;
|
|
||||||
#elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8))
|
|
||||||
static CONSTEVAL source_location current(uint_least32_t line = __builtin_LINE(),
|
|
||||||
uint_least32_t col = 0,
|
|
||||||
const char* file = __builtin_FILE(),
|
|
||||||
const char* func = __builtin_FUNCTION())noexcept;
|
|
||||||
#else
|
|
||||||
static CONSTEVAL source_location current(uint_least32_t line = 0,
|
|
||||||
uint_least32_t col = 0,
|
|
||||||
const char* file = "unknown",
|
|
||||||
const char* func = "unknown")noexcept;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
private:
|
|
||||||
constexpr source_location(uint_least32_t line, uint_least32_t col, const char* file, const char* func)noexcept;
|
|
||||||
};
|
|
||||||
|
|
||||||
constexpr source_location::source_location(void)noexcept:
|
|
||||||
source_location(0, 0, "unknown", "unknown"){}
|
|
||||||
constexpr source_location::source_location(const source_location& s):
|
|
||||||
source_location(s.m_line, s.m_column, s.m_file, s.m_func){}
|
|
||||||
constexpr source_location::source_location(source_location&& s)noexcept:
|
|
||||||
source_location(s.m_line, s.m_column, s.m_file, s.m_func){}
|
|
||||||
constexpr source_location::source_location(uint_least32_t line, uint_least32_t col, const char* file, const char* func)noexcept:
|
|
||||||
m_file(file),
|
|
||||||
m_func(func),
|
|
||||||
m_line(line),
|
|
||||||
m_column(col){}
|
|
||||||
|
|
||||||
constexpr uint_least32_t source_location::line(void)const noexcept{
|
|
||||||
return m_line;
|
|
||||||
}
|
|
||||||
constexpr uint_least32_t source_location::column(void)const noexcept{
|
|
||||||
return m_column;
|
|
||||||
}
|
|
||||||
constexpr const char* source_location::file_name(void)const noexcept{
|
|
||||||
return m_file;
|
|
||||||
}
|
|
||||||
constexpr const char* source_location::function_name(void)const noexcept{
|
|
||||||
return m_func;
|
|
||||||
}
|
|
||||||
|
|
||||||
CONSTEVAL source_location source_location::current(uint_least32_t line, uint_least32_t col, const char* file, const char* func)noexcept{
|
|
||||||
return source_location(line, col, file, func);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef CONSTEVAL
|
|
||||||
|
|
||||||
#else //__cpp_lib_source_location
|
#else //__cpp_lib_source_location
|
||||||
|
|
||||||
#include <source_location>
|
#include "cpp20/source_location.hpp"
|
||||||
|
|
||||||
namespace rexy::compat{
|
namespace rexy::compat{
|
||||||
|
|
||||||
using source_location = std::source_location;
|
using source_location = cpp20::source_location;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //__cpp_lib_source_location
|
#endif //__cpp_lib_source_location
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@ -19,32 +19,25 @@
|
|||||||
#ifndef REXY_COMPAT_TO_ADDRESS_HPP
|
#ifndef REXY_COMPAT_TO_ADDRESS_HPP
|
||||||
#define REXY_COMPAT_TO_ADDRESS_HPP
|
#define REXY_COMPAT_TO_ADDRESS_HPP
|
||||||
|
|
||||||
#if __cplusplus >= 202002L
|
#ifdef __cpp_lib_to_address
|
||||||
#include <memory> //to_address
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
#include "cpp20/to_address.hpp"
|
||||||
namespace rexy::compat{
|
namespace rexy::compat{
|
||||||
#if __cplusplus >= 202002L
|
|
||||||
template<class T>
|
using cpp20::to_address;
|
||||||
constexpr T* to_address(T* p)noexcept{
|
|
||||||
return std::to_address(p);
|
|
||||||
}
|
|
||||||
template<class Ptr>
|
|
||||||
constexpr auto to_address(const Ptr& p)noexcept{
|
|
||||||
return std::to_address(p);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
template<class T>
|
|
||||||
constexpr T* to_address(T* p)noexcept{
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
template<class Ptr>
|
|
||||||
constexpr auto to_address(const Ptr& p)noexcept{
|
|
||||||
return to_address(p.operator->());
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else //__cpp_lib_to_address
|
||||||
|
|
||||||
|
#include "cpp17/to_address.hpp"
|
||||||
|
namespace rexy::compat{
|
||||||
|
|
||||||
|
using cpp17::to_address;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif //__cpp_lib_to_address
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -29,7 +29,7 @@ namespace rexy::cx{
|
|||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
#include <cstddef> //ptrdiff_t, size_t
|
#include <cstddef> //ptrdiff_t, size_t
|
||||||
|
|
||||||
#include "../detail/cpp20.hpp"
|
#include "../compat/constexpr.hpp"
|
||||||
|
|
||||||
//This is different from rexy::static_string in that this doesn't hold a pointer to a constant string array.
|
//This is different from rexy::static_string in that this doesn't hold a pointer to a constant string array.
|
||||||
//This holds a mutable array of data which can be modified during compile time. static_string is
|
//This holds a mutable array of data which can be modified during compile time. static_string is
|
||||||
|
|||||||
@ -1,55 +0,0 @@
|
|||||||
/**
|
|
||||||
This file is a part of rexy's general purpose library
|
|
||||||
Copyright (C) 2020 rexy712
|
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation, either version 3 of the License, or
|
|
||||||
(at your option) any later version.
|
|
||||||
|
|
||||||
This program is distributed in the hope that it will be useful,
|
|
||||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
GNU General Public License for more details.
|
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License
|
|
||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef REXY_BINARY_STRING_CONV_HPP
|
|
||||||
#define REXY_BINARY_STRING_CONV_HPP
|
|
||||||
|
|
||||||
#include "rexy/string_base.hpp"
|
|
||||||
#include "rexy/binary_base.hpp"
|
|
||||||
#include <cstring> //memcpy
|
|
||||||
|
|
||||||
namespace rexy{
|
|
||||||
template<class Str, std::enable_if_t<is_string_v<Str>,int> = 0>
|
|
||||||
auto binary_to_string(const binary_base& b)
|
|
||||||
noexcept(std::is_nothrow_constructible<Str, decltype(b.size())>::value)
|
|
||||||
{
|
|
||||||
Str s(b.size()+1);
|
|
||||||
s.append(b.get(), b.size());
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
template<class Al, class Str, std::enable_if_t<is_string_v<Str>,int> = 0, std::enable_if_t<std::is_same<std::decay_t<Al>,typename Str::allocator_type>::value,int> = 0>
|
|
||||||
auto binary_to_string(basic_binary<Al>&& b)noexcept{
|
|
||||||
return Str(rexy::steal(b.release()), b.size());
|
|
||||||
}
|
|
||||||
template<class Bin, detail::enable_if_binary<Bin> = 0>
|
|
||||||
auto string_to_binary(const string_base<char>& s)
|
|
||||||
noexcept(std::is_nothrow_constructible<Bin, decltype(s.length())>::value &&
|
|
||||||
noexcept(std::decay_t<Bin>::allocator_type::allocate(0)))
|
|
||||||
{
|
|
||||||
Bin b(s.length()+1);
|
|
||||||
b.append(s.get(), s.length()+1);
|
|
||||||
return b;
|
|
||||||
}
|
|
||||||
template<class Al, class Bin, detail::enable_if_binary<Bin> = 0, std::enable_if_t<std::is_same<std::decay_t<Al>,typename Bin::allocator_type>::value,int> = 0>
|
|
||||||
auto string_to_binary(basic_string<char,Al>&& s)noexcept{
|
|
||||||
return Bin(rexy::steal(s.release()), s.length());
|
|
||||||
}
|
|
||||||
|
|
||||||
} //namespace rexy
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -25,9 +25,9 @@
|
|||||||
|
|
||||||
#include "string.hpp"
|
#include "string.hpp"
|
||||||
#include "steal.hpp"
|
#include "steal.hpp"
|
||||||
#include "binary.hpp"
|
|
||||||
#include "utility.hpp"
|
#include "utility.hpp"
|
||||||
#include "rexy.hpp"
|
#include "rexy.hpp"
|
||||||
|
#include "buffer.hpp"
|
||||||
|
|
||||||
namespace rexy{
|
namespace rexy{
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ namespace rexy{
|
|||||||
size_t read(char* dest, size_t bytes)noexcept;
|
size_t read(char* dest, size_t bytes)noexcept;
|
||||||
rexy::string read(size_t bytes)noexcept;
|
rexy::string read(size_t bytes)noexcept;
|
||||||
rexy::string readln(size_t max = 0)noexcept;
|
rexy::string readln(size_t max = 0)noexcept;
|
||||||
rexy::binary read_bin(size_t bytes)noexcept(std::is_nothrow_constructible<rexy::binary, rexy::steal<char*>, size_t, size_t>::value);
|
rexy::buffer<char> read_bin(size_t bytes)noexcept(std::is_nothrow_constructible<rexy::buffer<char>, char*, size_t>::value);
|
||||||
|
|
||||||
size_t write(const char* c, size_t bytes)noexcept;
|
size_t write(const char* c, size_t bytes)noexcept;
|
||||||
size_t write(const rexy::string_base<char>& s)noexcept;
|
size_t write(const rexy::string_base<char>& s)noexcept;
|
||||||
|
|||||||
@ -41,7 +41,7 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef REXY_STRING_BASE_HPP
|
#ifdef REXY_STRING_BASE_HPP
|
||||||
#include "static_string_hash.hpp"
|
#include "string_view_hash.hpp"
|
||||||
#endif
|
#endif
|
||||||
#ifdef REXY_STRING_HPP
|
#ifdef REXY_STRING_HPP
|
||||||
#include "basic_string_hash.hpp"
|
#include "basic_string_hash.hpp"
|
||||||
|
|||||||
@ -70,7 +70,7 @@ namespace rexy{
|
|||||||
constexpr reference operator*(void)noexcept;
|
constexpr reference operator*(void)noexcept;
|
||||||
constexpr const_reference operator*(void)const noexcept;
|
constexpr const_reference operator*(void)const noexcept;
|
||||||
|
|
||||||
bool valid(void)const;
|
constexpr bool valid(void)const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -114,7 +114,7 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
bool storage_for<T>::valid(void)const{
|
constexpr bool storage_for<T>::valid(void)const{
|
||||||
return m_dirty;
|
return m_dirty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
This file is a part of rexy's general purpose library
|
This file is a part of rexy's general purpose library
|
||||||
Copyright (C) 2020 rexy712
|
Copyright (C) 2020-2022 rexy712
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -35,7 +35,7 @@
|
|||||||
#include "detail/hasallocator.hpp"
|
#include "detail/hasallocator.hpp"
|
||||||
#include "rexy.hpp"
|
#include "rexy.hpp"
|
||||||
|
|
||||||
#include "detail/cpp20.hpp"
|
#include "compat/constexpr.hpp"
|
||||||
|
|
||||||
#if __cplusplus >= 202002L
|
#if __cplusplus >= 202002L
|
||||||
#include <concepts>
|
#include <concepts>
|
||||||
@ -44,82 +44,7 @@
|
|||||||
namespace rexy{
|
namespace rexy{
|
||||||
|
|
||||||
template<class Char>
|
template<class Char>
|
||||||
class string_base;
|
class basic_string_view;
|
||||||
|
|
||||||
template<class Char>
|
|
||||||
class basic_string_view
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
using value_type = Char;
|
|
||||||
using size_type = size_t;
|
|
||||||
using difference_type = ptrdiff_t;
|
|
||||||
using pointer = value_type*;
|
|
||||||
using const_pointer = const value_type*;
|
|
||||||
using reference = value_type&;
|
|
||||||
using const_reference = const value_type&;
|
|
||||||
using iterator = pointer;
|
|
||||||
using const_iterator = const_pointer;
|
|
||||||
using reverse_iterator = std::reverse_iterator<iterator>;
|
|
||||||
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
|
||||||
|
|
||||||
private:
|
|
||||||
const_pointer m_data = nullptr;
|
|
||||||
size_type m_length = 0;
|
|
||||||
|
|
||||||
public:
|
|
||||||
constexpr basic_string_view(void)noexcept;
|
|
||||||
constexpr basic_string_view(const_pointer str, size_type len)noexcept;
|
|
||||||
constexpr basic_string_view(const_pointer c)noexcept;
|
|
||||||
constexpr basic_string_view(const basic_string_view& s)noexcept;
|
|
||||||
constexpr basic_string_view(const string_base<Char>& s)noexcept;
|
|
||||||
constexpr basic_string_view(basic_string_view&& s)noexcept;
|
|
||||||
template<class InIter>
|
|
||||||
constexpr basic_string_view(InIter start, InIter fin)noexcept;
|
|
||||||
REXY_CPP20_CONSTEXPR ~basic_string_view(void)noexcept = default;
|
|
||||||
|
|
||||||
constexpr basic_string_view& operator=(const_pointer c)noexcept;
|
|
||||||
constexpr basic_string_view& operator=(const basic_string_view& s)noexcept;
|
|
||||||
constexpr basic_string_view& operator=(basic_string_view&&)noexcept;
|
|
||||||
|
|
||||||
|
|
||||||
//Length of string not including null terminator
|
|
||||||
constexpr size_type length(void)const noexcept{return m_length;}
|
|
||||||
//direct access to managed pointer
|
|
||||||
constexpr const_pointer c_str(void)const noexcept{return m_data;}
|
|
||||||
constexpr const_pointer get(void)const noexcept{return m_data;}
|
|
||||||
constexpr operator const_pointer(void)const noexcept{return m_data;}
|
|
||||||
//true if m_data is not empty
|
|
||||||
constexpr bool valid(void)const noexcept{return m_length > 0;}
|
|
||||||
|
|
||||||
constexpr const_reference operator[](size_type i)const noexcept{return m_data[i];}
|
|
||||||
|
|
||||||
constexpr const_iterator search(const basic_string_view& s)const;
|
|
||||||
constexpr const_iterator search(const_pointer c)const;
|
|
||||||
template<class Searcher>
|
|
||||||
constexpr const_iterator search(const basic_string_view& s, const Searcher& searcher)const;
|
|
||||||
template<class Searcher>
|
|
||||||
constexpr const_iterator search(const_pointer c, const Searcher& searcher)const;
|
|
||||||
constexpr bool compare(const basic_string_view& s)const{return *this == s;}
|
|
||||||
constexpr bool compare(const_pointer c)const{return *this == c;}
|
|
||||||
|
|
||||||
constexpr const_iterator begin(void)const{return m_data;}
|
|
||||||
constexpr const_iterator end(void)const{return m_data+m_length;}
|
|
||||||
constexpr const_iterator cbegin(void)const{return begin();}
|
|
||||||
constexpr const_iterator cend(void)const{return end();}
|
|
||||||
|
|
||||||
constexpr const_reverse_iterator rbegin(void)const{return const_reverse_iterator(m_data+m_length);}
|
|
||||||
constexpr const_reverse_iterator rend(void)const{return const_reverse_iterator(m_data-1);}
|
|
||||||
constexpr const_reverse_iterator crbegin(void)const{return rbegin();}
|
|
||||||
constexpr const_reverse_iterator crend(void)const{return rend();}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
basic_string_view(const T*) -> basic_string_view<T>;
|
|
||||||
template<class T>
|
|
||||||
basic_string_view(const T*, size_t) -> basic_string_view<T>;
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
using static_string [[deprecated]] = basic_string_view<T>;
|
|
||||||
|
|
||||||
//Base of all RAII strings. Its use is allowing passing of rexy strings to functions without knowing the exact type
|
//Base of all RAII strings. Its use is allowing passing of rexy strings to functions without knowing the exact type
|
||||||
template<class Char>
|
template<class Char>
|
||||||
@ -163,7 +88,7 @@ namespace rexy{
|
|||||||
length(0),
|
length(0),
|
||||||
data{}{}
|
data{}{}
|
||||||
};
|
};
|
||||||
//union of short and long string representations. Default to long representation for string_view's use case.
|
//union of short and long string representations. Default to long representation for wstring_view's use case.
|
||||||
union combine_data{
|
union combine_data{
|
||||||
ldata l;
|
ldata l;
|
||||||
sdata s;
|
sdata s;
|
||||||
@ -633,9 +558,6 @@ namespace rexy{
|
|||||||
template<class T>
|
template<class T>
|
||||||
static constexpr bool is_string_v = is_string<T>::value;
|
static constexpr bool is_string_v = is_string<T>::value;
|
||||||
|
|
||||||
static_assert(is_string_v<basic_string_view<char>>);
|
|
||||||
|
|
||||||
|
|
||||||
template<class... Ts>
|
template<class... Ts>
|
||||||
struct are_strings{
|
struct are_strings{
|
||||||
static constexpr bool value = (is_string<Ts>::value && ...);
|
static constexpr bool value = (is_string<Ts>::value && ...);
|
||||||
@ -777,44 +699,10 @@ namespace rexy{
|
|||||||
#include "string_base.tpp"
|
#include "string_base.tpp"
|
||||||
|
|
||||||
namespace{
|
namespace{
|
||||||
[[deprecated]]
|
|
||||||
constexpr inline rexy::basic_string_view<char> operator"" _ss(const char* str, size_t len)noexcept{
|
|
||||||
return rexy::basic_string_view(str, len);
|
|
||||||
}
|
|
||||||
[[deprecated]]
|
|
||||||
constexpr inline rexy::basic_string_view<wchar_t> operator"" _ss(const wchar_t* str, size_t len)noexcept{
|
|
||||||
return rexy::basic_string_view(str, len);
|
|
||||||
}
|
|
||||||
[[deprecated]]
|
|
||||||
constexpr inline rexy::basic_string_view<char16_t> operator"" _ss(const char16_t* str, size_t len)noexcept{
|
|
||||||
return rexy::basic_string_view(str, len);
|
|
||||||
}
|
|
||||||
[[deprecated]]
|
|
||||||
constexpr inline rexy::basic_string_view<char32_t> operator"" _ss(const char32_t* str, size_t len)noexcept{
|
|
||||||
return rexy::basic_string_view(str, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr inline rexy::basic_string_view<char> operator"" _sv(const char* str, size_t len)noexcept{
|
|
||||||
return rexy::basic_string_view(str, len);
|
|
||||||
}
|
|
||||||
constexpr inline rexy::basic_string_view<wchar_t> operator"" _sv(const wchar_t* str, size_t len)noexcept{
|
|
||||||
return rexy::basic_string_view(str, len);
|
|
||||||
}
|
|
||||||
constexpr inline rexy::basic_string_view<char16_t> operator"" _sv(const char16_t* str, size_t len)noexcept{
|
|
||||||
return rexy::basic_string_view(str, len);
|
|
||||||
}
|
|
||||||
constexpr inline rexy::basic_string_view<char32_t> operator"" _sv(const char32_t* str, size_t len)noexcept{
|
|
||||||
return rexy::basic_string_view(str, len);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<class Char, class Alloc>
|
template<class Char, class Alloc>
|
||||||
std::ostream& operator<<(std::ostream& os, const rexy::basic_string<Char,Alloc>& str){
|
std::ostream& operator<<(std::ostream& os, const rexy::basic_string<Char,Alloc>& str){
|
||||||
return os << str.c_str();
|
return os << str.c_str();
|
||||||
}
|
}
|
||||||
template<class Char>
|
|
||||||
std::ostream& operator<<(std::ostream& os, const rexy::basic_string_view<Char>& str){
|
|
||||||
return os << str.c_str();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -27,6 +27,7 @@
|
|||||||
#include "detail/string_appender.hpp"
|
#include "detail/string_appender.hpp"
|
||||||
#include "algorithm.hpp"
|
#include "algorithm.hpp"
|
||||||
#include "compat/to_address.hpp"
|
#include "compat/to_address.hpp"
|
||||||
|
#include "string_view.hpp"
|
||||||
|
|
||||||
#define STOP_STRICT_ALIAS_WARNING(x) (x)
|
#define STOP_STRICT_ALIAS_WARNING(x) (x)
|
||||||
|
|
||||||
@ -382,49 +383,6 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Char>
|
|
||||||
constexpr basic_string_view<Char>::basic_string_view(void)noexcept:
|
|
||||||
basic_string_view(nullptr, 0){}
|
|
||||||
|
|
||||||
template<class Char>
|
|
||||||
constexpr basic_string_view<Char>::basic_string_view(const_pointer str, size_type len)noexcept:
|
|
||||||
m_data(str), m_length(len){}
|
|
||||||
template<class Char>
|
|
||||||
constexpr basic_string_view<Char>::basic_string_view(const basic_string_view& s)noexcept:
|
|
||||||
m_data(s.m_data), m_length(s.m_length){}
|
|
||||||
template<class Char>
|
|
||||||
constexpr basic_string_view<Char>::basic_string_view(const string_base<Char>& s)noexcept:
|
|
||||||
m_data(s.c_str()), m_length(s.length()){}
|
|
||||||
template<class Char>
|
|
||||||
constexpr basic_string_view<Char>::basic_string_view(basic_string_view&& s)noexcept:
|
|
||||||
m_data(s.m_data), m_length(s.m_length){}
|
|
||||||
template<class Char>
|
|
||||||
template<class InIter>
|
|
||||||
constexpr basic_string_view<Char>::basic_string_view(InIter start, InIter fin)noexcept:
|
|
||||||
basic_string_view(compat::to_address(start), fin - start){}
|
|
||||||
|
|
||||||
template<class Char>
|
|
||||||
constexpr basic_string_view<Char>& basic_string_view<Char>::operator=(const basic_string_view& s)noexcept{
|
|
||||||
m_data = s.m_data;
|
|
||||||
m_length = s.m_length;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
template<class Char>
|
|
||||||
constexpr basic_string_view<Char>::basic_string_view(const_pointer c)noexcept:
|
|
||||||
basic_string_view(c, strlen(c)){}
|
|
||||||
template<class Char>
|
|
||||||
constexpr basic_string_view<Char>& basic_string_view<Char>::operator=(const_pointer c)noexcept{
|
|
||||||
m_data = c;
|
|
||||||
m_length = strlen(c);
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
template<class Char>
|
|
||||||
constexpr basic_string_view<Char>& basic_string_view<Char>::operator=(basic_string_view&& s)noexcept{
|
|
||||||
m_data = s.m_data;
|
|
||||||
m_length = s.m_length;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
} //namespace rexy
|
} //namespace rexy
|
||||||
|
|
||||||
#undef STOP_STRICT_ALIAS_WARNING
|
#undef STOP_STRICT_ALIAS_WARNING
|
||||||
|
|||||||
131
include/rexy/string_view.hpp
Normal file
131
include/rexy/string_view.hpp
Normal file
@ -0,0 +1,131 @@
|
|||||||
|
/**
|
||||||
|
This file is a part of rexy's general purpose library
|
||||||
|
Copyright (C) 2020-2022 rexy712
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef REXY_STRING_VIEW_HPP
|
||||||
|
#define REXY_STRING_VIEW_HPP
|
||||||
|
|
||||||
|
#include <cstddef> //size_t, ptrdiff_t
|
||||||
|
#include <iterator> //reverse_iterator
|
||||||
|
|
||||||
|
#include "compat/constexpr.hpp"
|
||||||
|
|
||||||
|
namespace rexy{
|
||||||
|
|
||||||
|
template<class Char>
|
||||||
|
class string_base;
|
||||||
|
|
||||||
|
template<class Char>
|
||||||
|
class basic_string_view
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
using value_type = Char;
|
||||||
|
using size_type = size_t;
|
||||||
|
using difference_type = ptrdiff_t;
|
||||||
|
using pointer = value_type*;
|
||||||
|
using const_pointer = const value_type*;
|
||||||
|
using reference = value_type&;
|
||||||
|
using const_reference = const value_type&;
|
||||||
|
using iterator = pointer;
|
||||||
|
using const_iterator = const_pointer;
|
||||||
|
using reverse_iterator = std::reverse_iterator<iterator>;
|
||||||
|
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
|
||||||
|
|
||||||
|
private:
|
||||||
|
const_pointer m_data = nullptr;
|
||||||
|
size_type m_length = 0;
|
||||||
|
|
||||||
|
public:
|
||||||
|
constexpr basic_string_view(void)noexcept;
|
||||||
|
constexpr basic_string_view(const_pointer str, size_type len)noexcept;
|
||||||
|
constexpr basic_string_view(const_pointer c)noexcept;
|
||||||
|
constexpr basic_string_view(const basic_string_view& s)noexcept;
|
||||||
|
constexpr basic_string_view(const string_base<Char>& s)noexcept;
|
||||||
|
constexpr basic_string_view(basic_string_view&& s)noexcept;
|
||||||
|
template<class InIter>
|
||||||
|
constexpr basic_string_view(InIter start, InIter fin)noexcept;
|
||||||
|
REXY_CPP20_CONSTEXPR ~basic_string_view(void)noexcept = default;
|
||||||
|
|
||||||
|
constexpr basic_string_view& operator=(const_pointer c)noexcept;
|
||||||
|
constexpr basic_string_view& operator=(const basic_string_view& s)noexcept;
|
||||||
|
constexpr basic_string_view& operator=(basic_string_view&&)noexcept;
|
||||||
|
|
||||||
|
|
||||||
|
//Length of string not including null terminator
|
||||||
|
constexpr size_type length(void)const noexcept{return m_length;}
|
||||||
|
//direct access to managed pointer
|
||||||
|
constexpr const_pointer c_str(void)const noexcept{return m_data;}
|
||||||
|
constexpr const_pointer get(void)const noexcept{return m_data;}
|
||||||
|
constexpr operator const_pointer(void)const noexcept{return m_data;}
|
||||||
|
//true if m_data is not empty
|
||||||
|
constexpr bool valid(void)const noexcept{return m_length > 0;}
|
||||||
|
|
||||||
|
constexpr const_reference operator[](size_type i)const noexcept{return m_data[i];}
|
||||||
|
|
||||||
|
constexpr const_iterator search(const basic_string_view& s)const;
|
||||||
|
constexpr const_iterator search(const_pointer c)const;
|
||||||
|
template<class Searcher>
|
||||||
|
constexpr const_iterator search(const basic_string_view& s, const Searcher& searcher)const;
|
||||||
|
template<class Searcher>
|
||||||
|
constexpr const_iterator search(const_pointer c, const Searcher& searcher)const;
|
||||||
|
constexpr bool compare(const basic_string_view& s)const{return *this == s;}
|
||||||
|
constexpr bool compare(const_pointer c)const{return *this == c;}
|
||||||
|
|
||||||
|
constexpr const_iterator begin(void)const{return m_data;}
|
||||||
|
constexpr const_iterator end(void)const{return m_data+m_length;}
|
||||||
|
constexpr const_iterator cbegin(void)const{return begin();}
|
||||||
|
constexpr const_iterator cend(void)const{return end();}
|
||||||
|
|
||||||
|
constexpr const_reverse_iterator rbegin(void)const{return const_reverse_iterator(m_data+m_length);}
|
||||||
|
constexpr const_reverse_iterator rend(void)const{return const_reverse_iterator(m_data-1);}
|
||||||
|
constexpr const_reverse_iterator crbegin(void)const{return rbegin();}
|
||||||
|
constexpr const_reverse_iterator crend(void)const{return rend();}
|
||||||
|
};
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
basic_string_view(const T*) -> basic_string_view<T>;
|
||||||
|
template<class T>
|
||||||
|
basic_string_view(const T*, size_t) -> basic_string_view<T>;
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
using static_string [[deprecated]] = basic_string_view<T>;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace{
|
||||||
|
|
||||||
|
constexpr inline rexy::basic_string_view<char> operator"" _sv(const char* str, size_t len)noexcept{
|
||||||
|
return rexy::basic_string_view(str, len);
|
||||||
|
}
|
||||||
|
constexpr inline rexy::basic_string_view<wchar_t> operator"" _sv(const wchar_t* str, size_t len)noexcept{
|
||||||
|
return rexy::basic_string_view(str, len);
|
||||||
|
}
|
||||||
|
constexpr inline rexy::basic_string_view<char16_t> operator"" _sv(const char16_t* str, size_t len)noexcept{
|
||||||
|
return rexy::basic_string_view(str, len);
|
||||||
|
}
|
||||||
|
constexpr inline rexy::basic_string_view<char32_t> operator"" _sv(const char32_t* str, size_t len)noexcept{
|
||||||
|
return rexy::basic_string_view(str, len);
|
||||||
|
}
|
||||||
|
template<class Char>
|
||||||
|
std::ostream& operator<<(std::ostream& os, const rexy::basic_string_view<Char>& str){
|
||||||
|
return os << str.c_str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "string_view.tpp"
|
||||||
|
|
||||||
|
#endif
|
||||||
73
include/rexy/string_view.tpp
Normal file
73
include/rexy/string_view.tpp
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
/**
|
||||||
|
This file is a part of rexy's general purpose library
|
||||||
|
Copyright (C) 2020-2022 rexy712
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef REXY_STRING_VIEW_TPP
|
||||||
|
#define REXY_STRING_VIEW_TPP
|
||||||
|
|
||||||
|
#include "compat/to_address.hpp"
|
||||||
|
#include "utility.hpp"
|
||||||
|
#include "string_base.hpp"
|
||||||
|
|
||||||
|
namespace rexy{
|
||||||
|
|
||||||
|
template<class Char>
|
||||||
|
constexpr basic_string_view<Char>::basic_string_view(void)noexcept:
|
||||||
|
basic_string_view(nullptr, 0){}
|
||||||
|
|
||||||
|
template<class Char>
|
||||||
|
constexpr basic_string_view<Char>::basic_string_view(const_pointer str, size_type len)noexcept:
|
||||||
|
m_data(str), m_length(len){}
|
||||||
|
template<class Char>
|
||||||
|
constexpr basic_string_view<Char>::basic_string_view(const basic_string_view& s)noexcept:
|
||||||
|
m_data(s.m_data), m_length(s.m_length){}
|
||||||
|
template<class Char>
|
||||||
|
constexpr basic_string_view<Char>::basic_string_view(const string_base<Char>& s)noexcept:
|
||||||
|
m_data(s.c_str()), m_length(s.length()){}
|
||||||
|
template<class Char>
|
||||||
|
constexpr basic_string_view<Char>::basic_string_view(basic_string_view&& s)noexcept:
|
||||||
|
m_data(s.m_data), m_length(s.m_length){}
|
||||||
|
template<class Char>
|
||||||
|
template<class InIter>
|
||||||
|
constexpr basic_string_view<Char>::basic_string_view(InIter start, InIter fin)noexcept:
|
||||||
|
basic_string_view(compat::to_address(start), fin - start){}
|
||||||
|
|
||||||
|
template<class Char>
|
||||||
|
constexpr basic_string_view<Char>& basic_string_view<Char>::operator=(const basic_string_view& s)noexcept{
|
||||||
|
m_data = s.m_data;
|
||||||
|
m_length = s.m_length;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
template<class Char>
|
||||||
|
constexpr basic_string_view<Char>::basic_string_view(const_pointer c)noexcept:
|
||||||
|
basic_string_view(c, strlen(c)){}
|
||||||
|
template<class Char>
|
||||||
|
constexpr basic_string_view<Char>& basic_string_view<Char>::operator=(const_pointer c)noexcept{
|
||||||
|
m_data = c;
|
||||||
|
m_length = strlen(c);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
template<class Char>
|
||||||
|
constexpr basic_string_view<Char>& basic_string_view<Char>::operator=(basic_string_view&& s)noexcept{
|
||||||
|
m_data = s.m_data;
|
||||||
|
m_length = s.m_length;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
This file is a part of rexy's general purpose library
|
This file is a part of rexy's general purpose library
|
||||||
Copyright (C) 2020 rexy712
|
Copyright (C) 2020-2022 rexy712
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
@ -16,8 +16,8 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef REXY_STATIC_STRING_HASH_HPP
|
#ifndef REXY_STRING_VIEW_HASH_HPP
|
||||||
#define REXY_STATIC_STRING_HASH_HPP
|
#define REXY_STRING_VIEW_HASH_HPP
|
||||||
|
|
||||||
#include "string_hash.hpp"
|
#include "string_hash.hpp"
|
||||||
#include "string_base.hpp"
|
#include "string_base.hpp"
|
||||||
@ -2,9 +2,6 @@
|
|||||||
|
|
||||||
#include "rexy/algorithm.hpp"
|
#include "rexy/algorithm.hpp"
|
||||||
#include "rexy/allocator.hpp"
|
#include "rexy/allocator.hpp"
|
||||||
#include "rexy/binary.hpp"
|
|
||||||
#include "rexy/binary_base.hpp"
|
|
||||||
#include "rexy/binary_base.tpp"
|
|
||||||
#include "rexy/buffer.hpp"
|
#include "rexy/buffer.hpp"
|
||||||
#include "rexy/buffer.tpp"
|
#include "rexy/buffer.tpp"
|
||||||
#include "rexy/expression.hpp"
|
#include "rexy/expression.hpp"
|
||||||
@ -25,8 +22,9 @@
|
|||||||
#include "rexy/debug_print.hpp"
|
#include "rexy/debug_print.hpp"
|
||||||
#include "rexy/storage_for.hpp"
|
#include "rexy/storage_for.hpp"
|
||||||
#include "rexy/visitor.hpp"
|
#include "rexy/visitor.hpp"
|
||||||
|
#include "rexy/string_view.hpp"
|
||||||
|
#include "rexy/string_view.tpp"
|
||||||
|
|
||||||
#include "rexy/detail/binary_string_conv.hpp"
|
|
||||||
#include "rexy/detail/string_appender.hpp"
|
#include "rexy/detail/string_appender.hpp"
|
||||||
|
|
||||||
#include "rexy/cx/array.hpp"
|
#include "rexy/cx/array.hpp"
|
||||||
|
|||||||
@ -94,13 +94,12 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
rexy::binary filerd::read_bin(size_t bytes)
|
rexy::buffer<char> filerd::read_bin(size_t bytes)
|
||||||
noexcept(std::is_nothrow_constructible<rexy::binary, rexy::steal<char*>, size_t, size_t>::value)
|
noexcept(std::is_nothrow_constructible<rexy::buffer<char>, char*, size_t>::value)
|
||||||
{
|
{
|
||||||
rexy::binary ret;
|
rexy::buffer<char> ret{bytes};
|
||||||
char* tmp = ret.allocator().allocate(bytes);
|
size_t written = read(ret.data(), bytes);
|
||||||
size_t written = read(tmp, bytes);
|
ret.set_size(written);
|
||||||
ret.reset(tmp, written);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
size_t filerd::write(const char* c, size_t bytes)noexcept{
|
size_t filerd::write(const char* c, size_t bytes)noexcept{
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "rexy/string_base.hpp"
|
#include "rexy/string_view.hpp"
|
||||||
|
|
||||||
namespace rexy{
|
namespace rexy{
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user