18#ifndef PacketUtilities_h__
19#define PacketUtilities_h__
23#include <short_alloc/short_alloc.h>
60 template<std::
size_t MaxBytesWithoutNullTerminator>
75 std::tuple<Strings::ByteSize<MaxBytesWithoutNullTerminator>,
Validators...>>;
81 operator std::string_view()
const {
return _storage; }
83 operator std::string
const&()
const {
return _storage; }
97 return ValidateNth(std::make_index_sequence<std::tuple_size_v<ValidatorList>>{});
100 template<std::size_t...
indexes>
103 return (std::tuple_element_t<indexes, ValidatorList>::Validate(
_storage) && ...);
118 template<
typename T, std::
size_t N>
122 using allocator_type = short_alloc::short_alloc<T, (N *
sizeof(T) + (
alignof(std::max_align_t) - 1)) & ~(
alignof(std::max_align_t) - 1)>;
131 using pointer =
typename storage_type::pointer;
142 for (T
const& element :
other)
154 for (T
const& element :
other)
179 if (
newSize > max_capacity::value)
187 if (
_storage.size() >= max_capacity::value)
195 if (
_storage.size() >= max_capacity::value)
198 _storage.push_back(std::forward<value_type>(value));
201 template<
typename...
Args>
204 _storage.emplace_back(std::forward<Args>(args)...);
std::string ReadCString(bool requireValidUtf8=true)
typename storage_type::iterator iterator
short_alloc::short_alloc< T,(N *sizeof(T)+(alignof(std::max_align_t) - 1)) &~(alignof(std::max_align_t) - 1)> allocator_type
const_pointer data() const
iterator erase(const_iterator first, const_iterator last)
T & emplace_back(Args &&... args)
Array & operator=(Array &&other) noexcept=delete
std::vector< T, allocator_type > storage_type
typename storage_type::const_pointer const_pointer
typename storage_type::const_reference const_reference
void push_back(value_type const &value)
const_iterator end() const
typename storage_type::reference reference
typename storage_type::size_type size_type
Array & operator=(Array const &other)
typename storage_type::value_type value_type
const_reference operator[](size_type i) const
void push_back(value_type &&value)
Array(Array &&other) noexcept=delete
typename storage_type::const_iterator const_iterator
typename storage_type::pointer pointer
std::integral_constant< std::size_t, N > max_capacity
typename allocator_type::arena_type arena_type
reference operator[](size_type i)
const_iterator begin() const
void resize(size_type newSize)
Array(Array const &other)
std::string const & GetInvalidValue() const
char const * c_str() const
std::conditional_t<!Trinity::has_type< Strings::RawBytes, std::tuple< Validators... > >::value, std::tuple< Strings::ByteSize< MaxBytesWithoutNullTerminator >, Strings::Utf8, Validators... >, std::tuple< Strings::ByteSize< MaxBytesWithoutNullTerminator >, Validators... > > ValidatorList
friend ByteBuffer & operator>>(ByteBuffer &data, String &value)
bool ValidateNth(std::index_sequence< indexes... >) const
static bool Validate(std::string const &value)
static bool Validate(std::string const &value)
static bool Validate(std::string const &value)
static bool Validate(std::string const &)
static bool Validate(std::string const &value)