YARP  2.3.70
Yet Another Robot Platform
yarp::os::ConstString Class Reference

A string with almost the same api as std::string. More...

#include <yarp/os/ConstString.h>

Public Types

typedef char value_type
 
typedef std::char_traits< char > traits_type
 
typedef std::allocator< char > allocator_type
 
typedef size_t size_type
 
typedef ptrdiff_t difference_type
 
typedef char & reference
 
typedef const char & const_reference
 
typedef char * pointer
 
typedef const char * const_pointer
 
typedef std::string::iterator iterator
 
typedef std::string::const_iterator const_iterator
 
typedef std::reverse_iterator< iteratorreverse_iterator
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 

Public Member Functions

 ConstString ()
 Constructor. More...
 
 ConstString (const ConstString &str)
 Copy constructor. More...
 
 ConstString (const ConstString &str, size_t pos, size_t len=npos)
 Constructor. More...
 
 ConstString (const char *str)
 Constructor. More...
 
 ConstString (const char *str, size_t len)
 Constructor. More...
 
 ConstString (size_t len, char c)
 Constructor. More...
 
 ~ConstString ()
 Destructor. More...
 
ConstStringoperator= (const ConstString &str)
 Assignment operator. More...
 
ConstStringoperator= (const char *str)
 Assignment operator. More...
 
ConstStringoperator= (char c)
 Assignment operator. More...
 
 operator std::string () const
 
 ConstString (const std::string &str)
 
Iterators
iterator begin ()
 
const_iterator begin () const
 
iterator end ()
 
const_iterator end () const
 
reverse_iterator rbegin ()
 
const_reverse_iterator rbegin () const
 
reverse_iterator rend ()
 
const_reverse_iterator rend () const
 
Capacity
size_t size () const
 
size_t length () const
 
size_t max_size () const
 
void resize (size_t n)
 
void resize (size_t n, char c)
 
size_t capacity () const
 
void reserve (size_t n=0)
 
void clear ()
 
bool empty () const
 
Element access
char & operator[] (size_t idx)
 
const char & operator[] (size_t idx) const
 
char & at (size_t pos)
 
const char & at (size_t pos) const
 
Modifiers
ConstStringoperator+= (const ConstString &str)
 
ConstStringoperator+= (const char *str)
 
ConstStringoperator+= (char ch)
 
void push_back (char c)
 
ConstStringassign (const char *s, size_t n)
 
ConstStringerase (size_t pos=0, size_t len=npos)
 
iterator erase (iterator p)
 
iterator erase (iterator first, iterator last)
 
void swap (ConstString &str)
 
String operations
const char * c_str () const
 Accesses the character sequence stored in this object. More...
 
const char * data () const
 Get string data. More...
 
allocator_type get_allocator () const
 Get allocator. More...
 
size_t copy (char *str, size_t len, size_t pos=0) const
 Copy sequence of characters from string. More...
 
size_t find (const ConstString &needle, size_t start=0) const
 Find content in string. More...
 
size_t find (const char *needle, size_t start=0) const
 
size_t find (const char *needle, size_t start, size_t len) const
 
size_t find (char needle, size_t start=0) const
 
size_t rfind (const ConstString &needle, size_t start=npos) const
 Find the last occurrence of content in string. More...
 
size_t rfind (const char *needle, size_t start=npos) const
 
size_t rfind (const char *needle, size_t start, size_t len) const
 
size_t rfind (char needle, size_t start=npos) const
 
ConstString substr (size_t start=0, size_t n=npos) const
 Generate a substring. More...
 
Non std::string
unsigned long hash () const
 

Static Public Attributes

static const size_t npos = std::string::npos
 

Detailed Description

A string with almost the same api as std::string.

It adds a hash function for compatibility with certain versions of the ACE library.

Examples:
carrier/carrier_stub.cpp, dev/file_grabber.cpp, framerate/main.cpp, os/database.cpp, os/image_process.cpp, and property/main.cpp.

Definition at line 44 of file ConstString.h.

Member Typedef Documentation

◆ allocator_type

typedef std::allocator<char> yarp::os::ConstString::allocator_type

Definition at line 51 of file ConstString.h.

◆ const_iterator

typedef std::string::const_iterator yarp::os::ConstString::const_iterator

Definition at line 61 of file ConstString.h.

◆ const_pointer

Definition at line 58 of file ConstString.h.

◆ const_reference

Definition at line 56 of file ConstString.h.

◆ const_reverse_iterator

Definition at line 63 of file ConstString.h.

◆ difference_type

Definition at line 53 of file ConstString.h.

◆ iterator

typedef std::string::iterator yarp::os::ConstString::iterator

Definition at line 60 of file ConstString.h.

◆ pointer

Definition at line 57 of file ConstString.h.

◆ reference

Definition at line 55 of file ConstString.h.

◆ reverse_iterator

typedef std::reverse_iterator<iterator> yarp::os::ConstString::reverse_iterator

Definition at line 62 of file ConstString.h.

◆ size_type

Definition at line 52 of file ConstString.h.

◆ traits_type

typedef std::char_traits<char> yarp::os::ConstString::traits_type

Definition at line 50 of file ConstString.h.

◆ value_type

Definition at line 49 of file ConstString.h.

Constructor & Destructor Documentation

◆ ConstString() [1/7]

ConstString::ConstString ( )

Constructor.

Creates an empty string.

Definition at line 31 of file ConstString.cpp.

◆ ConstString() [2/7]

ConstString::ConstString ( const ConstString str)

Copy constructor.

Parameters
strThe string to be copied.

Definition at line 36 of file ConstString.cpp.

◆ ConstString() [3/7]

ConstString::ConstString ( const ConstString str,
size_t  pos,
size_t  len = npos 
)

Constructor.

Stores a copy of the substring.

Parameters
strThe string to be copied.
posPosition of the first character to be copied.
lenLength of the substring to be copied.

Definition at line 41 of file ConstString.cpp.

◆ ConstString() [4/7]

ConstString::ConstString ( const char *  str)

Constructor.

Stores a copy of the null-terminated specified string.

Parameters
strThe string to be copied.

Definition at line 45 of file ConstString.cpp.

◆ ConstString() [5/7]

ConstString::ConstString ( const char *  str,
size_t  len 
)

Constructor.

Stores a copy of the specified string.

Parameters
strThe string to be copied.
lenNumber of bytes to copy.

Definition at line 50 of file ConstString.cpp.

◆ ConstString() [6/7]

ConstString::ConstString ( size_t  len,
char  c 
)

Constructor.

Fills the string with a character.

Parameters
lenNumber of characters to copy.
vThe character to copy.

Definition at line 60 of file ConstString.cpp.

◆ ~ConstString()

ConstString::~ConstString ( )

Destructor.

Definition at line 65 of file ConstString.cpp.

◆ ConstString() [7/7]

yarp::os::ConstString::ConstString ( const std::string &  str)
inline

Definition at line 148 of file ConstString.h.

Member Function Documentation

◆ assign()

ConstString & ConstString::assign ( const char *  s,
size_t  n 
)

Definition at line 268 of file ConstString.cpp.

◆ at() [1/2]

char & ConstString::at ( size_t  pos)

Definition at line 260 of file ConstString.cpp.

◆ at() [2/2]

const char & ConstString::at ( size_t  pos) const

Definition at line 264 of file ConstString.cpp.

◆ begin() [1/2]

ConstString::iterator ConstString::begin ( )

Definition at line 220 of file ConstString.cpp.

◆ begin() [2/2]

ConstString::const_iterator ConstString::begin ( ) const

Definition at line 224 of file ConstString.cpp.

◆ c_str()

◆ capacity()

size_t ConstString::capacity ( ) const

Definition at line 131 of file ConstString.cpp.

◆ clear()

void ConstString::clear ( )

Definition at line 212 of file ConstString.cpp.

◆ copy()

size_t ConstString::copy ( char *  str,
size_t  len,
size_t  pos = 0 
) const

Copy sequence of characters from string.

Definition at line 100 of file ConstString.cpp.

◆ data()

const char * ConstString::data ( ) const

Get string data.

Definition at line 92 of file ConstString.cpp.

◆ empty()

bool ConstString::empty ( ) const

Definition at line 216 of file ConstString.cpp.

◆ end() [1/2]

ConstString::iterator ConstString::end ( )

Definition at line 228 of file ConstString.cpp.

◆ end() [2/2]

ConstString::const_iterator ConstString::end ( ) const

Definition at line 232 of file ConstString.cpp.

◆ erase() [1/3]

ConstString & ConstString::erase ( size_t  pos = 0,
size_t  len = npos 
)

Definition at line 158 of file ConstString.cpp.

◆ erase() [2/3]

ConstString::iterator ConstString::erase ( iterator  p)

Definition at line 163 of file ConstString.cpp.

◆ erase() [3/3]

ConstString::iterator ConstString::erase ( iterator  first,
iterator  last 
)

Definition at line 167 of file ConstString.cpp.

◆ find() [1/4]

size_t ConstString::find ( const ConstString needle,
size_t  start = 0 
) const

Find content in string.

Definition at line 175 of file ConstString.cpp.

◆ find() [2/4]

size_t ConstString::find ( const char *  needle,
size_t  start = 0 
) const

Definition at line 179 of file ConstString.cpp.

◆ find() [3/4]

size_t ConstString::find ( const char *  needle,
size_t  start,
size_t  len 
) const

Definition at line 183 of file ConstString.cpp.

◆ find() [4/4]

size_t ConstString::find ( char  needle,
size_t  start = 0 
) const

Definition at line 187 of file ConstString.cpp.

◆ get_allocator()

ConstString::allocator_type ConstString::get_allocator ( ) const

Get allocator.

Definition at line 96 of file ConstString.cpp.

◆ hash()

unsigned long ConstString::hash ( ) const

Definition at line 275 of file ConstString.cpp.

◆ length()

size_t ConstString::length ( ) const

Definition at line 111 of file ConstString.cpp.

◆ max_size()

size_t ConstString::max_size ( ) const

Definition at line 119 of file ConstString.cpp.

◆ operator std::string()

yarp::os::ConstString::operator std::string ( ) const
inline

Definition at line 145 of file ConstString.h.

◆ operator+=() [1/3]

ConstString & ConstString::operator+= ( const ConstString str)

Definition at line 149 of file ConstString.cpp.

◆ operator+=() [2/3]

ConstString & ConstString::operator+= ( const char *  str)

Definition at line 144 of file ConstString.cpp.

◆ operator+=() [3/3]

ConstString & ConstString::operator+= ( char  ch)

Definition at line 139 of file ConstString.cpp.

◆ operator=() [1/3]

ConstString & ConstString::operator= ( const ConstString str)

Assignment operator.

Parameters
strThe string to be copied.

Definition at line 73 of file ConstString.cpp.

◆ operator=() [2/3]

ConstString & ConstString::operator= ( const char *  str)

Assignment operator.

Parameters
strThe string to be copied.

Definition at line 78 of file ConstString.cpp.

◆ operator=() [3/3]

ConstString & ConstString::operator= ( char  c)

Assignment operator.

Parameters
cThe character to be copied.

Definition at line 83 of file ConstString.cpp.

◆ operator[]() [1/2]

char & ConstString::operator[] ( size_t  idx)

Definition at line 252 of file ConstString.cpp.

◆ operator[]() [2/2]

const char & ConstString::operator[] ( size_t  idx) const

Definition at line 256 of file ConstString.cpp.

◆ push_back()

void ConstString::push_back ( char  c)

Definition at line 154 of file ConstString.cpp.

◆ rbegin() [1/2]

ConstString::reverse_iterator ConstString::rbegin ( )

Definition at line 236 of file ConstString.cpp.

◆ rbegin() [2/2]

ConstString::const_reverse_iterator ConstString::rbegin ( ) const

Definition at line 240 of file ConstString.cpp.

◆ rend() [1/2]

ConstString::reverse_iterator ConstString::rend ( )

Definition at line 244 of file ConstString.cpp.

◆ rend() [2/2]

ConstString::const_reverse_iterator ConstString::rend ( ) const

Definition at line 248 of file ConstString.cpp.

◆ reserve()

void ConstString::reserve ( size_t  n = 0)

Definition at line 135 of file ConstString.cpp.

◆ resize() [1/2]

void ConstString::resize ( size_t  n)

Definition at line 123 of file ConstString.cpp.

◆ resize() [2/2]

void ConstString::resize ( size_t  n,
char  c 
)

Definition at line 127 of file ConstString.cpp.

◆ rfind() [1/4]

size_t ConstString::rfind ( const ConstString needle,
size_t  start = npos 
) const

Find the last occurrence of content in string.

Definition at line 191 of file ConstString.cpp.

◆ rfind() [2/4]

size_t ConstString::rfind ( const char *  needle,
size_t  start = npos 
) const

Definition at line 195 of file ConstString.cpp.

◆ rfind() [3/4]

size_t ConstString::rfind ( const char *  needle,
size_t  start,
size_t  len 
) const

Definition at line 199 of file ConstString.cpp.

◆ rfind() [4/4]

size_t ConstString::rfind ( char  needle,
size_t  start = npos 
) const

Definition at line 203 of file ConstString.cpp.

◆ size()

size_t ConstString::size ( ) const

Definition at line 115 of file ConstString.cpp.

◆ substr()

ConstString ConstString::substr ( size_t  start = 0,
size_t  n = npos 
) const

Generate a substring.

Definition at line 207 of file ConstString.cpp.

◆ swap()

void ConstString::swap ( ConstString str)

Definition at line 171 of file ConstString.cpp.

Member Data Documentation

◆ npos

const size_t ConstString::npos = std::string::npos
static

Definition at line 47 of file ConstString.h.


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