Go to the documentation of this file.
70 #ifndef XSENS_NO_WCHAR
72 #endif // XSENS_NO_WCHAR
85 #define XsString_INITIALIZER XSARRAY_INITIALIZER(&g_xsStringDescriptor)
89 #define XSSTRING_INITIALIZER XsString_INITIALIZER
114 #ifndef XSENS_NO_WCHAR
119 #endif // XSENS_NO_WCHAR
123 #define XsString_copy(thisPtr, copy) XsArray_copy(copy, thisPtr)
124 #define XsString_swap(a, b) XsArray_swap(a, b)
134 typedef XsArrayImpl<char, g_xsStringDescriptor, XsString> XsStringType;
141 template<>
inline XsSize XsStringType::size() const noexcept
143 return m_size ? m_size - 1 : 0;
147 template<>
inline void XsStringType::reserve(
XsSize count)
156 template<>
inline XsSize XsStringType::reserved()
const
158 return m_reserved ? m_reserved - 1 : 0;
162 template<>
inline void XsStringType::erase(
XsSize index,
XsSize count)
173 template<>
inline void XsArrayImpl<char, g_xsStringDescriptor, XsString>::insert(
char const* items,
XsSize index,
XsSize count)
193 template<>
inline void XsArrayImpl<char, g_xsStringDescriptor, XsString>::assign(
XsSize count,
char const* src)
202 template<>
inline void XsArrayImpl<char, g_xsStringDescriptor, XsString>::resize(
XsSize count)
212 template<>
inline void XsArrayImpl<char, g_xsStringDescriptor, XsString>::setSize(
XsSize count)
219 template<>
inline void XsArrayImpl<char, g_xsStringDescriptor, XsString>::append(
const XsStringType& other)
224 struct XsString :
public XsStringType
235 inline XsString(
const XsStringType& other)
237 : XsStringType(other)
242 : XsStringType(other)
249 : XsStringType(ref, sz + 1, flags)
252 #ifndef XSENS_NOITERATOR
253 template <
typename Iterator>
255 inline explicit XsString(Iterator
const& beginIt, Iterator
const& endIt)
256 : XsStringType(beginIt, endIt)
269 #ifndef XSENS_NO_WCHAR
280 inline XsString(std::string
const& src)
289 inline XsString(std::wstring
const& src)
295 #endif // XSENS_NO_STL
300 static const char nullChar = 0;
302 return const_cast<char*
>(&nullChar);
303 #ifdef XSENS_NO_EXCEPTION
306 return begin().operator ->();
310 return const_cast<char*
>(&nullChar);
313 return begin().operator->();
318 inline char const* c_str()
const
320 static const char nullChar = 0;
323 #ifdef XSENS_NO_EXCEPTION
326 return begin().operator ->();
333 return begin().operator->();
338 inline std::string toStdString()
const
342 return std::string();
343 return std::string((
char const*)begin().
operator ->());
345 #endif // XSENS_NO_STL
351 tmp.reserve(size() + other.size());
358 std::wstring toStdWString()
const
362 return std::wstring();
369 #endif // XSENS_NO_STL
372 using XsStringType::operator ==;
373 using XsStringType::operator !=;
374 #ifndef XSENS_NOITERATOR
375 using XsStringType::operator <<;
384 return !strcmp(c_str(), str);
394 inline bool operator != (
char const* str)
const
396 return !(*
this == str);
400 inline bool operator != (
XsString const& str)
const
402 return !(*
this == str);
433 inline bool operator < (
const XsString& str)
const
436 return (strcmp(c_str(), str.c_str()) < 0);
438 return (this->toStdString() < str.toStdString());
443 inline bool operator > (
const XsString& str)
const
446 return (strcmp(c_str(), str.c_str()) > 0);
448 return (this->toStdString() > str.toStdString());
468 inline bool empty()
const
474 using XsStringType::append;
478 XsStringType::append(other);
483 inline void append(
char const* other)
492 #ifndef XSENS_NO_WCHAR
493 inline void append(
wchar_t const* other)
505 inline XsSize utf8Len()
const
515 inline bool endsWith(
XsString const& other,
bool caseSensitive =
false)
const
525 inline bool startsWith(
XsString const& other,
bool caseSensitive =
false)
const
536 inline bool contains(
XsString const& other,
bool caseSensitive =
false,
XsSize* offset = 0)
const
541 #ifndef XSENS_NO_WCHAR
547 inline wchar_t utf8At(
XsSize index)
const
553 inline XsString& push_back(
wchar_t c)
569 inline void reverse()
578 inline ptrdiff_t findSubStr(
XsString const& needle)
const
635 inline char last()
const
638 return at(size() - 1);
647 template<
typename _CharT,
typename _Traits>
648 basic_ostream<_CharT, _Traits>&
operator<<(basic_ostream<_CharT, _Traits>& o,
XsString const& xs)
650 return (o << xs.toStdString());
This object describes how to treat the data in an array.
XSTYPES_DLL_API XsSize XsString_copyToWCharArray(const XsString *thisPtr, wchar_t *dest, XsSize size)
This function copies the contents of the object to a unicode wchar_t array.
XSTYPES_DLL_API void XsString_append(XsString *thisPtr, XsString const *other)
This function concatenates the other to this.
XSTYPES_DLL_API int XsString_contains(XsString const *thisPtr, XsString const *other, int caseSensitive, XsSize *offset)
Returns whether this string contains other.
XSTYPES_DLL_API void XsString_mid(XsString *thisPtr, XsString const *source, XsSize start, XsSize count)
Copy a substring of the source string.
XSTYPES_DLL_API void XsString_push_backWChar(XsString *thisPtr, wchar_t c)
Append unicode character c to the string.
XSTYPES_DLL_API wchar_t XsString_utf8At(const XsString *thisPtr, XsSize index)
The decoded UTF-8 character at index index in the UTF-8 encoded string.
XSTYPES_DLL_API void XsString_assignWCharArray(XsString *thisPtr, const wchar_t *src)
This function determines the size of src and copies the contents to the object after converting it fr...
XSTYPES_DLL_API void XsString_replaceAll(XsString *thisPtr, XsString const *src, XsString const *dst)
Replace all occurrences of src with dst, modifying thisPtr.
XSTYPES_DLL_API void XsString_assign(XsString *thisPtr, XsSize count, const char *src)
Reinitializes the XsArray with space for count items and copies them from src.
XSTYPES_DLL_API void XsString_destruct(XsString *thisPtr)
Clears and frees memory allocated by the XsArray.
bool operator==(const XsFilterProfile &lhs, const XsFilterProfile &rhs)
Returns true if lhs has the same type as rhs.
XSTYPES_DLL_API int XsString_endsWith(XsString const *thisPtr, XsString const *other, int caseSensitive)
Returns whether this string ends with other.
XSTYPES_DLL_API ptrdiff_t XsString_findSubStr(XsString const *thisPtr, XsString const *needle)
Find the first occurrence of needle in the string.
size_t XsSize
XsSize must be unsigned number!
XSTYPES_DLL_API void XsString_trimmed(XsString *thisPtr, XsString const *source)
Fills thisPtr with a copy of source with all its leading and trailing whitespace removed.
void XsArray_insert(void *thisPtr, XsSize index, XsSize count, void const *src)
Insert count items from src at index in the array.
XSTYPES_DLL_API int XsString_empty(XsString const *thisPtr)
Returns true when the supplied string is empty.
void XsArray_reserve(void *thisPtr, XsSize count)
Reserves space for count items.
XSTYPES_DLL_API void XsString_push_back(XsString *thisPtr, char c)
Append character c to the string.
ROSCPP_DECL std::string append(const std::string &left, const std::string &right)
XSTYPES_DLL_API void XsString_assignCharArray(XsString *thisPtr, const char *src)
This function determines the size of src and copies the contents to the object.
XSTYPES_DLL_API void XsString_erase(XsString *thisPtr, XsSize index, XsSize count)
Removes a count items from the list starting at index.
const XsArrayDescriptor XSTYPES_DLL_API g_xsStringDescriptor
Descriptor for XsInt64Array.
XSTYPES_DLL_API int XsString_startsWith(XsString const *thisPtr, XsString const *other, int caseSensitive)
Returns whether this string starts with other.
XSTYPES_DLL_API void XsString_construct(XsString *thisPtr)
Initializes the XsString object as an empty string.
XSTYPES_DLL_API XsSize XsString_utf8Len(XsString const *thisPtr)
Returns the number of characters in a UTF-8 encoded string.
XSTYPES_DLL_API void XsString_reverse(XsString *thisPtr)
Reverses the contents of the string.
std::ostream & operator<<(std::ostream &os, JlHexLogger< char > const &hex)
XsDataFlags
These flags define the behaviour of data contained by Xsens data structures.
XSARRAY_STRUCT(XsString, char)
#define XSENS_MSC_WARNING_SUPPRESS(...)
XSTYPES_DLL_API void XsString_sort(XsString *thisPtr)
Sorts the string.
A 0-terminated managed string of characters.
XSTYPES_DLL_API void XsString_resize(XsString *thisPtr, XsSize count)
This function resizes the contained string to the desired size, while retaining its contents.