22#include "OnixS/CME/DropCopy/Export.h"
36class ONIXS_CME_DROP_COPY_EXPORT
String
56 explicit String(
const std::string& stdStr);
62 String(
const char* text,
size_t textSize);
79 const char*
data()
const;
82 const char*
c_str()
const;
110 char&
at(
size_t index);
114 const char&
at(
size_t index)
const;
140 String&
replace(
size_t offset,
size_t count,
const char* text,
size_t textSize);
144 void erase(
size_t offset,
size_t count);
150 operator std::string()
const;
185 PreallocatedSize = 3 *
sizeof(size_t)
191 char preallocated_[PreallocatedSize];
193 void grow(
size_t delta);
194 void shrink(
size_t delta);
209 return (capacity_ - 1);
234 return (text_ + size_);
239 return (text_ + size_);
259 throw std::out_of_range(
"index");
269 throw std::out_of_range(
"index");
272inline String::operator std::string()
const
274 return std::string(text_, size_);
279 return assign(other.data(), other.size());
286 assign(other, strlen(other));
306 append(text, strlen(text));
314 return append(text.data(), text.size());
319 return append(&character, 1);
348 : chars_(other.chars_)
355 : chars_(stdStr.c_str())
356 , size_(stdStr.
size())
362 : chars_(ownStr.
data())
363 , size_(ownStr.
size())
370 , size_(cStr ? strlen(cStr) : 0)
395 return chars_ + size_;
419 return chars_[index];
422 const char&
at(
size_t index)
const
426 return chars_[index];
429 throw std::invalid_argument(
"index");
434 template <
typename NumericType>
443 str.append(chars_, size_);
449 return std::string(chars_, size_);
453 operator std::string()
const
455 return std::string(chars_, size_);
461 return (size_ == other.size_ && 0 == memcmp(chars_, other.chars_, size_));
467 return (size_ != other.size_ || 0 != memcmp(chars_, other.chars_, size_));
473 chars_ = other.chars_;
482 std::swap(chars_, other.chars_);
483 std::swap(size_, other.size_);
560struct ONIXS_CME_DROP_COPY_EXPORT less<
OnixS::CME::DropCopy::StringRef>
567 ptrdiff_t compareResult = memcmp(
571 if (0 == compareResult)
573 compareResult =
static_cast<ptrdiff_t
>(left.
size() - right.
size());
576 return (0 > compareResult);
582struct ONIXS_CME_DROP_COPY_EXPORT less<
OnixS::CME::DropCopy::String>
589 return std::less<OnixS::CME::DropCopy::StringRef>()(
597 stream.write(text.
data(), text.
size());
603 stream.write(text.
data(), text.
size());
Provides efficient way of accessing text-based FIX field values.
bool toNumber(NumericType &number) const
bool operator==(const StringRef &other) const
Compares with another instance.
StringRef & operator=(const StringRef &other)
Reinitializes from another instance.
std::string toString() const
size_t size() const
Number of chars.
StringRef()
Initializes blank instance.
void toString(std::string &str) const
StringRef(const String &ownStr)
Initializes instance from string content.
bool empty() const
Indicates whether array of zero length.
ConstIterator end() const
STL-like end().
bool operator!=(const StringRef &other) const
Compares with another instance.
const char * ConstIterator
Immutable iterator over chars.
StringRef(const char *cStr)
Initializes instance from zero-terminated string.
void swap(StringRef &other)
Swaps content with other instance.
StringRef(const StringRef &other)
const char & operator[](size_t index) const
const char * data() const
Read-only content.
const char & at(size_t index) const
StringRef(const char *chars, size_t size)
Full initialization.
void reset()
Resets reference to nothing.
ConstIterator begin() const
STL-like begin().
void reset(const char *chars, size_t size)
Updates data being referenced.
StringRef(const std::string &stdStr)
Initializes instance from string content.
Zero-terminated sequence of characters.
void reserve(size_t capacity)
const char * c_str() const
Returns string as C string.
String & replace(size_t offset, size_t count, const char *text, size_t textSize)
String & operator=(const String &other)
Reinitializes instance as copy of another one.
String & assign(const char *text, size_t textSize)
Re-initializes instance with given string.
size_t size() const
Number of characters in the sequence.
String & operator+=(const String &text)
Appends other string to the end.
bool operator==(const String &other) const
Compares with other instance for equality.
String(const String &other)
Initializes as copy of another instance.
String & append(const char *text, size_t textSize)
Appends subsequence to the end.
String(const char *text, size_t textSize)
Initializes from sequence of give size.
void resize(size_t size, char filler)
String & insert(size_t offset, const char *text, size_t textSize)
Inserts subsequence at specified position.
bool operator!=(const String &other) const
Compares with other instance for inequality.
void erase(size_t offset, size_t count)
String(const StringRef &strRef)
bool empty() const
Indicates whether sequence is empty.
const char * ConstIterator
Read-only access over characters.
String()
Initializes empty string.
~String()
Cleans up internal resources.
const char * data() const
iterator begin()
Points to the first element in the sequence.
char * iterator
Read-write access over characters.
void clear()
Erases all characters in the string.
String(const char *cStr)
Initializes as copy of null-terminated C string.
String(const std::string &stdStr)
Initializes as copy of std::string instance.
char & operator[](size_t index)
bool operator==(const FieldValueRef &ref, const std::string &str)
bool operator!=(const FieldValueRef &ref, const std::string &str)
std::ostream & operator<<(std::ostream &, const OnixS::CME::DropCopy::Error &)
static bool tryParse(const char *buffer, size_t bufferSize, Int32 &number)
bool operator()(const OnixS::CME::DropCopy::StringRef &left, const OnixS::CME::DropCopy::StringRef &right) const
bool operator()(const OnixS::CME::DropCopy::String &left, const OnixS::CME::DropCopy::String &right) const