OnixS Xetra MDI Market Data Handler for C++  1.0.0.0
Public Types | Public Member Functions | List of all members
StringRef Class Reference

Provides efficient way of accessing text-based FIX field values. More...

Public Types

typedef const char * ConstIterator
 Immutable iterator over chars.
 

Public Member Functions

 StringRef ()
 Initializes blank instance.
 
 StringRef (const char *chars, size_t size)
 Full initialization.
 
 StringRef (const StringRef &other)
 Initializes as clone of other instance. More...
 
 StringRef (const std::string &stdStr)
 Initializes instance from string content.
 
 StringRef (const char *cStr)
 Initializes instance from zero-terminated string.
 
bool empty () const
 Indicates whether array of zero length.
 
const char * data () const
 Read-only content.
 
ConstIterator begin () const
 STL-like begin().
 
ConstIterator end () const
 STL-like end().
 
size_t size () const
 Number of chars.
 
void reset ()
 Resets reference to nothing.
 
void reset (const char *chars, size_t size)
 Updates data being referenced.
 
const char & operator[] (size_t index) const
 
const char & at (size_t index) const
 
template<typename NumericType >
bool toNumber (NumericType &number) const
 Returns number if text is string representation of an integer. More...
 
void toString (std::string &str) const
 
std::string toString () const
 
bool operator== (const StringRef &other) const
 Compares with another instance.
 
bool operator!= (const StringRef &other) const
 Compares with another instance.
 
StringRefoperator= (const StringRef &other)
 Reinitializes from another instance.
 
void swap (StringRef &other)
 Swaps content with other instance.
 

Detailed Description

Provides efficient way of accessing text-based FIX field values.

By default, OnixS::FIX::Message and OnixS::FIX::GroupInstance classes convert all values assigned to the fields into their text presentations and store textual data. This approach optimizes message reuse when same instance of message is used to update a few fields and is sent over FIX session multiple times. Also, when message comes from the network and is deserialized from its raw (tag=value) presentation, all field values in fact represent segments of text. To have access to textual values, StringRef class was added together with new access members (FieldSet::getStringRef()). If value is accessed using FieldSet::getStringRef() member, instance of StringRef class is returned. That instance holds reference to a read-only segment of text. An important aspect is that no memory is allocated and copied while accessing field values that way.

Constructor & Destructor Documentation

StringRef ( const StringRef other)
inline

Initializes as clone of other instance.

Data referenced by clone is not copied. Instead both instances will refer to same text segment.

Member Function Documentation

bool toNumber ( NumericType &  number) const
inline

Returns number if text is string representation of an integer.