CString Class Reference

String class to avoid std::string in the interfaceThis class helps avoiding std::string being present in exposed C++ interface, eventually resulting in compile/link errors when dynamically loading modules. More...

Public Member Functions

virtual OpenViBE::boolean set (const OpenViBE::CString &rString)
 Initializes this string from another OpenViBE string. More...
 
virtual OpenViBE::boolean set (const char *pString)
 Initializes this string from an ANSI/ASCII string. More...
 
virtual const char * toASCIIString (void) const
 Converts this string to an ANSI/ASCII string. More...
 
virtual std::size_t length (void) const
 Returns length of the string. More...
 
Constructor / Destructor
 CString (void)
 Default constructor. More...
 
 CString (const OpenViBE::CString &rString)
 Copy constructor. More...
 
 CString (const char *pString)
 Constructor based on ASCII strings. More...
 
virtual ~CString (void)
 Destructor. More...
 

Protected Attributes

OpenViBE::CStringImpl * m_pStringImpl
 The string implementation.
 

Operators

 operator const char * (void) const
 ASCII string cast operator. More...
 
OpenViBE::CStringoperator= (const OpenViBE::CString &rString)
 Affectation operator (copy) More...
 
OpenViBE::CStringoperator+= (const OpenViBE::CString &rString)
 Addition assignment operator. More...
 
char & operator[] (std::size_t idx)
 Array subscription operator. More...
 
OV_API const OpenViBE::CString operator+ (const OpenViBE::CString &rString1, const OpenViBE::CString &rString2)
 Addition operator. More...
 
OV_API OpenViBE::boolean operator== (const OpenViBE::CString &rString1, const OpenViBE::CString &rString2)
 Equality comparison operator. More...
 
OV_API OpenViBE::boolean operator!= (const OpenViBE::CString &rString1, const OpenViBE::CString &rString2)
 Inequality comparison operator. More...
 
OV_API OpenViBE::boolean operator< (const OpenViBE::CString &rString1, const OpenViBE::CString &rString2)
 Order comparison operator (necessary to use CString as a key in a stl map) More...
 

Detailed Description

String class to avoid std::string in the interface

This class helps avoiding std::string being present in exposed C++ interface, eventually resulting in compile/link errors when dynamically loading modules.

Author
Yann Renard (INRIA/IRISA)
Date
2006-08-10
Note
The implementation uses std::string of course :)

Constructor & Destructor Documentation

CString ( void  )

Default constructor.

Initializes the string to an empty string.

CString ( const OpenViBE::CString rString)

Copy constructor.

Parameters
rString[in] : The string to copy

Copies the content of rString into the new string.

References CString::m_pStringImpl.

CString ( const char *  pString)

Constructor based on ASCII strings.

Parameters
pString[in] : The string to copy

Copies the content of pString into the new string.

~CString ( void  )
virtual

Destructor.

The destructor releases the std::string implementation !

Member Function Documentation

operator const char * ( void  ) const

ASCII string cast operator.

Returns
The string formatted as standard ASCII string used in C.

The implementation simply calls c_str().

CString & operator= ( const OpenViBE::CString rString)

Affectation operator (copy)

Parameters
rString[in] : The string to copy
Returns
This string.

References CString::m_pStringImpl.

CString & operator+= ( const OpenViBE::CString rString)

Addition assignment operator.

Parameters
rString[in] : The string to append
Returns
This string.

References CString::m_pStringImpl.

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

Array subscription operator.

Parameters
idx[in] : Index in the array
boolean set ( const OpenViBE::CString rString)
virtual

Initializes this string from another OpenViBE string.

Parameters
rString[in] : the OpenViBE string to initialize this string from
Returns
true in case of success.
false in case of error.

References CString::m_pStringImpl.

boolean set ( const char *  pString)
virtual

Initializes this string from an ANSI/ASCII string.

Parameters
pString[in] : the ANSI/ASCII string to initialize this string from
Returns
true in case of success.
false in case of error.
const char * toASCIIString ( void  ) const
virtual

Converts this string to an ANSI/ASCII string.

Returns
the ANSI/ASCII converted string.
size_t length ( void  ) const
virtual

Returns length of the string.

Returns
Length of the string

Friends And Related Function Documentation

OV_API const OpenViBE::CString operator+ ( const OpenViBE::CString rString1,
const OpenViBE::CString rString2 
)
friend

Addition operator.

Parameters
rString1[in] : The first part of the resulting string
rString2[in] : The second part of the resulting string
Returns
The concatenation of rString1 and rString2.
OV_API OpenViBE::boolean operator== ( const OpenViBE::CString rString1,
const OpenViBE::CString rString2 
)
friend

Equality comparison operator.

Parameters
rString1[in] : The first part of the resulting string
rString2[in] : The second part of the resulting string
Returns
true is rString1 is exactly rString2.
false in other case.
Note
This is case sensitive !
OV_API OpenViBE::boolean operator!= ( const OpenViBE::CString rString1,
const OpenViBE::CString rString2 
)
friend

Inequality comparison operator.

Parameters
rString1[in] : The first part of the resulting string
rString2[in] : The second part of the resulting string
Returns
false is rString1 is exactly rString2.
true in other case.
Note
This is case sensitive !
OV_API OpenViBE::boolean operator< ( const OpenViBE::CString rString1,
const OpenViBE::CString rString2 
)
friend

Order comparison operator (necessary to use CString as a key in a stl map)

Parameters
rString1[in] : The first part of the resulting string
rString2[in] : The second part of the resulting string
Returns
false is rString1 is exactly rString2.
true in other case.
Note
This is case sensitive !