1 #ifndef CORELIB___TEMPSTR__HPP
2 #define CORELIB___TEMPSTR__HPP
41 #ifdef NCBI_HAVE_CXX17
42 #include <string_view>
90 #ifdef NCBI_HAVE_CXX17
117 const char*
data(
void)
const;
127 bool empty(
void)
const;
197 operator string(
void)
const;
199 #ifdef NCBI_HAVE_CXX17
200 operator string_view(
void)
const;
212 #if defined(NCBI_TEMPSTR_USE_A_COPY)
214 void x_MakeCopy(
void);
216 void x_DestroyCopy(
void);
229 const char* str2,
size_t len2)
232 tmp.reserve(len1 + len2);
233 tmp.assign(str1, len1);
234 tmp.append(str2, len2);
263 str2.data(), str2.length());
278 return out.write(
str.data(),
str.length());
285 #if defined(NCBI_TEMPSTR_USE_A_COPY)
290 # define NCBI_TEMPSTR_MAKE_COPY() x_MakeCopy()
291 # define NCBI_TEMPSTR_DESTROY_COPY() x_DestroyCopy()
293 # define NCBI_TEMPSTR_MAKE_COPY()
294 # define NCBI_TEMPSTR_DESTROY_COPY()
366 if ( pos >= str_len ) {
380 if ( pos >= str_len ) {
390 #if defined(NCBI_TEMPSTR_USE_A_COPY)
392 void CTempString::x_MakeCopy()
402 void CTempString::x_DestroyCopy(
void)
413 #if defined(NCBI_TEMPSTR_USE_A_COPY)
423 #if defined(NCBI_TEMPSTR_USE_A_COPY)
432 m_Length = strlen(
str);
439 template<
size_t Size>
449 : m_String(
str), m_Length(
len)
465 #if defined(NCBI_TEMPSTR_USE_A_COPY)
469 x_Init(
str.data(),
str.size(), pos,
len);
484 #if defined(NCBI_TEMPSTR_USE_A_COPY)
488 x_Init(
str.data(),
str.size(), pos);
495 #if defined(NCBI_TEMPSTR_USE_A_COPY)
499 x_Init(
str.data(),
str.size(), pos,
len);
503 #ifdef NCBI_HAVE_CXX17
506 : m_String(str_view.data()), m_Length(str_view.
size())
561 for ( ; it != end_it; ++it) {
564 match_it != match_end; ++match_it) {
565 if (*it == *match_it) {
583 if (
match.length()) {
591 for ( ; it >= end_it; --it) {
594 match_it != match_end; ++match_it) {
595 if (*it == *match_it) {
613 if (
match.length()) {
621 for ( ; it >= end_it; --it) {
624 match_it != match_end; ++match_it) {
625 if (*it == *match_it) {
661 if (
match.length() == 0) {
667 if (pos > length_limit) {
670 int res = memcmp(
begin() + pos + 1,
711 if (
match.length() == 0) {
717 int res = memcmp(
begin() + pos + 1,
746 if (
this != &src_str) {
792 return string(data(), length());
796 #ifdef NCBI_HAVE_CXX17
798 CTempString::operator string_view(
void)
const
800 return string_view(data(), length());
808 const int kLess = -1;
809 const int kEqual = 0;
810 const int kGreater = 1;
816 return n2 ? kLess : kEqual;
821 int res = memcmp(
data(),
str.data(),
min(n1, n2));
844 return !(*
this ==
str);
951 #ifdef NCBI_HAVE_CXX17
Helper class to allocate memory for CTempString[Ex] on demand in the functions which need to modify t...
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
std::ofstream out("events_result.xml")
main entry point for tests
#define NCBI_DEPRECATED_CTOR(decl)
Macro used to mark a constructor as deprecated.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
bool operator<(const CTempString str) const
const_iterator end() const
Return an iterator to the string's ending position (one past the end of the represented sequence)
string operator+(const char *str1, const CTempString str2)
CTempString literal(const char(&str)[Size])
Templatized initialization from a string literal.
size_type rfind(const CTempString match, size_type pos=npos) const
Find the first instance of the entire matching string within the current string in a backward directi...
bool operator!=(const CTempString str) const
CTempStringEx substr(size_type pos, size_type len) const
Obtain a substring from this string, beginning at a given offset and extending a specified length.
CTempStringEx substr(size_type pos) const
Obtain a substring from this string, beginning at a given offset.
CTempStringEx & assign(const char *str, size_type len, EZeroAtEnd zero_at_end)
CTempStringEx & assign(const CTempString &str)
void x_Init(const char *str, size_type str_len, size_type pos, size_type len)
CTempString & assign(const char *src_str, size_type len)
Assign new values to the content of the a string.
CTempString::size_type size_type
CTempStringEx(const string &str)
CTempStringEx(const CTempString &str)
CTempStringEx(const char *str, size_type len)
CTempStringEx(const char *str)
bool operator==(const char *str1, const CTempString str2)
CTempStringEx & assign(const CTempString str, size_type pos, size_type count)
CTempStringEx(const CTempString &str, size_type pos)
const char * m_String
Stored pointer to string.
char operator[](size_type pos) const
Index into the current string and provide its character in a read- only fashion.
CTempStringEx(const CTempString &str, size_type pos, size_type len)
string g_CTempString_plus(const char *str1, size_t len1, const char *str2, size_t len2)
const char * const_iterator
CNcbiOstream & operator<<(CNcbiOstream &out, const CTempString str)
const char * data(void) const
Return a pointer to the array represented.
void erase(size_type pos=0)
Truncate the string at some specified position Note: basic_string<> supports additional erase() optio...
bool empty(void) const
Return true if the represented string is empty (i.e., the length is zero)
void clear(void)
Clear value to an empty string.
int compare(const CTempString str) const
Compare the current string with a given string.
bool operator==(const CTempString str) const
size_type find_last_of(const CTempString match, size_type pos=npos) const
Find the last occurrence of any character in the matching string within the current string,...
void clear(void)
Clears the string.
size_type m_Length
Length of string.
size_type find_last_not_of(const CTempString match, size_type pos=npos) const
Find the last occurrence of any character not in the matching string within the current string,...
size_type length(void) const
Return the length of the represented array.
CTempString & operator=(const CTempString str)
bool operator!=(const char *str1, const CTempString str2)
CTempString substr(size_type pos) const
Obtain a substring from this string, beginning at a given offset.
#define NCBI_TEMPSTR_DESTROY_COPY()
size_type find_first_not_of(const CTempString match, size_type pos=0) const
Find the first occurrence of any character not in the matching string within the current string,...
bool HasZeroAtEnd(void) const
#define NCBI_TEMPSTR_MAKE_COPY()
size_type find_first_of(const CTempString match, size_type pos=0) const
Find the first occurrence of any character in the matching string within the current string,...
size_type find(const CTempString match, size_type pos=0) const
Find the first instance of the entire matching string within the current string, beginning at an opti...
CTempStringEx & assign(const char *str, size_type len)
Assign new values to the content of the a string.
CTempStringEx(const string &str, size_type pos, size_type len)
CTempStringEx & assign(const CTempStringEx &str)
bool operator<(const char *str1, const CTempString str2)
size_type size(void) const
Return the length of the represented array.
bool operator>(const CTempString str) const
void Copy(string &dst, size_type pos, size_type len) const
Copy a substring into a string Somewhat similar to basic_string::assign()
static const size_type npos
bool operator>(const char *str1, const CTempString str2)
const_iterator begin() const
Return an iterator to the string's starting position.
CTempStringEx(const char *str, size_type len, EZeroAtEnd zero_at_end)
@ eNoZeroAtEnd
For compatibility with older code.
#define NCBI_XNCBI_EXPORT
const struct ncbi::grid::netcache::search::fields::SIZE size
Defines NCBI C++ exception handling.
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
static int match(register const pcre_uchar *eptr, register const pcre_uchar *ecode, const pcre_uchar *mstart, int offset_top, match_data *md, eptrblock *eptrb, unsigned int rdepth)
static const char * str(char *buf, int n)