Change naming convention for template impl of standard class
This commit is contained in:
parent
c83d2ce686
commit
f4aa7f8564
@ -24,9 +24,9 @@
|
|||||||
|
|
||||||
namespace rexy{
|
namespace rexy{
|
||||||
|
|
||||||
using binary = binary_data<detail::default_allocator<>>;
|
using binary = basic_binary<detail::default_allocator<>>;
|
||||||
|
|
||||||
extern template class binary_data<detail::default_allocator<>>;
|
extern template class basic_binary<detail::default_allocator<>>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -61,31 +61,31 @@ namespace rexy{
|
|||||||
|
|
||||||
};
|
};
|
||||||
template<class Allocator = detail::default_allocator<>>
|
template<class Allocator = detail::default_allocator<>>
|
||||||
class binary_data : public binary_base
|
class basic_binary : public binary_base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using allocator_type = Allocator;
|
using allocator_type = Allocator;
|
||||||
public:
|
public:
|
||||||
constexpr binary_data(void)noexcept;
|
constexpr basic_binary(void)noexcept;
|
||||||
constexpr binary_data(rexy::steal<char*> data, size_t size)noexcept;
|
constexpr basic_binary(rexy::steal<char*> data, size_t size)noexcept;
|
||||||
constexpr binary_data(rexy::steal<char*> data, size_t cap, size_t size)noexcept;
|
constexpr basic_binary(rexy::steal<char*> data, size_t cap, size_t size)noexcept;
|
||||||
constexpr binary_data(rexy::steal<char*> data)noexcept;
|
constexpr basic_binary(rexy::steal<char*> data)noexcept;
|
||||||
binary_data(const char* data, size_t size)noexcept(noexcept(Allocator::copy(data, size)));
|
basic_binary(const char* data, size_t size)noexcept(noexcept(Allocator::copy(data, size)));
|
||||||
binary_data(const char* data)noexcept(noexcept(Allocator::copy(data, 0)));
|
basic_binary(const char* data)noexcept(noexcept(Allocator::copy(data, 0)));
|
||||||
binary_data(const char* data, size_t size, size_t cap)noexcept(noexcept(Allocator::copy(data, size)));
|
basic_binary(const char* data, size_t size, size_t cap)noexcept(noexcept(Allocator::copy(data, size)));
|
||||||
explicit binary_data(size_t size)noexcept(noexcept(Allocator::allocate(size)));
|
explicit basic_binary(size_t size)noexcept(noexcept(Allocator::allocate(size)));
|
||||||
binary_data(size_t size, size_t cap)noexcept(noexcept(Allocator::allocate(size)));
|
basic_binary(size_t size, size_t cap)noexcept(noexcept(Allocator::allocate(size)));
|
||||||
|
|
||||||
binary_data(const binary_data& b)noexcept(noexcept(Allocator::copy(b.m_data, b.m_cap)));
|
basic_binary(const basic_binary& b)noexcept(noexcept(Allocator::copy(b.m_data, b.m_cap)));
|
||||||
constexpr binary_data(binary_data&& b)noexcept;
|
constexpr basic_binary(basic_binary&& b)noexcept;
|
||||||
binary_data(const binary_base& b)noexcept(noexcept(Allocator::copy(b.get(),b.size())));
|
basic_binary(const binary_base& b)noexcept(noexcept(Allocator::copy(b.get(),b.size())));
|
||||||
|
|
||||||
~binary_data(void)noexcept(noexcept(Allocator::free(m_data)));
|
~basic_binary(void)noexcept(noexcept(Allocator::free(m_data)));
|
||||||
|
|
||||||
binary_data& operator=(const binary_data& b)noexcept(noexcept(Allocator::copy(b.m_data, b.m_size)));
|
basic_binary& operator=(const basic_binary& b)noexcept(noexcept(Allocator::copy(b.m_data, b.m_size)));
|
||||||
constexpr binary_data& operator=(binary_data&& b)noexcept;
|
constexpr basic_binary& operator=(basic_binary&& b)noexcept;
|
||||||
binary_data& operator=(const char* c)noexcept(noexcept(Allocator::copy(c, 0)));
|
basic_binary& operator=(const char* c)noexcept(noexcept(Allocator::copy(c, 0)));
|
||||||
binary_data& operator=(const binary_base& b)noexcept(noexcept(Allocator::copy(b.get(), b.size())));
|
basic_binary& operator=(const binary_base& b)noexcept(noexcept(Allocator::copy(b.get(), b.size())));
|
||||||
|
|
||||||
void reset(void)
|
void reset(void)
|
||||||
noexcept(noexcept(Allocator::free(m_data)));
|
noexcept(noexcept(Allocator::free(m_data)));
|
||||||
@ -98,7 +98,7 @@ namespace rexy{
|
|||||||
noexcept(noexcept(Allocator::allocate(0)) &&
|
noexcept(noexcept(Allocator::allocate(0)) &&
|
||||||
noexcept(Allocator::free(nullptr)));
|
noexcept(Allocator::free(nullptr)));
|
||||||
private:
|
private:
|
||||||
binary_data& _copy_data(const char* data, size_t len)
|
basic_binary& _copy_data(const char* data, size_t len)
|
||||||
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
|
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
|
||||||
noexcept(Allocator::free(nullptr)));
|
noexcept(Allocator::free(nullptr)));
|
||||||
};
|
};
|
||||||
@ -115,9 +115,9 @@ namespace rexy{
|
|||||||
constexpr size_t size(void)const noexcept;
|
constexpr size_t size(void)const noexcept;
|
||||||
|
|
||||||
template<class Alloc>
|
template<class Alloc>
|
||||||
operator binary_data<Alloc>(void)
|
operator basic_binary<Alloc>(void)
|
||||||
noexcept(std::is_nothrow_constructible<binary_data<Alloc>, size_t>::value &&
|
noexcept(std::is_nothrow_constructible<basic_binary<Alloc>, size_t>::value &&
|
||||||
std::is_nothrow_invocable<detail::string_appender<binary_data<Alloc>>,decltype(*this)>::value);
|
std::is_nothrow_invocable<detail::string_appender<basic_binary<Alloc>>,decltype(*this)>::value);
|
||||||
};
|
};
|
||||||
|
|
||||||
class static_binary : public binary_base
|
class static_binary : public binary_base
|
||||||
|
|||||||
@ -70,84 +70,84 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
constexpr binary_data<Allocator>::binary_data(void)noexcept{}
|
constexpr basic_binary<Allocator>::basic_binary(void)noexcept{}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
constexpr binary_data<Allocator>::binary_data(rexy::steal<char*> data)noexcept:
|
constexpr basic_binary<Allocator>::basic_binary(rexy::steal<char*> data)noexcept:
|
||||||
binary_base(data.value() ? cx::strlen(data.value()) : 0)
|
binary_base(data.value() ? cx::strlen(data.value()) : 0)
|
||||||
{
|
{
|
||||||
m_data = data.value();
|
m_data = data.value();
|
||||||
m_size = m_cap;
|
m_size = m_cap;
|
||||||
}
|
}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
constexpr binary_data<Allocator>::binary_data(rexy::steal<char*> data, size_t size)noexcept:
|
constexpr basic_binary<Allocator>::basic_binary(rexy::steal<char*> data, size_t size)noexcept:
|
||||||
binary_base(data.value(), size){}
|
binary_base(data.value(), size){}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
constexpr binary_data<Allocator>::binary_data(rexy::steal<char*> data, size_t cap, size_t size)noexcept:
|
constexpr basic_binary<Allocator>::basic_binary(rexy::steal<char*> data, size_t cap, size_t size)noexcept:
|
||||||
binary_base(data.value(), cap, size){}
|
binary_base(data.value(), cap, size){}
|
||||||
|
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
binary_data<Allocator>::binary_data(const char* data, size_t size)
|
basic_binary<Allocator>::basic_binary(const char* data, size_t size)
|
||||||
noexcept(noexcept(Allocator::copy(data, size))):
|
noexcept(noexcept(Allocator::copy(data, size))):
|
||||||
binary_base(reinterpret_cast<char*>(Allocator::copy(data, size)), size){}
|
binary_base(reinterpret_cast<char*>(Allocator::copy(data, size)), size){}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
binary_data<Allocator>::binary_data(const char* data)
|
basic_binary<Allocator>::basic_binary(const char* data)
|
||||||
noexcept(noexcept(Allocator::copy(data, 0))):
|
noexcept(noexcept(Allocator::copy(data, 0))):
|
||||||
binary_data(data, cx::strlen(data)){}
|
basic_binary(data, cx::strlen(data)){}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
binary_data<Allocator>::binary_data(const char* data, size_t size, size_t cap)
|
basic_binary<Allocator>::basic_binary(const char* data, size_t size, size_t cap)
|
||||||
noexcept(noexcept(Allocator::copy(data, size))):
|
noexcept(noexcept(Allocator::copy(data, size))):
|
||||||
binary_base(reinterpret_cast<char*>(Allocator::copy(data, size)), size, cap){}
|
binary_base(reinterpret_cast<char*>(Allocator::copy(data, size)), size, cap){}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
binary_data<Allocator>::binary_data(size_t size)
|
basic_binary<Allocator>::basic_binary(size_t size)
|
||||||
noexcept(noexcept(Allocator::allocate(size))):
|
noexcept(noexcept(Allocator::allocate(size))):
|
||||||
binary_base(reinterpret_cast<char*>(Allocator::allocate(size)), size){}
|
binary_base(reinterpret_cast<char*>(Allocator::allocate(size)), size){}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
binary_data<Allocator>::binary_data(size_t size, size_t cap)
|
basic_binary<Allocator>::basic_binary(size_t size, size_t cap)
|
||||||
noexcept(noexcept(Allocator::allocate(size))):
|
noexcept(noexcept(Allocator::allocate(size))):
|
||||||
binary_base(reinterpret_cast<char*>(size ? Allocator::allocate(size) : nullptr), size, cap){}
|
binary_base(reinterpret_cast<char*>(size ? Allocator::allocate(size) : nullptr), size, cap){}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
binary_data<Allocator>::binary_data(const binary_data& b)
|
basic_binary<Allocator>::basic_binary(const basic_binary& b)
|
||||||
noexcept(noexcept(Allocator::copy(b.m_data, b.m_cap))):
|
noexcept(noexcept(Allocator::copy(b.m_data, b.m_cap))):
|
||||||
binary_base(reinterpret_cast<char*>(b.m_size ? Allocator::copy(b.m_data, b.m_size) : nullptr), b.m_size, b.m_size){}
|
binary_base(reinterpret_cast<char*>(b.m_size ? Allocator::copy(b.m_data, b.m_size) : nullptr), b.m_size, b.m_size){}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
constexpr binary_data<Allocator>::binary_data(binary_data&& b)noexcept:
|
constexpr basic_binary<Allocator>::basic_binary(basic_binary&& b)noexcept:
|
||||||
binary_base(cx::exchange(b.m_data, nullptr), b.m_size, b.m_cap){}
|
binary_base(cx::exchange(b.m_data, nullptr), b.m_size, b.m_cap){}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
binary_data<Allocator>::binary_data(const binary_base& b)noexcept(noexcept(Allocator::copy(b.get(),b.size()))):
|
basic_binary<Allocator>::basic_binary(const binary_base& b)noexcept(noexcept(Allocator::copy(b.get(),b.size()))):
|
||||||
binary_base(reinterpret_cast<char*>(b.size() ? Allocator::copy(b.get(), b.size()) : nullptr), b.size(), b.size()){}
|
binary_base(reinterpret_cast<char*>(b.size() ? Allocator::copy(b.get(), b.size()) : nullptr), b.size(), b.size()){}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
binary_data<Allocator>::~binary_data(void)
|
basic_binary<Allocator>::~basic_binary(void)
|
||||||
noexcept(noexcept(Allocator::free(m_data)))
|
noexcept(noexcept(Allocator::free(m_data)))
|
||||||
{
|
{
|
||||||
Allocator::free(m_data);
|
Allocator::free(m_data);
|
||||||
}
|
}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
binary_data<Allocator>& binary_data<Allocator>::operator=(const binary_data& b)
|
basic_binary<Allocator>& basic_binary<Allocator>::operator=(const basic_binary& b)
|
||||||
noexcept(noexcept(Allocator::copy(b.m_data, b.m_size)))
|
noexcept(noexcept(Allocator::copy(b.m_data, b.m_size)))
|
||||||
{
|
{
|
||||||
return _copy_data(b.get(), b.size());
|
return _copy_data(b.get(), b.size());
|
||||||
}
|
}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
constexpr binary_data<Allocator>& binary_data<Allocator>::operator=(binary_data&& b)noexcept{
|
constexpr basic_binary<Allocator>& basic_binary<Allocator>::operator=(basic_binary&& b)noexcept{
|
||||||
m_size = b.m_size;
|
m_size = b.m_size;
|
||||||
m_cap = b.m_cap;
|
m_cap = b.m_cap;
|
||||||
cx::swap(m_data, b.m_data);
|
cx::swap(m_data, b.m_data);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
binary_data<Allocator>& binary_data<Allocator>::operator=(const char* c)
|
basic_binary<Allocator>& basic_binary<Allocator>::operator=(const char* c)
|
||||||
noexcept(noexcept(Allocator::copy(c, 0)))
|
noexcept(noexcept(Allocator::copy(c, 0)))
|
||||||
{
|
{
|
||||||
return _copy_data(c, strlen(c));
|
return _copy_data(c, strlen(c));
|
||||||
}
|
}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
binary_data<Allocator>& binary_data<Allocator>::operator=(const binary_base& b)
|
basic_binary<Allocator>& basic_binary<Allocator>::operator=(const binary_base& b)
|
||||||
noexcept(noexcept(Allocator::copy(b.get(), b.size())))
|
noexcept(noexcept(Allocator::copy(b.get(), b.size())))
|
||||||
{
|
{
|
||||||
return _copy_data(b.get(), b.size());
|
return _copy_data(b.get(), b.size());
|
||||||
}
|
}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
void binary_data<Allocator>::reset(void)
|
void basic_binary<Allocator>::reset(void)
|
||||||
noexcept(noexcept(Allocator::free(m_data)))
|
noexcept(noexcept(Allocator::free(m_data)))
|
||||||
{
|
{
|
||||||
Allocator::free(m_data);
|
Allocator::free(m_data);
|
||||||
@ -155,7 +155,7 @@ namespace rexy{
|
|||||||
m_cap = m_size = 0;
|
m_cap = m_size = 0;
|
||||||
}
|
}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
void binary_data<Allocator>::reset(char* val, size_t cap, size_t size)
|
void basic_binary<Allocator>::reset(char* val, size_t cap, size_t size)
|
||||||
noexcept(noexcept(Allocator::free(m_data)))
|
noexcept(noexcept(Allocator::free(m_data)))
|
||||||
{
|
{
|
||||||
Allocator::free(m_data);
|
Allocator::free(m_data);
|
||||||
@ -164,13 +164,13 @@ namespace rexy{
|
|||||||
m_size = size;
|
m_size = size;
|
||||||
}
|
}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
bool binary_data<Allocator>::resize(size_t newsize)
|
bool basic_binary<Allocator>::resize(size_t newsize)
|
||||||
noexcept(noexcept(Allocator::allocate(0)) &&
|
noexcept(noexcept(Allocator::allocate(0)) &&
|
||||||
noexcept(Allocator::free(nullptr)))
|
noexcept(Allocator::free(nullptr)))
|
||||||
{
|
{
|
||||||
if(newsize < m_cap)
|
if(newsize < m_cap)
|
||||||
return false;
|
return false;
|
||||||
binary_data<allocator_type> tmp(newsize);
|
basic_binary<allocator_type> tmp(newsize);
|
||||||
if(!tmp)
|
if(!tmp)
|
||||||
return false;
|
return false;
|
||||||
memcpy(STOP_STRICT_ALIAS_WARNING(tmp).m_data, m_data, m_size);
|
memcpy(STOP_STRICT_ALIAS_WARNING(tmp).m_data, m_data, m_size);
|
||||||
@ -179,7 +179,7 @@ namespace rexy{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
void binary_data<Allocator>::append(const char* data, size_t len)
|
void basic_binary<Allocator>::append(const char* data, size_t len)
|
||||||
noexcept(noexcept(Allocator::allocate(0)) &&
|
noexcept(noexcept(Allocator::allocate(0)) &&
|
||||||
noexcept(Allocator::free(nullptr)))
|
noexcept(Allocator::free(nullptr)))
|
||||||
{
|
{
|
||||||
@ -189,18 +189,18 @@ namespace rexy{
|
|||||||
m_size += len;
|
m_size += len;
|
||||||
}
|
}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
binary_data<Allocator>& binary_data<Allocator>::_copy_data(const char* data, size_t len)
|
basic_binary<Allocator>& basic_binary<Allocator>::_copy_data(const char* data, size_t len)
|
||||||
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
|
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
|
||||||
noexcept(Allocator::free(nullptr)))
|
noexcept(Allocator::free(nullptr)))
|
||||||
{
|
{
|
||||||
if(!len)
|
if(!len)
|
||||||
return (*this = binary_data(rexy::steal<char*>(nullptr), 0, 0));
|
return (*this = basic_binary(rexy::steal<char*>(nullptr), 0, 0));
|
||||||
if(len <= m_size){
|
if(len <= m_size){
|
||||||
m_size = len;
|
m_size = len;
|
||||||
memcpy(m_data, data, len);
|
memcpy(m_data, data, len);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
return (*this = binary_data(data, len));
|
return (*this = basic_binary(data, len));
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr static_binary::static_binary(const char* str, size_t len)noexcept:
|
constexpr static_binary::static_binary(const char* str, size_t len)noexcept:
|
||||||
@ -238,14 +238,14 @@ namespace rexy{
|
|||||||
|
|
||||||
template<class Left, class Right>
|
template<class Left, class Right>
|
||||||
template<class Alloc>
|
template<class Alloc>
|
||||||
binary_cat_expr<Left,Right>::operator binary_data<Alloc>(void)
|
binary_cat_expr<Left,Right>::operator basic_binary<Alloc>(void)
|
||||||
noexcept(std::is_nothrow_constructible<binary_data<Alloc>, size_t>::value &&
|
noexcept(std::is_nothrow_constructible<basic_binary<Alloc>, size_t>::value &&
|
||||||
std::is_nothrow_invocable<detail::string_appender<binary_data<Alloc>>,decltype(*this)>::value)
|
std::is_nothrow_invocable<detail::string_appender<basic_binary<Alloc>>,decltype(*this)>::value)
|
||||||
{
|
{
|
||||||
auto sz = size();
|
auto sz = size();
|
||||||
binary_data<Alloc> ret(sz);
|
basic_binary<Alloc> ret(sz);
|
||||||
|
|
||||||
detail::string_appender<binary_data<Alloc>> append(ret);
|
detail::string_appender<basic_binary<Alloc>> append(ret);
|
||||||
|
|
||||||
append(*this);
|
append(*this);
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@ -33,7 +33,7 @@ namespace rexy{
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
template<class Al, class Str, detail::enable_if_concrete_string<Str> = 0, std::enable_if_t<std::is_same<std::decay_t<Al>,typename Str::allocator_type>::value,int> = 0>
|
template<class Al, class Str, detail::enable_if_concrete_string<Str> = 0, std::enable_if_t<std::is_same<std::decay_t<Al>,typename Str::allocator_type>::value,int> = 0>
|
||||||
auto binary_to_string(binary_data<Al>&& b)noexcept{
|
auto binary_to_string(basic_binary<Al>&& b)noexcept{
|
||||||
return Str(rexy::steal(b.release()), b.size());
|
return Str(rexy::steal(b.release()), b.size());
|
||||||
}
|
}
|
||||||
template<class Bin, detail::enable_if_binary<Bin> = 0>
|
template<class Bin, detail::enable_if_binary<Bin> = 0>
|
||||||
@ -46,7 +46,7 @@ namespace rexy{
|
|||||||
return b;
|
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>
|
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(string_intermediary<Al>&& s)noexcept{
|
auto string_to_binary(basic_string<Al>&& s)noexcept{
|
||||||
return Bin(rexy::steal(s.release()), s.length());
|
return Bin(rexy::steal(s.release()), s.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -25,9 +25,9 @@
|
|||||||
namespace rexy{
|
namespace rexy{
|
||||||
|
|
||||||
//new allocated string
|
//new allocated string
|
||||||
using string = string_intermediary<detail::default_allocator<>>;
|
using string = basic_string<detail::default_allocator<>>;
|
||||||
|
|
||||||
extern template class string_intermediary<detail::default_allocator<>>;
|
extern template class basic_string<detail::default_allocator<>>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -77,46 +77,46 @@ namespace rexy{
|
|||||||
|
|
||||||
//Supplies all functions that string_base can't implement
|
//Supplies all functions that string_base can't implement
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
class string_intermediary : public string_base
|
class basic_string : public string_base
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
using allocator_type = Allocator;
|
using allocator_type = Allocator;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
string_intermediary& _copy_string(const char* s, size_t len)
|
basic_string& _copy_string(const char* s, size_t len)
|
||||||
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
|
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
|
||||||
noexcept(Allocator::free(nullptr)));
|
noexcept(Allocator::free(nullptr)));
|
||||||
|
|
||||||
public:
|
public:
|
||||||
constexpr string_intermediary(void)noexcept;
|
constexpr basic_string(void)noexcept;
|
||||||
constexpr string_intermediary(rexy::steal<char*> data, size_t len)noexcept;
|
constexpr basic_string(rexy::steal<char*> data, size_t len)noexcept;
|
||||||
constexpr string_intermediary(rexy::steal<char*> data, size_t len, size_t cap)noexcept;
|
constexpr basic_string(rexy::steal<char*> data, size_t len, size_t cap)noexcept;
|
||||||
constexpr string_intermediary(rexy::steal<char*> data)noexcept;
|
constexpr basic_string(rexy::steal<char*> data)noexcept;
|
||||||
string_intermediary(const char* data, size_t len)noexcept(noexcept(Allocator::copy(data,len)));
|
basic_string(const char* data, size_t len)noexcept(noexcept(Allocator::copy(data,len)));
|
||||||
string_intermediary(const char* data)noexcept(noexcept(Allocator::copy(data, m_cap)));
|
basic_string(const char* data)noexcept(noexcept(Allocator::copy(data, m_cap)));
|
||||||
explicit string_intermediary(size_t len)noexcept(noexcept(Allocator::allocate(len)));
|
explicit basic_string(size_t len)noexcept(noexcept(Allocator::allocate(len)));
|
||||||
string_intermediary(size_t len, size_t cap)noexcept(noexcept(Allocator::allocate(len)));
|
basic_string(size_t len, size_t cap)noexcept(noexcept(Allocator::allocate(len)));
|
||||||
|
|
||||||
//normal copy and move ctors
|
//normal copy and move ctors
|
||||||
string_intermediary(const string_intermediary& b)noexcept(noexcept(Allocator::copy(b.m_data, b.m_length)));
|
basic_string(const basic_string& b)noexcept(noexcept(Allocator::copy(b.m_data, b.m_length)));
|
||||||
constexpr string_intermediary(string_intermediary&& s)noexcept(noexcept(cx::exchange(s.m_data, nullptr)));
|
constexpr basic_string(basic_string&& s)noexcept(noexcept(cx::exchange(s.m_data, nullptr)));
|
||||||
|
|
||||||
string_intermediary(const string_base& b)noexcept(noexcept(Allocator::copy(b.get(), b.length())));
|
basic_string(const string_base& b)noexcept(noexcept(Allocator::copy(b.get(), b.length())));
|
||||||
|
|
||||||
//dtor
|
//dtor
|
||||||
~string_intermediary(void)noexcept(noexcept(Allocator::free(m_data)));
|
~basic_string(void)noexcept(noexcept(Allocator::free(m_data)));
|
||||||
|
|
||||||
string_intermediary& operator=(const string_intermediary& s)
|
basic_string& operator=(const basic_string& s)
|
||||||
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
|
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
|
||||||
noexcept(Allocator::free(nullptr)));
|
noexcept(Allocator::free(nullptr)));
|
||||||
|
|
||||||
constexpr string_intermediary& operator=(string_intermediary&& s)noexcept;
|
constexpr basic_string& operator=(basic_string&& s)noexcept;
|
||||||
//Copy from c string
|
//Copy from c string
|
||||||
string_intermediary& operator=(const char* c)
|
basic_string& operator=(const char* c)
|
||||||
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
|
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
|
||||||
noexcept(Allocator::free(nullptr)));
|
noexcept(Allocator::free(nullptr)));
|
||||||
//Copy from other string_base
|
//Copy from other string_base
|
||||||
string_intermediary& operator=(const string_base& s)
|
basic_string& operator=(const string_base& s)
|
||||||
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
|
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
|
||||||
noexcept(Allocator::free(nullptr)));
|
noexcept(Allocator::free(nullptr)));
|
||||||
|
|
||||||
@ -151,9 +151,9 @@ namespace rexy{
|
|||||||
|
|
||||||
constexpr size_t length(void)const noexcept;
|
constexpr size_t length(void)const noexcept;
|
||||||
template<class Alloc>
|
template<class Alloc>
|
||||||
operator string_intermediary<Alloc>(void)
|
operator basic_string<Alloc>(void)
|
||||||
noexcept(std::is_nothrow_constructible<string_intermediary<Alloc>, size_t>::value &&
|
noexcept(std::is_nothrow_constructible<basic_string<Alloc>, size_t>::value &&
|
||||||
std::is_nothrow_invocable<detail::string_appender<string_intermediary<Alloc>>,decltype(*this)>::value);
|
std::is_nothrow_invocable<detail::string_appender<basic_string<Alloc>>,decltype(*this)>::value);
|
||||||
};
|
};
|
||||||
template<class Left, class Right>
|
template<class Left, class Right>
|
||||||
string_cat_expr(Left&&,Right&&) -> string_cat_expr<Left&&,Right&&>;
|
string_cat_expr(Left&&,Right&&) -> string_cat_expr<Left&&,Right&&>;
|
||||||
|
|||||||
@ -31,29 +31,29 @@
|
|||||||
namespace rexy{
|
namespace rexy{
|
||||||
|
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
constexpr string_intermediary<Allocator>::string_intermediary(void)noexcept{}
|
constexpr basic_string<Allocator>::basic_string(void)noexcept{}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
constexpr string_intermediary<Allocator>::string_intermediary(rexy::steal<char*> data)noexcept:
|
constexpr basic_string<Allocator>::basic_string(rexy::steal<char*> data)noexcept:
|
||||||
string_base(data.value() ? cx::strlen(data.value()) : 0)
|
string_base(data.value() ? cx::strlen(data.value()) : 0)
|
||||||
{
|
{
|
||||||
m_data = data.value();
|
m_data = data.value();
|
||||||
m_length = m_cap;
|
m_length = m_cap;
|
||||||
}
|
}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
constexpr string_intermediary<Allocator>::string_intermediary(rexy::steal<char*> data, size_t len)noexcept:
|
constexpr basic_string<Allocator>::basic_string(rexy::steal<char*> data, size_t len)noexcept:
|
||||||
string_base(data.value(), len, len){}
|
string_base(data.value(), len, len){}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
constexpr string_intermediary<Allocator>::string_intermediary(rexy::steal<char*> data, size_t len, size_t cap)noexcept:
|
constexpr basic_string<Allocator>::basic_string(rexy::steal<char*> data, size_t len, size_t cap)noexcept:
|
||||||
string_base(data.value(), len, cap){}
|
string_base(data.value(), len, cap){}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
string_intermediary<Allocator>::string_intermediary(const char* data, size_t len)
|
basic_string<Allocator>::basic_string(const char* data, size_t len)
|
||||||
noexcept(noexcept(Allocator::copy(data,len))):
|
noexcept(noexcept(Allocator::copy(data,len))):
|
||||||
string_base(reinterpret_cast<char*>(len ? Allocator::copy(data, len+1) : nullptr), len, len)
|
string_base(reinterpret_cast<char*>(len ? Allocator::copy(data, len+1) : nullptr), len, len)
|
||||||
{
|
{
|
||||||
m_data[len] = 0;
|
m_data[len] = 0;
|
||||||
}
|
}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
string_intermediary<Allocator>::string_intermediary(const char* data)
|
basic_string<Allocator>::basic_string(const char* data)
|
||||||
noexcept(noexcept(Allocator::copy(data, m_cap))):
|
noexcept(noexcept(Allocator::copy(data, m_cap))):
|
||||||
string_base(data ? strlen(data) : 0)
|
string_base(data ? strlen(data) : 0)
|
||||||
{
|
{
|
||||||
@ -63,14 +63,14 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
string_intermediary<Allocator>::string_intermediary(size_t len)
|
basic_string<Allocator>::basic_string(size_t len)
|
||||||
noexcept(noexcept(Allocator::allocate(len))):
|
noexcept(noexcept(Allocator::allocate(len))):
|
||||||
string_base(reinterpret_cast<char*>(len ? Allocator::allocate(len+1) : nullptr), len)
|
string_base(reinterpret_cast<char*>(len ? Allocator::allocate(len+1) : nullptr), len)
|
||||||
{
|
{
|
||||||
m_data[len] = 0;
|
m_data[len] = 0;
|
||||||
}
|
}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
string_intermediary<Allocator>::string_intermediary(size_t len, size_t cap)
|
basic_string<Allocator>::basic_string(size_t len, size_t cap)
|
||||||
noexcept(noexcept(Allocator::allocate(len))):
|
noexcept(noexcept(Allocator::allocate(len))):
|
||||||
string_base(reinterpret_cast<char*>(len ? Allocator::allocate(len+1) : nullptr), len, cap)
|
string_base(reinterpret_cast<char*>(len ? Allocator::allocate(len+1) : nullptr), len, cap)
|
||||||
{
|
{
|
||||||
@ -79,29 +79,29 @@ namespace rexy{
|
|||||||
|
|
||||||
//normal copy and move ctors
|
//normal copy and move ctors
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
string_intermediary<Allocator>::string_intermediary(const string_intermediary& b)
|
basic_string<Allocator>::basic_string(const basic_string& b)
|
||||||
noexcept(noexcept(Allocator::copy(b.m_data, b.m_length))):
|
noexcept(noexcept(Allocator::copy(b.m_data, b.m_length))):
|
||||||
string_base(reinterpret_cast<char*>(b.m_length ? Allocator::copy(b.m_data, b.m_length+1) : nullptr), b.m_length, b.m_length){}
|
string_base(reinterpret_cast<char*>(b.m_length ? Allocator::copy(b.m_data, b.m_length+1) : nullptr), b.m_length, b.m_length){}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
constexpr string_intermediary<Allocator>::string_intermediary(string_intermediary&& s)
|
constexpr basic_string<Allocator>::basic_string(basic_string&& s)
|
||||||
noexcept(noexcept(cx::exchange(s.m_data, nullptr))):
|
noexcept(noexcept(cx::exchange(s.m_data, nullptr))):
|
||||||
string_base(cx::exchange(s.m_data, nullptr), s.m_length, s.m_cap){}
|
string_base(cx::exchange(s.m_data, nullptr), s.m_length, s.m_cap){}
|
||||||
|
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
string_intermediary<Allocator>::string_intermediary(const string_base& b)
|
basic_string<Allocator>::basic_string(const string_base& b)
|
||||||
noexcept(noexcept(Allocator::copy(b.get(), b.length()))):
|
noexcept(noexcept(Allocator::copy(b.get(), b.length()))):
|
||||||
string_base(reinterpret_cast<char*>(b.length() ? Allocator::copy(b.get(), b.length()+1) : nullptr), b.length(), b.length()){}
|
string_base(reinterpret_cast<char*>(b.length() ? Allocator::copy(b.get(), b.length()+1) : nullptr), b.length(), b.length()){}
|
||||||
|
|
||||||
//dtor
|
//dtor
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
string_intermediary<Allocator>::~string_intermediary(void)
|
basic_string<Allocator>::~basic_string(void)
|
||||||
noexcept(noexcept(Allocator::free(m_data)))
|
noexcept(noexcept(Allocator::free(m_data)))
|
||||||
{
|
{
|
||||||
Allocator::free(m_data);
|
Allocator::free(m_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
string_intermediary<Allocator>& string_intermediary<Allocator>::operator=(const string_intermediary& s)
|
basic_string<Allocator>& basic_string<Allocator>::operator=(const basic_string& s)
|
||||||
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
|
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
|
||||||
noexcept(Allocator::free(nullptr)))
|
noexcept(Allocator::free(nullptr)))
|
||||||
{
|
{
|
||||||
@ -110,11 +110,11 @@ namespace rexy{
|
|||||||
m_length = s.m_length;
|
m_length = s.m_length;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
string_intermediary tmp(s);
|
basic_string tmp(s);
|
||||||
return (*this = std::move(tmp));
|
return (*this = std::move(tmp));
|
||||||
}
|
}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
constexpr string_intermediary<Allocator>& string_intermediary<Allocator>::operator=(string_intermediary&& s)noexcept{
|
constexpr basic_string<Allocator>& basic_string<Allocator>::operator=(basic_string&& s)noexcept{
|
||||||
cx::swap(m_data, s.m_data);
|
cx::swap(m_data, s.m_data);
|
||||||
m_length = s.m_length;
|
m_length = s.m_length;
|
||||||
m_cap = s.m_cap;
|
m_cap = s.m_cap;
|
||||||
@ -122,7 +122,7 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
//Copy from c string
|
//Copy from c string
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
string_intermediary<Allocator>& string_intermediary<Allocator>::operator=(const char* c)
|
basic_string<Allocator>& basic_string<Allocator>::operator=(const char* c)
|
||||||
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
|
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
|
||||||
noexcept(Allocator::free(nullptr)))
|
noexcept(Allocator::free(nullptr)))
|
||||||
{
|
{
|
||||||
@ -130,7 +130,7 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
//Copy from other string_base
|
//Copy from other string_base
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
string_intermediary<Allocator>& string_intermediary<Allocator>::operator=(const string_base& s)
|
basic_string<Allocator>& basic_string<Allocator>::operator=(const string_base& s)
|
||||||
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
|
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
|
||||||
noexcept(Allocator::free(nullptr)))
|
noexcept(Allocator::free(nullptr)))
|
||||||
{
|
{
|
||||||
@ -139,7 +139,7 @@ namespace rexy{
|
|||||||
|
|
||||||
//Replace managed pointer. Frees existing value
|
//Replace managed pointer. Frees existing value
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
void string_intermediary<Allocator>::reset(char* val)
|
void basic_string<Allocator>::reset(char* val)
|
||||||
noexcept(noexcept(Allocator::free(m_data)))
|
noexcept(noexcept(Allocator::free(m_data)))
|
||||||
{
|
{
|
||||||
Allocator::free(m_data);
|
Allocator::free(m_data);
|
||||||
@ -148,7 +148,7 @@ namespace rexy{
|
|||||||
m_cap = m_length;
|
m_cap = m_length;
|
||||||
}
|
}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
void string_intermediary<Allocator>::reset(char* val, size_t len)
|
void basic_string<Allocator>::reset(char* val, size_t len)
|
||||||
noexcept(noexcept(Allocator::free(m_data)))
|
noexcept(noexcept(Allocator::free(m_data)))
|
||||||
{
|
{
|
||||||
Allocator::free(m_data);
|
Allocator::free(m_data);
|
||||||
@ -157,16 +157,16 @@ namespace rexy{
|
|||||||
m_cap = len;
|
m_cap = len;
|
||||||
}
|
}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
bool string_intermediary<Allocator>::resize(size_t newsize)
|
bool basic_string<Allocator>::resize(size_t newsize)
|
||||||
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
|
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
|
||||||
noexcept(Allocator::free(nullptr)))
|
noexcept(Allocator::free(nullptr)))
|
||||||
{
|
{
|
||||||
if(newsize < m_cap)
|
if(newsize < m_cap)
|
||||||
return false;
|
return false;
|
||||||
return (*this = string_intermediary(m_data, newsize));
|
return (*this = basic_string(m_data, newsize));
|
||||||
}
|
}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
void string_intermediary<Allocator>::append(const char* data, size_t len)
|
void basic_string<Allocator>::append(const char* data, size_t len)
|
||||||
noexcept(noexcept(Allocator::allocate(0)) &&
|
noexcept(noexcept(Allocator::allocate(0)) &&
|
||||||
noexcept(Allocator::free(nullptr)))
|
noexcept(Allocator::free(nullptr)))
|
||||||
{
|
{
|
||||||
@ -175,19 +175,19 @@ namespace rexy{
|
|||||||
m_length += len;
|
m_length += len;
|
||||||
m_data[m_length] = 0;
|
m_data[m_length] = 0;
|
||||||
}else if(!m_data){
|
}else if(!m_data){
|
||||||
*this = string_intermediary(len, len);
|
*this = basic_string(len, len);
|
||||||
memcpy(m_data, data, len);
|
memcpy(m_data, data, len);
|
||||||
m_data[len] = 0;
|
m_data[len] = 0;
|
||||||
}else{
|
}else{
|
||||||
auto newsize = cx::max(m_length+len, m_cap*2);
|
auto newsize = cx::max(m_length+len, m_cap*2);
|
||||||
string_intermediary tmp(newsize);
|
basic_string tmp(newsize);
|
||||||
tmp.append(m_data, m_length);
|
tmp.append(m_data, m_length);
|
||||||
tmp.append(data, len);
|
tmp.append(data, len);
|
||||||
*this = std::move(tmp);
|
*this = std::move(tmp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
void string_intermediary<Allocator>::append(const char* data)
|
void basic_string<Allocator>::append(const char* data)
|
||||||
noexcept(noexcept(Allocator::allocate(0)) &&
|
noexcept(noexcept(Allocator::allocate(0)) &&
|
||||||
noexcept(Allocator::free(nullptr)))
|
noexcept(Allocator::free(nullptr)))
|
||||||
{
|
{
|
||||||
@ -195,7 +195,7 @@ namespace rexy{
|
|||||||
append(data, strlen(data));
|
append(data, strlen(data));
|
||||||
}
|
}
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
void string_intermediary<Allocator>::append(const string_base& s)
|
void basic_string<Allocator>::append(const string_base& s)
|
||||||
noexcept(noexcept(Allocator::allocate(0)) &&
|
noexcept(noexcept(Allocator::allocate(0)) &&
|
||||||
noexcept(Allocator::free(nullptr)))
|
noexcept(Allocator::free(nullptr)))
|
||||||
{
|
{
|
||||||
@ -203,19 +203,19 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
|
|
||||||
template<class Allocator>
|
template<class Allocator>
|
||||||
string_intermediary<Allocator>& string_intermediary<Allocator>::_copy_string(const char* s, size_t len)
|
basic_string<Allocator>& basic_string<Allocator>::_copy_string(const char* s, size_t len)
|
||||||
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
|
noexcept(noexcept(Allocator::copy(nullptr,0)) &&
|
||||||
noexcept(Allocator::free(nullptr)))
|
noexcept(Allocator::free(nullptr)))
|
||||||
{
|
{
|
||||||
if(!len)
|
if(!len)
|
||||||
return (*this = string_intermediary(rexy::steal<char*>(nullptr), 0, 0));
|
return (*this = basic_string(rexy::steal<char*>(nullptr), 0, 0));
|
||||||
if(len <= m_length){
|
if(len <= m_length){
|
||||||
m_length = len;
|
m_length = len;
|
||||||
memcpy(m_data, s, len);
|
memcpy(m_data, s, len);
|
||||||
m_data[len] = 0;
|
m_data[len] = 0;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
return (*this = string_intermediary(s, len));
|
return (*this = basic_string(s, len));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -225,13 +225,13 @@ namespace rexy{
|
|||||||
}
|
}
|
||||||
template<class Left, class Right>
|
template<class Left, class Right>
|
||||||
template<class Alloc>
|
template<class Alloc>
|
||||||
string_cat_expr<Left,Right>::operator string_intermediary<Alloc>(void)
|
string_cat_expr<Left,Right>::operator basic_string<Alloc>(void)
|
||||||
noexcept(std::is_nothrow_constructible<string_intermediary<Alloc>, size_t>::value &&
|
noexcept(std::is_nothrow_constructible<basic_string<Alloc>, size_t>::value &&
|
||||||
std::is_nothrow_invocable<detail::string_appender<string_intermediary<Alloc>>,decltype(*this)>::value)
|
std::is_nothrow_invocable<detail::string_appender<basic_string<Alloc>>,decltype(*this)>::value)
|
||||||
{
|
{
|
||||||
size_t len = length();
|
size_t len = length();
|
||||||
string_intermediary<Alloc> ret(len);
|
basic_string<Alloc> ret(len);
|
||||||
detail::string_appender<string_intermediary<Alloc>> append(ret);
|
detail::string_appender<basic_string<Alloc>> append(ret);
|
||||||
append(*this);
|
append(*this);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,6 @@
|
|||||||
|
|
||||||
namespace rexy{
|
namespace rexy{
|
||||||
|
|
||||||
template class binary_data<detail::default_allocator<>>;
|
template class basic_binary<detail::default_allocator<>>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,6 @@
|
|||||||
|
|
||||||
namespace rexy{
|
namespace rexy{
|
||||||
|
|
||||||
template class string_intermediary<detail::default_allocator<>>;
|
template class basic_string<detail::default_allocator<>>;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user