21 #include "OnixS/CME/DropCopy/Export.h" 30 namespace OnixS {
namespace CME {
namespace DropCopy {
35 class ONIXS_CME_DROP_COPY_EXPORT
String 55 explicit String(
const std::string& stdStr);
58 explicit String(
const char* cStr);
61 String(
const char* text,
size_t textSize);
74 size_t capacity()
const;
78 const char* data()
const;
81 const char* c_str()
const;
87 ConstIterator begin()
const;
95 ConstIterator end()
const;
100 char& operator[](
size_t index);
105 const char& operator[](
size_t index)
const;
109 char& at(
size_t index);
113 const char& at(
size_t index)
const;
118 void reserve(
size_t capacity);
122 void resize(
size_t size);
126 void resize(
size_t size,
char filler);
129 String& insert(
size_t offset,
const char* text,
size_t textSize);
132 String& append(
const char* text,
size_t textSize);
135 String& assign(
const char* text,
size_t textSize);
139 String& replace(
size_t offset,
size_t count,
const char* text,
size_t textSize);
143 void erase(
size_t offset,
size_t count);
149 operator std::string()
const;
161 String& operator =(
const std::string& other);
164 String& operator =(
const char* other);
167 String& operator =(
char other);
173 String& operator +=(
const char* text);
176 String& operator +=(
const std::string& text);
179 String& operator +=(
char character);
184 PreallocatedSize = 3 *
sizeof(size_t)
190 char preallocated_[PreallocatedSize];
192 void grow(
size_t delta);
193 void shrink(
size_t delta);
208 return (capacity_ - 1);
233 return (text_ + size_);
238 return (text_ + size_);
256 throw std::out_of_range(
"index");
264 throw std::out_of_range(
"index");
267 inline String::operator std::string()
const 269 return std::string(text_, size_);
274 return assign(other.data(), other.size());
280 assign(other, strlen(other));
287 return assign(&other, 1);
292 return append(text.
data(), text.
size());
298 append(text, strlen(text));
305 return append(text.data(), text.size());
310 return append(&character, 1);
339 : chars_(other.chars_)
346 : chars_(stdStr.c_str())
347 , size_(stdStr.size())
353 : chars_(ownStr.data())
354 , size_(ownStr.size())
360 : chars_(cStr), size_(cStr ? strlen(cStr) : 0)
385 return chars_ + size_;
411 operator [](
size_t index)
const 413 return chars_[index];
417 at(
size_t index)
const 420 return chars_[index];
422 throw std::invalid_argument(
"index");
427 template<
typename NumericType>
437 str.append(chars_, size_);
443 return std::string(chars_, size_);
447 operator std::string()
const 449 return std::string(chars_, size_);
455 return (size_ == other.size_ && 0 == memcmp(chars_, other.chars_, size_) );
461 return (size_ != other.size_ || 0 != memcmp(chars_, other.chars_, size_) );
467 chars_ = other.chars_;
476 std::swap(chars_, other.chars_);
477 std::swap(size_, other.size_);
554 struct ONIXS_CME_DROP_COPY_EXPORT
less<
OnixS::CME::DropCopy::StringRef>
558 ptrdiff_t compareResult = memcmp(left.
data(), right.
data(), left.
size() < right.
size() ? left.
size() : right.
size());
560 if (0 == compareResult)
562 compareResult =
static_cast<ptrdiff_t
>(left.
size() - right.
size());
565 return (0 > compareResult);
571 struct ONIXS_CME_DROP_COPY_EXPORT
less<
OnixS::CME::DropCopy::String>
581 stream.write(text.
data(), text.
size());
587 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.
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 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.
Zero-terminated sequence of characters.
const char * data() const
Read-only content.
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.