Sierra Toolkit Version of the Day
sierra::implementation::StringData Union Reference

List of all members.

Public Types

enum  { buf_len = 32 }
enum  { off_len = buf_len - 1 }
enum  { max_len = buf_len - 2 }

Public Member Functions

size_t len () const
const char * c_str () const
char * c_str ()
char * mem (const char *, size_t n)

Public Attributes

struct
sierra::implementation::StringData::Large 
large
char small [buf_len]

Detailed Description

Objectives:
  • Don't allocate for short strings, strings <= max_len
  • buf_len == sizeof(String)
  • buf_len % sizeof(unsigned long) == 0
Limitations:
  • sizeof(StringData::Large) + 2 <= buf_len < ( 127 == 0x7f )
Memory layout for short strings that are <= max_len
  • buf[ 0 .. max_len - 1 ] = buffer for characters
  • buf[ max_len ] = null
  • buf[ off_len ] = length of string
  • data = must not be used
Memory layout for long strings that are > max_len
  • data.ptr = pointer to allocated memory
  • data.len = length of string
  • data.siz = allocated size
  • buf[ max_len ] != null
  • buf[ 0 .. max_len - 1 ] = must not be used

Definition at line 248 of file String.hpp.


Member Function Documentation

char * sierra::implementation::StringData::mem ( const char *  cs,
size_t  n 
)

Assigns memory and copy contents

Definition at line 119 of file String.cpp.


The documentation for this union was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines