22 #include "OnixS/CME/DropCopy/Export.h" 31 namespace OnixS {
namespace CME {
namespace DropCopy {
36 class ONIXS_CME_DROP_COPY_EXPORT
String 56 explicit String(
const std::string& stdStr);
59 explicit String(
const char* cStr);
62 String(
const char* text,
size_t textSize);
75 size_t capacity()
const;
79 const char* data()
const;
82 const char* c_str()
const;
88 ConstIterator begin()
const;
96 ConstIterator end()
const;
101 char& operator[](
size_t index);
106 const char& operator[](
size_t index)
const;
110 char& at(
size_t index);
114 const char& at(
size_t index)
const;
119 void reserve(
size_t capacity);
123 void resize(
size_t size);
127 void resize(
size_t size,
char filler);
130 String& insert(
size_t offset,
const char* text,
size_t textSize);
133 String& append(
const char* text,
size_t textSize);
136 String& assign(
const char* text,
size_t textSize);
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;
162 String& operator=(
const std::string& other);
165 String& operator=(
const char* other);
168 String& operator=(
char other);
174 String& operator+=(
const char* text);
177 String& operator+=(
const std::string& text);
180 String& operator+=(
char character);
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");
272 inline String::operator std::string()
const 274 return std::string(text_, size_);
279 return assign(other.data(), other.size());
286 assign(other, strlen(other));
294 return assign(&other, 1);
299 return append(text.
data(), text.
size());
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_;
411 void reset(
const char* chars,
size_t 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_);
560 struct 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);
582 struct ONIXS_CME_DROP_COPY_EXPORT
less<
OnixS::CME::DropCopy::String>
597 stream.write(text.
data(), text.
size());
603 stream.write(text.
data(), text.
size());
const char * c_str() const
Returns string as C string.
char * iterator
Read-write access over characters.
StringRef(const char *chars, size_t size)
Full initialization.
ConstIterator end() const
STL-like end().
bool empty() const
Indicates whether array of zero length.
size_t size() const
Number of characters in the sequence.
std::ostream & operator<<(std::ostream &, const OnixS::CME::DropCopy::Error &)
ConstIterator begin() const
STL-like begin().
Provides efficient way of accessing text-based FIX field values.
char & operator[](size_t index)
String & operator+=(const String &text)
Appends other string to the end.
static bool tryParse(const char *buffer, size_t bufferSize, Int32 &number)
const char * ConstIterator
Read-only access over characters.
bool operator()(const OnixS::CME::DropCopy::String &left, const OnixS::CME::DropCopy::String &right) const
std::string toString() const
void toString(std::string &str) const
bool operator==(const FieldValueRef &ref, const std::string &str)
Allows using of StringRef in collections like std::map.
bool operator!=(const FieldValueRef &ref, const std::string &str)
StringRef(const StringRef &other)
const char * ConstIterator
Immutable iterator over chars.
void reset(const char *chars, size_t size)
Updates data being referenced.
StringRef(const String &ownStr)
Initializes instance from string content.
void swap(StringRef &other)
Swaps content with other instance.
void reset()
Resets reference to nothing.
bool operator!=(const StringRef &other) const
Compares with another instance.
bool empty() const
Indicates whether sequence is empty.
size_t size() const
Number of chars.
bool less(const Decimal &lhs, const Decimal &rhs)
const char * data() const
StringRef()
Initializes blank instance.
iterator begin()
Points to the first element in the sequence.
bool toNumber(NumericType &number) const
StringRef(const char *cStr)
Initializes instance from zero-terminated string.
bool operator==(const StringRef &other) const
Compares with another instance.
Zero-terminated sequence of characters.
const char * data() const
Read-only content.
bool operator()(const OnixS::CME::DropCopy::StringRef &left, const OnixS::CME::DropCopy::StringRef &right) const
StringRef & operator=(const StringRef &other)
Reinitializes from another instance.
const char & operator[](size_t index) const
StringRef(const std::string &stdStr)
Initializes instance from string content.
const char & at(size_t index) const
String & operator=(const String &other)
Reinitializes instance as copy of another one.