AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
WorldPackets::String< MaxBytesWithoutNullTerminator, Validators > Class Template Reference

#include "PacketUtilities.h"

Public Member Functions

bool empty () const
 
char const * c_str () const
 
 operator std::string_view () const
 
 operator std::string & ()
 
 operator std::string const & () const
 
std::string && Move ()
 

Private Types

using ValidatorList = std::conditional_t<!Acore::has_type< Strings::RawBytes, std::tuple< Validators... > >::value, std::tuple< Strings::ByteSize< MaxBytesWithoutNullTerminator >, Strings::Utf8, Validators... >, std::tuple< Strings::ByteSize< MaxBytesWithoutNullTerminator >, Validators... > >
 

Private Member Functions

bool Validate () const
 
template<std::size_t... indexes>
bool ValidateNth (std::index_sequence< indexes... >) const
 

Private Attributes

std::string _storage
 

Friends

ByteBufferoperator>> (ByteBuffer &data, String &value)
 

Detailed Description

template<std::size_t MaxBytesWithoutNullTerminator, typename... Validators>
class WorldPackets::String< MaxBytesWithoutNullTerminator, Validators >

Utility class for automated prevention of invalid strings in client packets

Member Typedef Documentation

◆ ValidatorList

template<std::size_t MaxBytesWithoutNullTerminator, typename... Validators>
using WorldPackets::String< MaxBytesWithoutNullTerminator, Validators >::ValidatorList = std::conditional_t<!Acore::has_type<Strings::RawBytes, std::tuple<Validators...> >::value, std::tuple<Strings::ByteSize<MaxBytesWithoutNullTerminator>, Strings::Utf8, Validators...>, std::tuple<Strings::ByteSize<MaxBytesWithoutNullTerminator>, Validators...> >
private

Member Function Documentation

◆ c_str()

template<std::size_t MaxBytesWithoutNullTerminator, typename... Validators>
char const * WorldPackets::String< MaxBytesWithoutNullTerminator, Validators >::c_str ( ) const
inline
79{ return _storage.c_str(); }
std::string _storage
Definition: PacketUtilities.h:106

References WorldPackets::String< MaxBytesWithoutNullTerminator, Validators >::_storage.

◆ empty()

template<std::size_t MaxBytesWithoutNullTerminator, typename... Validators>
bool WorldPackets::String< MaxBytesWithoutNullTerminator, Validators >::empty ( ) const
inline

◆ Move()

template<std::size_t MaxBytesWithoutNullTerminator, typename... Validators>
std::string && WorldPackets::String< MaxBytesWithoutNullTerminator, Validators >::Move ( )
inline

◆ operator std::string &()

template<std::size_t MaxBytesWithoutNullTerminator, typename... Validators>
WorldPackets::String< MaxBytesWithoutNullTerminator, Validators >::operator std::string & ( )
inline

◆ operator std::string const &()

template<std::size_t MaxBytesWithoutNullTerminator, typename... Validators>
WorldPackets::String< MaxBytesWithoutNullTerminator, Validators >::operator std::string const & ( ) const
inline

◆ operator std::string_view()

template<std::size_t MaxBytesWithoutNullTerminator, typename... Validators>
WorldPackets::String< MaxBytesWithoutNullTerminator, Validators >::operator std::string_view ( ) const
inline

◆ Validate()

template<std::size_t MaxBytesWithoutNullTerminator, typename... Validators>
bool WorldPackets::String< MaxBytesWithoutNullTerminator, Validators >::Validate ( ) const
inlineprivate
96 {
97 return ValidateNth(std::make_index_sequence<std::tuple_size_v<ValidatorList>>{});
98 }
bool ValidateNth(std::index_sequence< indexes... >) const
Definition: PacketUtilities.h:101

References WorldPackets::String< MaxBytesWithoutNullTerminator, Validators >::ValidateNth().

◆ ValidateNth()

template<std::size_t MaxBytesWithoutNullTerminator, typename... Validators>
template<std::size_t... indexes>
bool WorldPackets::String< MaxBytesWithoutNullTerminator, Validators >::ValidateNth ( std::index_sequence< indexes... >  ) const
inlineprivate
102 {
103 return (std::tuple_element_t<indexes, ValidatorList>::Validate(_storage) && ...);
104 }

References WorldPackets::String< MaxBytesWithoutNullTerminator, Validators >::_storage.

Referenced by WorldPackets::String< MaxBytesWithoutNullTerminator, Validators >::Validate().

Friends And Related Function Documentation

◆ operator>>

template<std::size_t MaxBytesWithoutNullTerminator, typename... Validators>
ByteBuffer & operator>> ( ByteBuffer data,
String< MaxBytesWithoutNullTerminator, Validators > &  value 
)
friend
88 {
89 value._storage = data.ReadCString(false);
90 value.Validate();
91 return data;
92 }
std::string ReadCString(bool requireValidUtf8=true)
Definition: ByteBuffer.cpp:77

Member Data Documentation

◆ _storage