OnixS C++ FIX Engine  4.6.0
API Documentation
StringRef Class Reference

#include <OnixS/FIXEngine/FIX/StringRef.h>

Public Types

typedef const char * ConstIterator

Public Member Functions

 StringRef ()
ONIXS_FIXENGINE_CONSTEXPR StringRef (const char *chars, size_t size)
 StringRef (const std::string &stdStr)
 StringRef (const char *cStr)
bool empty () const
const char * data () const
ConstIterator begin () const
ConstIterator end () const
size_t size () const
void reset ()
void reset (const char *chars, size_t size)
const char & operator[] (size_t index) const
const char & at (size_t index) const
template<typename NumericType >
bool toNumber (NumericType &number) const
void toString (std::string &str) const
std::string toString () const
bool operator== (const StringRef &other) const
bool operator!= (const StringRef &other) const
void swap (StringRef &other)


std::ostream & operator<< (std::ostream &out, const StringRef &ref)

Detailed Description

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.

Definition at line 45 of file StringRef.h.

Member Typedef Documentation

typedef const char* ConstIterator

Immutable iterator over chars.

Definition at line 51 of file StringRef.h.

Constructor & Destructor Documentation

StringRef ( )

Initializes blank instance.

Definition at line 54 of file StringRef.h.

ONIXS_FIXENGINE_CONSTEXPR StringRef ( const char *  chars,
size_t  size 

Full initialization.

Definition at line 61 of file StringRef.h.

StringRef ( const std::string &  stdStr)

Initializes instance from string content.

Definition at line 69 of file StringRef.h.

StringRef ( const char *  cStr)

Initializes instance from zero-terminated string.

Definition at line 76 of file StringRef.h.

Member Function Documentation

const char& at ( size_t  index) const

Definition at line 126 of file StringRef.h.

ConstIterator begin ( ) const

STL-like begin().

Definition at line 92 of file StringRef.h.

const char* data ( ) const

Read-only content.

Definition at line 87 of file StringRef.h.

bool empty ( ) const

Indicates whether array of zero length.

Definition at line 82 of file StringRef.h.

ConstIterator end ( ) const

STL-like end().

Definition at line 97 of file StringRef.h.

bool operator!= ( const StringRef other) const

Compares with another instance.

Definition at line 170 of file StringRef.h.

bool operator== ( const StringRef other) const

Compares with another instance.

Definition at line 159 of file StringRef.h.

const char& operator[] ( size_t  index) const

Definition at line 121 of file StringRef.h.

void reset ( )

Resets reference to nothing.

Definition at line 107 of file StringRef.h.

void reset ( const char *  chars,
size_t  size 

Updates data being referenced.

Definition at line 113 of file StringRef.h.

size_t size ( ) const

Number of chars.

Definition at line 102 of file StringRef.h.

void swap ( StringRef other)

Swaps content with other instance.

Definition at line 181 of file StringRef.h.

bool toNumber ( NumericType &  number) const

Returns number if text is string representation of an integer.

Definition at line 140 of file StringRef.h.

void toString ( std::string &  str) const

Definition at line 147 of file StringRef.h.

std::string toString ( ) const

Definition at line 153 of file StringRef.h.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const StringRef ref 

Definition at line 279 of file StringRef.h.

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