29 #ifdef ONIXS_FIXENGINE_CXX17 31 #include <string_view> 38 #ifdef ONIXS_FIXENGINE_CXX17 40 using StringRef = std::basic_string_view<Char>;
68 : chars_(ONIXS_FIXENGINE_NULLPTR),
73 ONIXS_FIXENGINE_CONSTEXPR
83 const std::string & stdStr)
84 : chars_(stdStr.c_str()),
85 size_(stdStr.size()) {
91 size_(cStr ? strlen(cStr) : 0) {
110 ConstIterator
end()
const {
111 return chars_ + size_;
126 reset(ONIXS_FIXENGINE_NULLPTR, 0);
139 operator [](
size_t index)
const {
140 return chars_[index];
144 at(
size_t index)
const {
146 return chars_[index];
148 throw std::invalid_argument(
"index");
166 str.append(chars_, size_);
172 return std::string(chars_, size_);
183 chars_, other.chars_, size_));
194 chars_, other.chars_, size_));
200 std::swap(chars_, other.chars_);
201 std::swap(size_, other.size_);
218 const std::string & str)
227 const std::string & str)
235 const std::string & str,
244 const std::string & str,
291 out.write(ref.chars_, ref.size_);
298 template <
size_t Size>
301 ONIXS_FIXENGINE_CONSTEXPR
321 compareResult = std::memcmp(
326 if(0 == compareResult) {
328 static_cast<ptrdiff_t
>(
332 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)
Full initialization.
bool operator()(const OnixS::FIX::StringRef &left, const OnixS::FIX::StringRef &right) const
void swap(StringRef &other)
Swaps content with other instance.
ConstIterator begin() const
STL-like begin().
ONIXS_FIXENGINE_NODISCARD ONIXS_FIXENGINE_CONSTEXPR StringRef constructStrRef(const char(&value)[Size]) ONIXS_FIXENGINE_NOTHROW
StringRef(const std::string &stdStr)
Initializes instance from string content.
#define ONIXS_FIXENGINE_NOTHROW
#define ONIXS_FIXENGINE_API
bool toNumber(NumericType &number) const
Returns number if text is string representation of an integer.
void reset(const char *chars, size_t size)
Updates data being referenced.
std::string toString() const
StringRef()
Initializes blank instance.
Provides efficient way of accessing text-based FIX field values.
Allows using of StringRef in collections like std::map.
void toString(std::string &str) const
ConstIterator end() const
STL-like end().
const char * ConstIterator
Immutable iterator over chars.
bool operator==(const FieldValueRef &ref, const std::string &str)
size_t length() const
Number of chars.
bool empty() const
Indicates whether array of zero length.
size_t size() const
Number of chars.
#define ONIXS_FIXENGINE_NODISCARD
static bool tryParse(const char *buffer, size_t bufferSize, Int32 &number)
void reset()
Resets reference to nothing.
StringRef(const char *cStr)
Initializes instance from zero-terminated string.
const char * data() const
Read-only content.
bool operator!=(const FieldValueRef &ref, const std::string &str)