EMA C++ Edition
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
List of all members | Static Public Attributes | Protected Attributes
thomsonreuters::ema::access::EmaString Class Reference

EmaString class is a container of a null terminated Ascii character string. More...

Public Member Functions

Constructor
 EmaString ()
 
 EmaString (const char *str, UInt32 length=EmaString::npos)
 
 EmaString (const EmaString &other)
 
Destructor
virtual ~EmaString ()
 
Operations
EmaStringclear ()
 
EmaStringset (const char *str, UInt32 length=EmaString::npos)
 
EmaStringoperator= (const EmaString &other)
 
EmaStringoperator= (const char *other)
 
EmaStringappend (Int64 value)
 
EmaStringappend (UInt64 value)
 
EmaStringappend (Int32 value)
 
EmaStringappend (UInt32 value)
 
EmaStringappend (float value)
 
EmaStringappend (double value)
 
EmaStringappend (const char *value)
 
EmaStringappend (const EmaString &value)
 
EmaStringoperator+= (Int64 value)
 
EmaStringoperator+= (UInt64 value)
 
EmaStringoperator+= (Int32 value)
 
EmaStringoperator+= (UInt32 value)
 
EmaStringoperator+= (float value)
 
EmaStringoperator+= (double value)
 
EmaStringoperator+= (const char *value)
 
EmaStringoperator+= (const EmaString &value)
 
EmaString operator+ (const EmaString &str) const
 
EmaString operator+ (const char *str) const
 
char & operator[] (UInt32 index)
 
EmaStringtrimWhitespace ()
 
Accessors
bool empty () const
 
virtual const char * c_str () const
 
UInt32 length () const
 
char operator[] (UInt32 index) const
 
EmaString substr (UInt32 index, UInt32 length) const
 
 operator const char * () const
 
Int32 find (const EmaString &str, Int32 index=0) const
 
Int32 find (const char *str, Int32 index=0) const
 
Int32 findLast (const EmaString &str) const
 
Int32 findLast (const char *) const
 
bool operator== (const EmaString &str) const
 
bool operator!= (const EmaString &str) const
 
bool operator> (const EmaString &str) const
 
bool operator< (const EmaString &str) const
 
bool operator>= (const EmaString &str) const
 
bool operator<= (const EmaString &str) const
 
bool operator== (const char *str) const
 
bool operator!= (const char *str) const
 
bool operator> (const char *str) const
 
bool operator< (const char *str) const
 
bool operator>= (const char *str) const
 
bool operator<= (const char *str) const
 
bool caseInsensitiveCompare (const EmaString &str) const
 
bool caseInsensitiveCompare (const char *str) const
 

Static Public Attributes

static const UInt32 npos = -1
 

Protected Attributes

UInt32 _capacity
 
UInt32 _length
 
char * _pString
 

Detailed Description

The following code snippet shows simple usage of EmaString;

EmaString myString( "ABCDEFG" );
Int32 position = myString.find( "DE" ); // Returns 3
position = myString.find("XYZ"); // Returns EmaString::npos (-1)
...
EmaString temp = myString.substr( 3, 4 ) // Returns "DEFG"
temp = myString.substr( 0, EmaString::npos ); // Returns "ABCDEFG"
temp = myString.substr( 4, EmaString::npos ); // Returns "EFG"
...
myString.append( ( Int32 ) 4 );
std::cout << myString << endl; // Prints "ABCDEFG4"
...
Remarks
EmaString class contains a copy of the passed in string.
All methods in this class are Lock-free Method.

Definition at line 56 of file EmaString.h.

Constructor & Destructor Documentation

thomsonreuters::ema::access::EmaString::EmaString ( )

Constructs EmaString.

thomsonreuters::ema::access::EmaString::EmaString ( const char *  str,
UInt32  length = EmaString::npos 
)

Copy constructor.

Remarks
Preallocates memory of passed in length if used as in EmaString( 0, 1000 );
If length parameter is set to 0 (zero), then the actual length is determined looking up for a null character (e.g. strlen()).
Exceptions
OmmMemoryExhaustionExceptionif app runs out of memory
OmmInvalidUsageExceptionif passed in string is longer than MAX_UINT32
Parameters
[in]strpointer to the memory containing copied in character string
[in]lengthspecifies number of characters to copy
thomsonreuters::ema::access::EmaString::EmaString ( const EmaString other)

Copy constructor.

Parameters
[in]othercopied in EmaString object
virtual thomsonreuters::ema::access::EmaString::~EmaString ( )
virtual

Destructor.

Member Function Documentation

EmaString& thomsonreuters::ema::access::EmaString::append ( Int64  value)

Append method. Appends string representation of passed in Int64

Exceptions
OmmMemoryExhaustionExceptionif application runs out of memory
Parameters
[in]valueto be appended to this object
Returns
reference to this object
EmaString& thomsonreuters::ema::access::EmaString::append ( UInt64  value)

Append method. Appends string representation of passed in UInt64

Exceptions
OmmMemoryExhaustionExceptionif application runs out of memory
Parameters
[in]valueto be appended to this object
Returns
reference to this object
EmaString& thomsonreuters::ema::access::EmaString::append ( Int32  value)

Append method. Appends string representation of passed in Int32

Exceptions
OmmMemoryExhaustionExceptionif application runs out of memory
Parameters
[in]valueto be appended to this object
Returns
reference to this object
EmaString& thomsonreuters::ema::access::EmaString::append ( UInt32  value)

Append method. Appends string representation of passed in UInt32

Exceptions
OmmMemoryExhaustionExceptionif application runs out of memory
Parameters
[in]valueto be appended to this object
Returns
reference to this object
EmaString& thomsonreuters::ema::access::EmaString::append ( float  value)

Append method. Appends string representation of passed in float

Exceptions
OmmMemoryExhaustionExceptionif application runs out of memory
Parameters
[in]valueto be appended to this object
Returns
reference to this object
EmaString& thomsonreuters::ema::access::EmaString::append ( double  value)

Append method. Appends string representation of passed in double

Exceptions
OmmMemoryExhaustionExceptionif application runs out of memory
Parameters
[in]valueto be appended to this object
Returns
reference to this object
EmaString& thomsonreuters::ema::access::EmaString::append ( const char *  value)

Append method. Appends string representation of passed in const char*

Exceptions
OmmMemoryExhaustionExceptionif application runs out of memory
Parameters
[in]valueto be appended to this object
Returns
reference to this object
EmaString& thomsonreuters::ema::access::EmaString::append ( const EmaString value)

Append method. Appends string representation of passed in EmaString

Exceptions
OmmMemoryExhaustionExceptionif application runs out of memory
Parameters
[in]valueto be appended to this object
Returns
reference to this object
virtual const char* thomsonreuters::ema::access::EmaString::c_str ( ) const
virtual

method to get pointer to internal null terminated string of characters

Returns
const char pointer used for printing out content of the internal string to screen
bool thomsonreuters::ema::access::EmaString::caseInsensitiveCompare ( const EmaString str) const

Case insensitive comparison operator

Parameters
[in]strspecifies string to match against this object
Returns
true if this object and passed in match; false otherwise
bool thomsonreuters::ema::access::EmaString::caseInsensitiveCompare ( const char *  str) const

Case insensitive comparison operator

Parameters
[in]strspecifies null terminated string to match against this object
Returns
true if this object and passed in match; false otherwise
EmaString& thomsonreuters::ema::access::EmaString::clear ( )

Clears the contained string.

Returns
reference to this object
bool thomsonreuters::ema::access::EmaString::empty ( ) const

check if EmaString is empty

Returns
true if string is empty; false otherwise
Int32 thomsonreuters::ema::access::EmaString::find ( const EmaString str,
Int32  index = 0 
) const

Method to find occurrence of the passed in string.

Remarks
This is a case sensitive method.
Parameters
[in]strspecifies looked up string
[in]indexspecifies position to start the search from
Returns
position where matching string starts; if not found -1
Int32 thomsonreuters::ema::access::EmaString::find ( const char *  str,
Int32  index = 0 
) const

Method to find occurrence of the passed in string.

Remarks
This is a case sensitive method.
Parameters
[in]strspecifies looked up null terminated string of characters
[in]indexspecifies position to start the search from
Returns
position where matching string starts; if not found -1
Int32 thomsonreuters::ema::access::EmaString::findLast ( const EmaString str) const

Method to find occurrence of the passed in string starting from the end

Remarks
This is a case sensitive method.
Parameters
[in]strspecifies looked up string
Returns
position where matching string starts; if not found -1
Int32 thomsonreuters::ema::access::EmaString::findLast ( const char *  ) const

Method to find occurrence of the passed in string from the end

Remarks
This is a case sensitive method.
Parameters
[in]strspecifies looked up null terminated string of characters
Returns
position where matching string starts; if not found -1
UInt32 thomsonreuters::ema::access::EmaString::length ( ) const

Returns length of the contained string. Null termination is not counted in.

Returns
length
thomsonreuters::ema::access::EmaString::operator const char * ( ) const

Conversion operator to const char*

Remarks
invokes c_str()
Returns
const char pointer used for printing out content of the internal string to screen
bool thomsonreuters::ema::access::EmaString::operator!= ( const EmaString str) const

Compare operator

Remarks
This operator is case sensitive.
Parameters
[in]strspecifies string to match against this object
Returns
true if this object and passed in do not match; false otherwise
bool thomsonreuters::ema::access::EmaString::operator!= ( const char *  str) const

Compare operator

Remarks
This operator is case sensitive.
Parameters
[in]strspecifies null terminated string to match against this object
Returns
true if this object and passed in do not match; false otherwise
EmaString thomsonreuters::ema::access::EmaString::operator+ ( const EmaString str) const

Addition operator. Allows a = b + c;

Exceptions
OmmMemoryExhaustionExceptionif application runs out of memory
Parameters
[in]strspecifies EmaString to be added to this EmaString
Returns
result of addition
EmaString thomsonreuters::ema::access::EmaString::operator+ ( const char *  str) const

Addition operator. Allows a = b + c;

Exceptions
OmmMemoryExhaustionExceptionif application runs out of memory
Parameters
[in]strspecifies char string to be added to this EmaString
Returns
result of addition
EmaString& thomsonreuters::ema::access::EmaString::operator+= ( Int64  value)

Append operator. Appends string representation of passed in Int64

Exceptions
OmmMemoryExhaustionExceptionif application runs out of memory
Parameters
[in]valueto be appended to this object
Returns
reference to this object
EmaString& thomsonreuters::ema::access::EmaString::operator+= ( UInt64  value)

Append operator. Appends string representation of passed in UInt64

Exceptions
OmmMemoryExhaustionExceptionif application runs out of memory
Parameters
[in]valueto be appended to this object
Returns
reference to this object
EmaString& thomsonreuters::ema::access::EmaString::operator+= ( Int32  value)

Append operator. Appends string representation of passed in Int32

Exceptions
OmmMemoryExhaustionExceptionif application runs out of memory
Parameters
[in]valueto be appended to this object
Returns
reference to this object
EmaString& thomsonreuters::ema::access::EmaString::operator+= ( UInt32  value)

Append operator. Appends string representation of passed in UInt32

Exceptions
OmmMemoryExhaustionExceptionif application runs out of memory
Parameters
[in]valueto be appended to this object
Returns
reference to this object
EmaString& thomsonreuters::ema::access::EmaString::operator+= ( float  value)

Append operator. Appends string representation of passed in float

Exceptions
OmmMemoryExhaustionExceptionif application runs out of memory
Parameters
[in]valueto be appended to this object
Returns
reference to this object
EmaString& thomsonreuters::ema::access::EmaString::operator+= ( double  value)

Append operator. Appends string representation of passed in double

Exceptions
OmmMemoryExhaustionExceptionif application runs out of memory
Parameters
[in]valueto be appended to this object
Returns
reference to this object
EmaString& thomsonreuters::ema::access::EmaString::operator+= ( const char *  value)

Append operator. Appends string representation of passed in const char*

Exceptions
OmmMemoryExhaustionExceptionif application runs out of memory
Parameters
[in]valueto be appended to this object
Returns
reference to this object
EmaString& thomsonreuters::ema::access::EmaString::operator+= ( const EmaString value)

Append operator. Appends string representation of passed in EmaString

Exceptions
OmmMemoryExhaustionExceptionif application runs out of memory
Parameters
[in]valueto be appended to this object
Returns
reference to this object
bool thomsonreuters::ema::access::EmaString::operator< ( const EmaString str) const

Compare operator

Remarks
This operator is case sensitive.
Parameters
[in]strspecifies string to match against this object
Returns
true if this object is less than the passed in; false otherwise
bool thomsonreuters::ema::access::EmaString::operator< ( const char *  str) const

Compare operator

Remarks
This operator is case sensitive.
Parameters
[in]strspecifies null terminated string to match against this object
Returns
true if this object is less than the passed in; false otherwise
bool thomsonreuters::ema::access::EmaString::operator<= ( const EmaString str) const

Compare operator

Remarks
This operator is case sensitive.
Parameters
[in]strspecifies string to match against this object
Returns
true if this object is less than or equal to the passed in; false otherwise
bool thomsonreuters::ema::access::EmaString::operator<= ( const char *  str) const

Compare operator

Remarks
This operator is case sensitive.
Parameters
[in]strspecifies null terminated string to match against this object
Returns
true if this object is less than or equal the passed in; false otherwise
EmaString& thomsonreuters::ema::access::EmaString::operator= ( const EmaString other)

Assignment operator

Exceptions
OmmMemoryExhaustionExceptionif app runs out of memory
Parameters
[in]othercopied in EmaString object
Returns
reference to this object
EmaString& thomsonreuters::ema::access::EmaString::operator= ( const char *  other)

Assignment operator

Remarks
a null character determines length of the copied in string
Exceptions
OmmMemoryExhaustionExceptionif application runs out of memory
Parameters
[in]othercopied in character string
Returns
reference to this object
bool thomsonreuters::ema::access::EmaString::operator== ( const EmaString str) const

Compare operator

Remarks
This operator is case sensitive.
Parameters
[in]strspecifies string to match against this object
Returns
true if this object and passed in match; false otherwise
bool thomsonreuters::ema::access::EmaString::operator== ( const char *  str) const

Compare operator

Remarks
This operator is case sensitive.
Parameters
[in]strspecifies null terminated string to match against this object
Returns
true if this object and passed in match; false otherwise
bool thomsonreuters::ema::access::EmaString::operator> ( const EmaString str) const

Compare operator

Remarks
This operator is case sensitive.
Parameters
[in]strspecifies string to match against this object
Returns
true if this object is greater than the passed in; false otherwise
bool thomsonreuters::ema::access::EmaString::operator> ( const char *  str) const

Compare operator

Remarks
This operator is case sensitive.
Parameters
[in]strspecifies null terminated string to match against this object
Returns
true if this object is greater than the passed in; false otherwise
bool thomsonreuters::ema::access::EmaString::operator>= ( const EmaString str) const

Compare operator

Remarks
This operator is case sensitive.
Parameters
[in]strspecifies string to match against this object
Returns
true if this object is greater than or equal to the passed in; false otherwise
bool thomsonreuters::ema::access::EmaString::operator>= ( const char *  str) const

Compare operator

Remarks
This operator is case sensitive.
Parameters
[in]strspecifies null terminated string to match against this object
Returns
true if this object is greater than or equal to the passed in; false otherwise
char& thomsonreuters::ema::access::EmaString::operator[] ( UInt32  index)

read write index operator

Exceptions
OmmOutOfRangeExceptionif passed in index is greater than the length of the contained buffer
Parameters
[in]indexspecifies position of a character to be read
Returns
reference to character at the specified position
char thomsonreuters::ema::access::EmaString::operator[] ( UInt32  index) const

read only index operator

Exceptions
OmmOutOfRangeExceptionif passed in index is greater than the length of the contained buffer
Parameters
[in]indexspecifies position of a character to be read
Returns
character at the specified position
EmaString& thomsonreuters::ema::access::EmaString::set ( const char *  str,
UInt32  length = EmaString::npos 
)

Set method. This method copies "length" number of characters from the "str" pointer.

Remarks
Preallocates empty memory of passed in length if used as follows EmaString::set( 0, 1000 );
Exceptions
OmmMemoryExhaustionExceptionif app runs out of memory
OmmInvalidUsageExceptionif passed in string is longer than MAX_UINT32
Parameters
[in]strpointer to the memory containing copied in character string
[in]lengthspecifies number of characters to copy
Returns
reference to this object
EmaString thomsonreuters::ema::access::EmaString::substr ( UInt32  index,
UInt32  length 
) const

sub string operator

Exceptions
OmmOutOfRangeExceptionif passed in index and length resolve to out of range
Parameters
[in]indexspecifies starting position of the sub string
[in]lengthspecifies length of the sub string
Returns
copy of sub string
EmaString& thomsonreuters::ema::access::EmaString::trimWhitespace ( )

removes white spaces from the front and back of the string.

Returns
reference to this object

Member Data Documentation

UInt32 thomsonreuters::ema::access::EmaString::_capacity
mutableprotected

Definition at line 436 of file EmaString.h.

UInt32 thomsonreuters::ema::access::EmaString::_length
protected

Definition at line 435 of file EmaString.h.

char* thomsonreuters::ema::access::EmaString::_pString
mutableprotected

Definition at line 434 of file EmaString.h.

const UInt32 thomsonreuters::ema::access::EmaString::npos = -1
static

npos. Represents the greatest possible value of type unsigned int

Remarks
npos is often used as a length parameter in EmaString methods to mean "until the end of the string"
When used as a return value, npos indicates that the element was "not found"

Definition at line 64 of file EmaString.h.