opp_string Class Reference

API: opp_string Class Reference
API
opp_string Class Reference

Public Member Functions

 opp_string ()
 opp_string (const char *s)
 opp_string (const char *s, int n)
 opp_string (const std::string &s)
 opp_string (const opp_string &s)
 opp_string (opp_string &&s)
 ~opp_string ()
const char * c_str () const
std::string str () const
bool empty () const
char * buffer ()
int size () const
char * reserve (unsigned size)
const char * operator= (const char *s)
opp_stringoperator= (const opp_string &s)
opp_stringoperator= (const std::string &s)
bool operator< (const opp_string &s) const
bool operator== (const opp_string &s) const
bool operator!= (const opp_string &s) const
opp_stringoperator+= (const char *s)
opp_stringoperator+= (const opp_string &s)
opp_stringoperator+= (const std::string &s)
opp_string operator+ (const char *s)
opp_string operator+ (const opp_string &s)
opp_string operator+ (const std::string &s)

Description

Lightweight string class, used internally in some parts of OMNeT++.

In simulation models it is better to use std::string or const char * instead.

opp_string has only one data member, a char* pointer. Allocation and deallocation of the contents takes place via opp_strdup() and operator delete.

Constructor & Destructor Documentation

◆ opp_string() [1/6]

◆ opp_string() [2/6]

opp_string ( const char * s)
inline

Constructor.

◆ opp_string() [3/6]

opp_string ( const char * s,
int n )
inline

Constructor.

◆ opp_string() [4/6]

opp_string ( const std::string & s)
inline

Constructor.

◆ opp_string() [5/6]

opp_string ( const opp_string & s)
inline

Copy constructor.

References opp_string().

◆ opp_string() [6/6]

opp_string ( opp_string && s)
inline

Move constructor.

References opp_string().

◆ ~opp_string()

~opp_string ( )
inline

Destructor.

Member Function Documentation

◆ c_str()

const char * c_str ( ) const
inline

Return pointer to the string.

Referenced by operator+(), operator+(), and cValue::set().

◆ str()

std::string str ( ) const
inline

Convert to std::string.

◆ empty()

bool empty ( ) const
inline

Null (empty) string or not.

◆ buffer()

char * buffer ( )
inline

Returns pointer to the internal buffer where the string is stored. It is allowed to write into the string via this pointer, but the length of the string should not be exceeded.

◆ size()

int size ( ) const
inline

Returns the length of the string.

Referenced by reserve().

◆ reserve()

char * reserve ( unsigned size)
inline

Allocates a buffer of the given size.

References size().

◆ operator=() [1/3]

const char * operator= ( const char * s)
inline

Deletes the old value and opp_strdup()'s the new value to create the object's own copy.

Referenced by operator+=().

◆ operator=() [2/3]

opp_string & operator= ( const opp_string & s)
inline

Assignment.

References operator=(), and opp_string().

Referenced by operator=().

◆ operator=() [3/3]

opp_string & operator= ( const std::string & s)
inline

Assignment.

References operator=(), and opp_string().

Referenced by operator=().

◆ operator<()

bool operator< ( const opp_string & s) const
inline

Comparison.

References opp_string().

◆ operator==()

bool operator== ( const opp_string & s) const
inline

Comparison.

References opp_string().

◆ operator!=()

bool operator!= ( const opp_string & s) const
inline

Comparison.

References opp_string().

◆ operator+=() [1/3]

opp_string & operator+= ( const char * s)
inline

Concatenation

References operator=(), and opp_string().

◆ operator+=() [2/3]

opp_string & operator+= ( const opp_string & s)
inline

Concatenation

References operator+=(), and opp_string().

Referenced by operator+=().

◆ operator+=() [3/3]

opp_string & operator+= ( const std::string & s)
inline

Concatenation

References operator+=(), and opp_string().

Referenced by operator+=().

◆ operator+() [1/3]

opp_string operator+ ( const char * s)
inline

Concatenation

References c_str(), and opp_string().

◆ operator+() [2/3]

opp_string operator+ ( const opp_string & s)
inline

Concatenation

References c_str(), operator+(), and opp_string().

Referenced by operator+().

◆ operator+() [3/3]

opp_string operator+ ( const std::string & s)
inline

Concatenation

References operator+(), and opp_string().

Referenced by operator+().