cprover
dstringt Class Referencefinal

dstringt has one field, an unsigned integer no which is an index into a static table of strings. More...

#include <dstring.h>

Public Member Functions

 dstringt ()
 
 dstringt (const char *s)
 
 dstringt (const std::string &s)
 
bool empty () const
 
char operator[] (size_t i) const
 
const char * c_str () const
 
size_t size () const
 
bool operator< (const dstringt &b) const
 
bool operator== (const dstringt &b) const
 
bool operator!= (const dstringt &b) const
 
bool operator== (const char *b) const
 
bool operator!= (const char *b) const
 
bool operator== (const std::string &b) const
 
bool operator!= (const std::string &b) const
 
bool operator< (const std::string &b) const
 
bool operator> (const std::string &b) const
 
bool operator<= (const std::string &b) const
 
bool operator>= (const std::string &b) const
 
int compare (const dstringt &b) const
 
void clear ()
 
void swap (dstringt &b)
 
dstringtoperator= (const dstringt &b)
 
std::ostream & operator<< (std::ostream &out) const
 
unsigned get_no () const
 
size_t hash () const
 

Static Public Member Functions

static dstringt make_from_table_index (unsigned no)
 

Private Member Functions

 dstringt (unsigned _no)
 
const std::string & as_string () const
 

Private Attributes

unsigned no
 

Detailed Description

dstringt has one field, an unsigned integer no which is an index into a static table of strings.

This makes it expensive to create a new string(because you have to look through the whole table to see if it is already there, and add it if it isn't) but very cheap to compare strings (just compare the two integers). It also means that when you have lots of copies of the same string you only have to store the whole string once, which saves space.

irep_idt and irep_namet are typedef-ed to dstringt in irep.h unless USE_STD_STRING is set.

Note: Marked final to disable inheritance. No virtual destructor, so runtime-polymorphic use would be unsafe.

Definition at line 35 of file dstring.h.

Constructor & Destructor Documentation

◆ dstringt() [1/4]

dstringt::dstringt ( )
inline

Definition at line 42 of file dstring.h.

◆ dstringt() [2/4]

dstringt::dstringt ( const char *  s)
inline

Definition at line 63 of file dstring.h.

◆ dstringt() [3/4]

dstringt::dstringt ( const std::string &  s)
inline

Definition at line 69 of file dstring.h.

◆ dstringt() [4/4]

dstringt::dstringt ( unsigned  _no)
inlineexplicitprivate

Definition at line 158 of file dstring.h.

Member Function Documentation

◆ as_string()

const std::string& dstringt::as_string ( ) const
inlineprivate

Definition at line 165 of file dstring.h.

◆ c_str()

const char* dstringt::c_str ( ) const
inline

Definition at line 86 of file dstring.h.

◆ clear()

void dstringt::clear ( void  )
inline

Definition at line 129 of file dstring.h.

◆ compare()

int dstringt::compare ( const dstringt b) const
inline

Definition at line 120 of file dstring.h.

◆ empty()

bool dstringt::empty ( ) const
inline

Definition at line 75 of file dstring.h.

◆ get_no()

unsigned dstringt::get_no ( ) const
inline

Definition at line 144 of file dstring.h.

◆ hash()

size_t dstringt::hash ( ) const
inline

Definition at line 149 of file dstring.h.

◆ make_from_table_index()

static dstringt dstringt::make_from_table_index ( unsigned  no)
inlinestatic

Definition at line 50 of file dstring.h.

◆ operator!=() [1/3]

bool dstringt::operator!= ( const dstringt b) const
inline

Definition at line 105 of file dstring.h.

◆ operator!=() [2/3]

bool dstringt::operator!= ( const char *  b) const
inline

Definition at line 111 of file dstring.h.

◆ operator!=() [3/3]

bool dstringt::operator!= ( const std::string &  b) const
inline

Definition at line 114 of file dstring.h.

◆ operator<() [1/2]

bool dstringt::operator< ( const dstringt b) const
inline

Definition at line 98 of file dstring.h.

◆ operator<() [2/2]

bool dstringt::operator< ( const std::string &  b) const
inline

Definition at line 115 of file dstring.h.

◆ operator<<()

std::ostream & dstringt::operator<< ( std::ostream &  out) const

Definition at line 16 of file dstring.cpp.

◆ operator<=()

bool dstringt::operator<= ( const std::string &  b) const
inline

Definition at line 117 of file dstring.h.

◆ operator=()

dstringt& dstringt::operator= ( const dstringt b)
inline

Definition at line 135 of file dstring.h.

◆ operator==() [1/3]

bool dstringt::operator== ( const dstringt b) const
inline

Definition at line 102 of file dstring.h.

◆ operator==() [2/3]

bool dstringt::operator== ( const char *  b) const
inline

Definition at line 110 of file dstring.h.

◆ operator==() [3/3]

bool dstringt::operator== ( const std::string &  b) const
inline

Definition at line 113 of file dstring.h.

◆ operator>()

bool dstringt::operator> ( const std::string &  b) const
inline

Definition at line 116 of file dstring.h.

◆ operator>=()

bool dstringt::operator>= ( const std::string &  b) const
inline

Definition at line 118 of file dstring.h.

◆ operator[]()

char dstringt::operator[] ( size_t  i) const
inline

Definition at line 80 of file dstring.h.

◆ size()

size_t dstringt::size ( ) const
inline

Definition at line 91 of file dstring.h.

◆ swap()

void dstringt::swap ( dstringt b)
inline

Definition at line 132 of file dstring.h.

Member Data Documentation

◆ no

unsigned dstringt::no
private

Definition at line 162 of file dstring.h.


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