OnixS C++ FIX Engine 4.13.0
API Documentation
Loading...
Searching...
No Matches
StringRef Class Reference

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
size_t length () 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)

Friends

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 the same message instance is used to update a few fields and is sent over the FIX session multiple times. Also, when a message comes from the network and is deserialized from its raw (tag=value) presentation, all field values represent text segments. To access textual values, the 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 a 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 59 of file StringRef.h.

Member Typedef Documentation

◆ ConstIterator

typedef const char* ConstIterator

An immutable iterator over chars.

Definition at line 65 of file StringRef.h.

Constructor & Destructor Documentation

◆ StringRef() [1/4]

StringRef ( )
inline

Initializes the blank instance.

Definition at line 68 of file StringRef.h.

◆ StringRef() [2/4]

ONIXS_FIXENGINE_CONSTEXPR StringRef ( const char * chars,
size_t size )
inline

The full initialization.

Definition at line 75 of file StringRef.h.

◆ StringRef() [3/4]

StringRef ( const std::string & stdStr)
inlineexplicit

Initializes an instance from the string content.

Definition at line 83 of file StringRef.h.

◆ StringRef() [4/4]

StringRef ( const char * cStr)
inline

Initializes an instance from the zero-terminated string.

Definition at line 90 of file StringRef.h.

Member Function Documentation

◆ at()

const char & at ( size_t index) const
inline

Definition at line 145 of file StringRef.h.

◆ begin()

ConstIterator begin ( ) const
inline

The STL-like begin().

Definition at line 106 of file StringRef.h.

◆ data()

const char * data ( ) const
inline

Returns the read-only content.

Definition at line 101 of file StringRef.h.

◆ empty()

bool empty ( ) const
inline

Indicates whether the array has zero length.

Definition at line 96 of file StringRef.h.

◆ end()

ConstIterator end ( ) const
inline

The STL-like end().

Definition at line 111 of file StringRef.h.

◆ length()

size_t length ( ) const
inline

The number of chars.

Definition at line 121 of file StringRef.h.

◆ operator!=()

bool operator!= ( const StringRef & other) const
inline

Compares with another instance.

Definition at line 189 of file StringRef.h.

◆ operator==()

bool operator== ( const StringRef & other) const
inline

Compares with another instance.

Definition at line 178 of file StringRef.h.

◆ operator[]()

const char & operator[] ( size_t index) const
inline

Definition at line 140 of file StringRef.h.

◆ reset() [1/2]

void reset ( )
inline

Resets the reference to nothing.

Definition at line 126 of file StringRef.h.

◆ reset() [2/2]

void reset ( const char * chars,
size_t size )
inline

Updates data being referenced.

Definition at line 132 of file StringRef.h.

◆ size()

size_t size ( ) const
inline

The number of chars.

Definition at line 116 of file StringRef.h.

◆ swap()

void swap ( StringRef & other)
inline

Swaps the content with another instance.

Definition at line 200 of file StringRef.h.

◆ toNumber()

template<typename NumericType>
bool toNumber ( NumericType & number) const
inline

Returns the number if the text is a string representation of an integer.

Definition at line 159 of file StringRef.h.

◆ toString() [1/2]

std::string toString ( ) const
inline

Definition at line 172 of file StringRef.h.

◆ toString() [2/2]

void toString ( std::string & str) const
inline

Definition at line 166 of file StringRef.h.

◆ operator<<

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

Definition at line 289 of file StringRef.h.