Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZStd::basic_string< Element, Traits, Allocator > Class Template Reference

#include <string.h>

Classes

struct  _Format_Internal
 
struct  AllocatedStringData
 dynamically allocated data More...
 
struct  PointerAlignedData
 
struct  ShortStringData
 small buffer used for small string optimization More...
 
union  Storage
 

Public Types

using pointer = Element *
 
using const_pointer = const Element *
 
using reference = Element &
 
using const_reference = const Element &
 
using iterator_impl = pointer
 
using const_iterator_impl = const_pointer
 
using iterator = iterator_impl
 
using const_iterator = const_iterator_impl
 
using difference_type = iter_difference_t< iterator >
 
using size_type = make_unsigned_t< difference_type >
 
using reverse_iterator = AZStd::reverse_iterator< iterator >
 
using const_reverse_iterator = AZStd::reverse_iterator< const_iterator >
 
using value_type = Element
 
using traits_type = Traits
 
using allocator_type = Allocator
 
using node_type = value_type
 Allocation node type. Common for all AZStd containers. In vectors case we allocate always "sizeof(node_type)*capacity" block.
 

Public Member Functions

constexpr basic_string (const Allocator &alloc=Allocator())
 
 basic_string (const_pointer ptr, size_type count, const Allocator &alloc=Allocator())
 
 basic_string (const_pointer ptr, const Allocator &alloc=Allocator())
 
 basic_string (size_type count, Element ch, const Allocator &alloc=Allocator())
 
template<class InputIt , typename = enable_if_t<input_iterator<InputIt> && !is_convertible_v<InputIt, size_t>>>
 basic_string (InputIt first, InputIt last, const Allocator &alloc=Allocator())
 
template<class R , class = enable_if_t<Internal::container_compatible_range<R, value_type>>>
 basic_string (from_range_t, R &&rg, const Allocator &alloc=Allocator())
 
 basic_string (initializer_list< Element > ilist, const Allocator &alloc=Allocator())
 
 basic_string (const this_type &rhs)
 
 basic_string (this_type &&rhs)
 
 basic_string (const this_type &rhs, size_type rhsOffset, size_type count=npos)
 
 basic_string (const this_type &rhs, size_type rhsOffset, size_type count, const Allocator &alloc)
 
 basic_string (AZStd::basic_string_view< Element, Traits > view, const Allocator &alloc=Allocator())
 
 basic_string (AZStd::basic_string_view< Element, Traits > view, size_type pos, size_type n, const Allocator &alloc=Allocator())
 
constexpr basic_string (AZStd::nullptr_t)=delete
 
constexpr operator AZStd::basic_string_view< Element, Traits > () const
 
iterator begin ()
 
const_iterator begin () const
 
const_iterator cbegin () const
 
iterator end ()
 
const_iterator end () const
 
const_iterator cend () const
 
reverse_iterator rbegin ()
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator crbegin () const
 
reverse_iterator rend ()
 
const_reverse_iterator rend () const
 
const_reverse_iterator crend () const
 
this_typeoperator= (const this_type &rhs)
 
this_typeoperator= (this_type &&rhs)
 
this_typeoperator= (AZStd::basic_string_view< Element, Traits > view)
 
this_typeoperator= (const_pointer ptr)
 
this_typeoperator= (Element ch)
 
this_typeoperator= (AZStd::nullptr_t)=delete
 
this_typeoperator+= (const this_type &rhs)
 
this_typeoperator+= (const_pointer ptr)
 
this_typeoperator+= (Element ch)
 
this_typeappend (const this_type &rhs)
 
this_typeappend (const this_type &rhs, size_type rhsOffset, size_type count)
 
this_typeappend (const_pointer ptr, size_type count)
 
this_typeappend (const_pointer ptr)
 
this_typeappend (size_type count, Element ch)
 
template<class InputIt >
auto append (InputIt first, InputIt last) -> enable_if_t< input_iterator< InputIt > &&!is_convertible_v< InputIt, size_type >, this_type & >
 
this_typeappend (const_pointer first, const_pointer last)
 
template<class R >
auto append_range (R &&rg) -> enable_if_t< Internal::container_compatible_range< R, value_type >, basic_string & >
 
basic_stringappend (initializer_list< Element > iList)
 
this_typeassign (const this_type &rhs)
 
this_typeassign (basic_string_view< Element, Traits > view)
 
this_typeassign (this_type &&rhs)
 
this_typeassign (const this_type &rhs, size_type rhsOffset, size_type count)
 
this_typeassign (const_pointer ptr, size_type count)
 
this_typeassign (const_pointer ptr)
 
this_typeassign (size_type count, Element ch)
 
template<class InputIt >
auto assign (InputIt first, InputIt last) -> enable_if_t< input_iterator< InputIt > &&!is_convertible_v< InputIt, size_type >, this_type & >
 
template<class R >
auto assign_range (R &&rg) -> enable_if_t< Internal::container_compatible_range< R, value_type >, basic_string & >
 
basic_stringassign (initializer_list< Element > iList)
 
this_typeinsert (size_type offset, const this_type &rhs)
 
this_typeinsert (size_type offset, const this_type &rhs, size_type rhsOffset, size_type count)
 
this_typeinsert (size_type offset, const_pointer ptr, size_type count)
 
this_typeinsert (size_type offset, const_pointer ptr)
 
this_typeinsert (size_type offset, size_type count, Element ch)
 
iterator insert (const_iterator insertPos)
 
iterator insert (const_iterator insertPos, Element ch)
 
iterator insert (const_iterator insertPos, size_type count, Element ch)
 
template<class InputIt >
auto insert (const_iterator insertPos, InputIt first, InputIt last) -> enable_if_t< input_iterator< InputIt > &&!is_convertible_v< InputIt, size_type >, iterator >
 
template<class R >
auto insert_range (const_iterator insertPos, R &&rg) -> enable_if_t< Internal::container_compatible_range< R, value_type >, iterator >
 
iterator insert (const_iterator insertPos, initializer_list< Element > iList)
 
this_typeerase (size_type offset=0, size_type count=npos)
 
iterator erase (const_iterator erasePos)
 
iterator erase (const_iterator first, const_iterator last)
 
void clear ()
 
this_typereplace (size_type offset, size_type count, const this_type &rhs)
 
this_typereplace (size_type offset, size_type count, const this_type &rhs, size_type rhsOffset, size_type rhsCount)
 
this_typereplace (size_type offset, size_type count, const_pointer ptr, size_type ptrCount)
 
this_typereplace (size_type offset, size_type count, const_pointer ptr)
 
this_typereplace (size_type offset, size_type count, size_type num, Element ch)
 
this_typereplace (const_iterator first, const_iterator last, const this_type &rhs)
 
this_typereplace (const_iterator first, const_iterator last, const_pointer ptr, size_type count)
 
this_typereplace (const_iterator first, const_iterator last, const_pointer ptr)
 
this_typereplace (const_iterator first, const_iterator last, size_type count, Element ch)
 
template<class InputIt >
auto replace (const_iterator first, const_iterator last, InputIt replaceFirst, InputIt replaceLast) -> enable_if_t< input_iterator< InputIt > &&!is_convertible_v< InputIt, size_type >, this_type & >
 
template<class R >
auto replace_with_range (const_iterator first, const_iterator last, R &&rg) -> enable_if_t< Internal::container_compatible_range< R, value_type >, basic_string & >
 
basic_stringreplace (const_iterator first, const_iterator last, initializer_list< Element > iList)
 
reference at (size_type offset)
 
const_reference at (size_type offset) const
 
reference operator[] (size_type offset)
 
const_reference operator[] (size_type offset) const
 
reference front ()
 
const_reference front () const
 
reference back ()
 
const_reference back () const
 
void push_back (Element ch)
 
const_pointer c_str () const
 
size_type length () const
 
size_type size () const
 
size_type capacity () const
 
size_type max_size () const
 
void resize (size_type newSize)
 
void resize_no_construct (size_type newSize)
 
template<class Operation >
void resize_and_overwrite (size_type n, Operation op)
 
void resize (size_type newSize, Element ch)
 
void reserve (size_type newCapacity=0)
 
bool empty () const
 
size_type copy (Element *dest, size_type count, size_type offset=0) const
 
void swap (this_type &rhs)
 
bool contains (const basic_string &other) const
 
bool contains (value_type c) const
 
bool contains (const_pointer s) const
 
size_type find (const this_type &rhs, size_type offset=0) const
 
size_type find (const_pointer ptr, size_type offset, size_type count) const
 
size_type find (const_pointer ptr, size_type offset=0) const
 
size_type find (Element ch, size_type offset=0) const
 
size_type rfind (const this_type &rhs, size_type offset=npos) const
 
size_type rfind (const_pointer ptr, size_type offset, size_type count) const
 
size_type rfind (const_pointer ptr, size_type offset=npos) const
 
size_type rfind (Element ch, size_type offset=npos) const
 
size_type find_first_of (const this_type &rhs, size_type offset=0) const
 
size_type find_first_of (const_pointer ptr, size_type offset, size_type count) const
 
size_type find_first_of (const_pointer ptr, size_type offset=0) const
 
size_type find_first_of (Element ch, size_type offset=0) const
 
size_type find_last_of (const this_type &rhs, size_type offset=npos) const
 
size_type find_last_of (const_pointer ptr, size_type offset, size_type count) const
 
size_type find_last_of (const_pointer ptr, size_type offset=npos) const
 
size_type find_last_of (Element ch, size_type offset=npos) const
 
size_type find_first_not_of (const this_type &rhs, size_type offset=0) const
 
size_type find_first_not_of (const_pointer ptr, size_type offset, size_type count) const
 
size_type find_first_not_of (const_pointer ptr, size_type offset=0) const
 
size_type find_first_not_of (Element ch, size_type offset=0) const
 
size_type find_last_not_of (const this_type &rhs, size_type offset=npos) const
 
size_type find_last_not_of (const_pointer ptr, size_type offset, size_type count) const
 
size_type find_last_not_of (const_pointer ptr, size_type offset=npos) const
 
size_type find_last_not_of (Element ch, size_type offset=npos) const
 
this_type substr (size_type offset=0, size_type count=npos) const
 
int compare (const this_type &rhs) const
 
int compare (size_type offset, size_type count, const this_type &rhs) const
 
int compare (size_type offset, size_type count, const this_type &rhs, size_type rhsOffset, size_type rhsCount) const
 
int compare (const_pointer ptr) const
 
int compare (size_type offset, size_type count, const_pointer ptr) const
 
int compare (size_type offset, size_type count, const_pointer ptr, size_type ptrCount) const
 
bool starts_with (AZStd::basic_string_view< Element, Traits > prefix) const
 
bool starts_with (value_type prefix) const
 
bool starts_with (const_pointer prefix) const
 
bool ends_with (AZStd::basic_string_view< Element, Traits > suffix) const
 
bool ends_with (value_type suffix) const
 
bool ends_with (const_pointer suffix) const
 
void pop_back ()
 

Static Public Attributes

static constexpr size_type npos = size_type(-1)
 

Extensions

enum  
 
AZStd::compressed_pair< Storage, allocator_type > m_storage
 
pointer data ()
 TR1 Extension. Return pointer to the vector data. The vector data is guaranteed to be stored as an array.
 
const_pointer data () const
 
allocator_type & get_allocator ()
 The only difference from the standard is that we return the allocator instance, not a copy.
 
const allocator_type & get_allocator () const
 
void set_allocator (const allocator_type &allocator)
 Set the vector allocator. If different than then current all elements will be reallocated.
 
bool validate () const
 
int validate_iterator (const iterator &iter) const
 Validates an iter iterator. Returns a combination of iterator_status_flag.
 
int validate_iterator (const const_iterator &iter) const
 
void leak_and_reset ()
 
void set_capacity (size_type numElements)
 
template<class UAllocator >
 basic_string (const basic_string< Element, Traits, UAllocator > &rhs)
 
template<class UAllocator >
this_typeoperator= (const basic_string< Element, Traits, UAllocator > &rhs)
 
template<class UAllocator >
this_typeappend (const basic_string< Element, Traits, UAllocator > &rhs)
 
template<class UAllocator >
this_typeinsert (size_type offset, const basic_string< Element, Traits, UAllocator > &rhs)
 
template<class UAllocator >
this_typereplace (size_type offset, size_type count, const basic_string< Element, Traits, UAllocator > &rhs)
 
template<class UAllocator >
int compare (const basic_string< Element, Traits, UAllocator > &rhs)
 
static basic_string< char, char_traits< char >, Allocator > format_arg (const char *formatStr, va_list argList)
 
static basic_string< wchar_t, char_traits< wchar_t >, Allocator > format_arg (const wchar_t *formatStr, va_list argList)
 
template<typename... Args>
static basic_string< char, char_traits< char >, Allocator > format (const char *formatStr, Args... args)
 
template<typename... Args>
static basic_string< wchar_t, char_traits< wchar_t >, Allocator > format (const wchar_t *formatStr, Args... args)
 
void copy (size_type newSize, size_type oldLength)
 
bool grow (size_type newSize)
 
bool fits_in_capacity (size_type newSize)
 
void deallocate_memory (pointer data, size_type expandedSize)
 

Detailed Description

template<class Element, class Traits = char_traits<Element>, class Allocator = AZStd::allocator>
class AZStd::basic_string< Element, Traits, Allocator >

Based on dinkumware (VC9) implementation. There are many improvements and extensions.

Member Function Documentation

◆ leak_and_reset()

template<class Element , class Traits = char_traits<Element>, class Allocator = AZStd::allocator>
void AZStd::basic_string< Element, Traits, Allocator >::leak_and_reset ( )
inline

Resets the container without deallocating any memory or calling any destructor. This function should be used when we need very quick tear down. Generally it's used for temporary vectors and we can just nuke them that way. In addition the provided Allocators, has leak and reset flag which will enable automatically this behavior. So this function should be used in special cases AZStdExamples.

Note
This function is added to the vector for consistency. In the vector case we have only one allocation, and if the allocator allows memory leaks it can just leave deallocate function empty, which performance wise will be the same. For more complex containers this will make big difference.

◆ set_capacity()

template<class Element , class Traits = char_traits<Element>, class Allocator = AZStd::allocator>
void AZStd::basic_string< Element, Traits, Allocator >::set_capacity ( size_type  numElements)
inline

Set the capacity, if necessary it will erase elements at the end of the container to match the new capacity.


The documentation for this class was generated from the following files: