Quick Links:

bal | bbl | bdl | bsl

Public Types | Public Member Functions | Static Public Member Functions | Public Attributes

bsl::String_Imp< CHAR_TYPE, SIZE_TYPE > Class Template Reference
[Component bslstl_string]

#include <bslstl_string.h>

List of all members.

Public Types

enum  ShortBufferConstraints {
  SHORT_BUFFER_MIN_BYTES = 20, SHORT_BUFFER_NEED_BYTES, SHORT_BUFFER_BYTES, SHORT_BUFFER_LENGTH = SHORT_BUFFER_BYTES / sizeof(CHAR_TYPE),
  SHORT_BUFFER_CAPACITY = SHORT_BUFFER_LENGTH - 1
}
enum  ConfigurableParameters { BASIC_STRING_DEALLOCATE_IN_CLEAR = false, BASIC_STRING_HONOR_SHRINK_REQUEST = false }

Public Member Functions

 BSLMF_ASSERT (SHORT_BUFFER_BYTES >=sizeof(CHAR_TYPE *))
 BSLMF_NESTED_TRAIT_DECLARATION (String_Imp, BloombergLP::bslmf::IsBitwiseMoveable)
 String_Imp ()
 String_Imp (SIZE_TYPE length, SIZE_TYPE capacity)
 String_Imp (const String_Imp &original)
 ~String_Imp ()
String_Impoperator= (const String_Imp &rhs)
void swap (String_Imp &other)
void resetFields ()
CHAR_TYPE * dataPtr ()
bool isShortString () const
const CHAR_TYPE * dataPtr () const

Static Public Member Functions

static SIZE_TYPE computeNewCapacity (SIZE_TYPE newLength, SIZE_TYPE oldCapacity, SIZE_TYPE maxSize)

Public Attributes

union {
   BloombergLP::bsls::AlignedBuffer
< SHORT_BUFFER_BYTES,
BloombergLP::bsls::AlignmentFromType
< CHAR_TYPE >::VALUE >   d_short
   CHAR_TYPE *   bsl::String_Imp::d_start_p
}; 
SIZE_TYPE d_length
SIZE_TYPE d_capacity

Detailed Description

template<class CHAR_TYPE, class SIZE_TYPE>
class bsl::String_Imp< CHAR_TYPE, SIZE_TYPE >

This component private class describes the basic data layout for a string class and provides methods to help encapsulate internal string implementation details. It is parameterized by CHAR_TYPE and SIZE_TYPE only, and implements the portion of basic_string that does not need to know about its (template parameter) types CHAR_TRAITS or ALLOCATOR. It contains the following data fields: pointer to string, short string buffer, length, and capacity. The purpose of the short string buffer is to implement a "short string optimization" such that strings with lengths shorter than a certain number of characters are stored directly inside the string object (inside the short string buffer), and thereby avoid memory allocations/deallocations.

See Component bslstl_string


Member Enumeration Documentation

template<class CHAR_TYPE, class SIZE_TYPE>
enum bsl::String_Imp::ShortBufferConstraints

This enum contains values necessary to calculate the size of the short string buffer. The starting value is SHORT_BUFFER_MIN_BYTES, which defines the minimal number of bytes (or char values) that the short string buffer should be able to contain. Then this value is aligned to a word boundary. Then we make sure that it fits at least one CHAR_TYPE character (because the default state of the string object requires that the first character is initialized with a NULL-terminator). The final output of this enum used by String_Imp is the SHORT_BUFFER_CAPACITY value. It defines the capacity of the short string buffer and also the capacity of the default-constructed empty string object.

Enumerator:
SHORT_BUFFER_MIN_BYTES 

minimum required size of the short string buffer in bytes

SHORT_BUFFER_NEED_BYTES 

round it to a word boundary

SHORT_BUFFER_BYTES 

in case CHAR_TYPE is very large

SHORT_BUFFER_LENGTH 
SHORT_BUFFER_CAPACITY 

short string buffer capacity (not including the null-terminator)


Member Data Documentation

template<class CHAR_TYPE, class SIZE_TYPE>
BloombergLP::bsls::AlignedBuffer< SHORT_BUFFER_BYTES, BloombergLP::bsls::AlignmentFromType<CHAR_TYPE>::VALUE> bsl::String_Imp< CHAR_TYPE, SIZE_TYPE >::d_short

short string buffer

Referenced by bsl::String_Imp< CHAR_TYPE, SIZE_TYPE >::dataPtr().


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