29 #ifdef ONIXS_FIXENGINE_CXX17 31 #include <string_view> 38 #ifdef ONIXS_FIXENGINE_CXX17 40 using StringRef = std::basic_string_view<Char>;
69 : chars_(ONIXS_FIXENGINE_NULLPTR),
74 ONIXS_FIXENGINE_CONSTEXPR
84 const std::string & stdStr)
85 : chars_(stdStr.c_str()),
86 size_(stdStr.size()) {
92 size_(cStr ? strlen(cStr) : 0) {
111 ConstIterator
end()
const {
112 return chars_ + size_;
127 reset(ONIXS_FIXENGINE_NULLPTR, 0);
140 operator [](
size_t index)
const {
141 return chars_[index];
145 at(
size_t index)
const {
147 return chars_[index];
149 throw std::invalid_argument(
"index");
167 str.append(chars_, size_);
173 return std::string(chars_, size_);
184 chars_, other.chars_, size_));
195 chars_, other.chars_, size_));
201 std::swap(chars_, other.chars_);
202 std::swap(size_, other.size_);
219 const std::string & str)
228 const std::string & str)
236 const std::string & str,
245 const std::string & str,
292 out.write(ref.chars_, ref.size_);
299 template <
size_t Size>
302 ONIXS_FIXENGINE_CONSTEXPR
322 compareResult = std::memcmp(
327 if(0 == compareResult) {
329 static_cast<ptrdiff_t
>(
333 return (0 > compareResult);
ONIXS_FIXENGINE_API std::ostream & operator<<(std::ostream &os, const Group &group)
Stream output.
const char & at(size_t index) const
ONIXS_FIXENGINE_CONSTEXPR StringRef(const char *chars, size_t size)
The full initialization.
bool operator()(const OnixS::FIX::StringRef &left, const OnixS::FIX::StringRef &right) const
void swap(StringRef &other)
Swaps the content with another instance.
ConstIterator begin() const
The STL-like begin().
ONIXS_FIXENGINE_NODISCARD ONIXS_FIXENGINE_CONSTEXPR StringRef constructStrRef(const char(&value)[Size]) ONIXS_FIXENGINE_NOTHROW
StringRef(const std::string &stdStr)
Initializes an instance from the string content.
#define ONIXS_FIXENGINE_NOTHROW
#define ONIXS_FIXENGINE_API
bool toNumber(NumericType &number) const
Returns the number if the text is a string representation of an integer.
void reset(const char *chars, size_t size)
Updates data being referenced.
std::string toString() const
StringRef()
Initializes the blank instance.
Provides an efficient way of accessing text-based FIX field values.
Allows the use of the StringRef in collections like std::map.
void toString(std::string &str) const
ConstIterator end() const
The STL-like end().
const char * ConstIterator
An immutable iterator over chars.
bool operator==(const FieldValueRef &ref, const std::string &str)
size_t length() const
The number of chars.
bool empty() const
Indicates whether the array has zero length.
size_t size() const
The number of chars.
#define ONIXS_FIXENGINE_NODISCARD
static bool tryParse(const char *buffer, size_t bufferSize, Int32 &number)
void reset()
Resets the reference to nothing.
StringRef(const char *cStr)
Initializes an instance from the zero-terminated string.
const char * data() const
Returns the read-only content.
bool operator!=(const FieldValueRef &ref, const std::string &str)