Classes | Public Member Functions | Private Attributes | Static Private Attributes | List of all members
PJ::StringRef Class Reference

Super simple, unmutable, string_view with small string optimization. If the string is 15 bytes or less, it is copied, otherwise, StringRef store a not-owning reference. More...

#include <string_ref_sso.h>

Classes

struct  noSSO
 
struct  SSO
 

Public Member Functions

const char * data () const
 
bool isSSO () const
 
size_t size () const
 
 StringRef ()
 
 StringRef (const char *data_ptr, size_t length)
 
 StringRef (const char *str)
 
 StringRef (const std::string &str)
 

Private Attributes

union {
   noSSO   no_sso
 
   SSO   sso
 
_storage
 

Static Private Attributes

static const uint8_t SSO_SIZE = sizeof(noSSO) - 1
 
static const uint64_t TYPE_BIT = uint64_t(1) << (sizeof(size_t) * 8 - 1)
 

Detailed Description

Super simple, unmutable, string_view with small string optimization. If the string is 15 bytes or less, it is copied, otherwise, StringRef store a not-owning reference.

Definition at line 21 of file string_ref_sso.h.

Constructor & Destructor Documentation

◆ StringRef() [1/4]

PJ::StringRef::StringRef ( )
inline

Definition at line 51 of file string_ref_sso.h.

◆ StringRef() [2/4]

PJ::StringRef::StringRef ( const std::string &  str)
inline

Definition at line 55 of file string_ref_sso.h.

◆ StringRef() [3/4]

PJ::StringRef::StringRef ( const char *  str)
inline

Definition at line 59 of file string_ref_sso.h.

◆ StringRef() [4/4]

PJ::StringRef::StringRef ( const char *  data_ptr,
size_t  length 
)
inlineexplicit

Definition at line 63 of file string_ref_sso.h.

Member Function Documentation

◆ data()

const char* PJ::StringRef::data ( ) const
inline

Definition at line 81 of file string_ref_sso.h.

◆ isSSO()

bool PJ::StringRef::isSSO ( ) const
inline

Definition at line 46 of file string_ref_sso.h.

◆ size()

size_t PJ::StringRef::size ( ) const
inline

Definition at line 86 of file string_ref_sso.h.

Member Data Documentation

◆ _storage

union { ... } PJ::StringRef::_storage

◆ no_sso

noSSO PJ::StringRef::no_sso

Definition at line 41 of file string_ref_sso.h.

◆ sso

SSO PJ::StringRef::sso

Definition at line 42 of file string_ref_sso.h.

◆ SSO_SIZE

const uint8_t PJ::StringRef::SSO_SIZE = sizeof(noSSO) - 1
staticprivate

Definition at line 32 of file string_ref_sso.h.

◆ TYPE_BIT

const uint64_t PJ::StringRef::TYPE_BIT = uint64_t(1) << (sizeof(size_t) * 8 - 1)
staticprivate

Definition at line 24 of file string_ref_sso.h.


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


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:52