LibSWOC++ 1.5.14
Solid Wall of C++
Loading...
Searching...
No Matches
string_view_util.h File Reference
#include <bitset>
#include <iosfwd>
#include <memory.h>
#include <string>
#include <string_view>
#include <memory>
#include <limits>
Include dependency graph for string_view_util.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int strcasecmp (const std::string_view &lhs, const std::string_view &rhs)
 
int memcmp (const std::string_view &lhs, const std::string_view &rhs)
 
int strcmp (const std::string_view &lhs, const std::string_view &rhs)
 
void * memcpy (void *dst, const std::string_view &src)
 

Detailed Description

Additional handy utilities for string_view and hence also TextView.

Definition in file string_view_util.h.

Function Documentation

◆ memcmp()

int memcmp ( const std::string_view & lhs,
const std::string_view & rhs )

Compare views with ordering.

Parameters
lhsinput view
rhsinput view
Returns
The ordered comparison value.
  • -1 if lhs is less than rhs
  • 1 if lhs is greater than rhs
  • 0 if the views have identical content.

If one view is the prefix of the other, the shorter view is less (first in the ordering).

Note
For string views, there is no difference between strcmp and memcmp.
See also
strcmp

Definition at line 11 of file string_view_util.cc.

◆ memcpy()

void * memcpy ( void * dst,
const std::string_view & src )
inline

Copy bytes.

Parameters
dstDestination buffer.
srcOriginal string.
Returns
dest

This is a convenience for

memcpy(dst, src.data(), size.size());
void * memcpy(void *dst, const std::string_view &src)

Therefore dst must point at a buffer large enough to hold src. If this is not already determined, then presuming DST_SIZE is the size of the buffer at dst

memcpy(dst, src.prefix(DST_SIZE));

Definition at line 86 of file string_view_util.h.

◆ strcasecmp()

int strcasecmp ( const std::string_view & lhs,
const std::string_view & rhs )

Compare views with ordering, ignoring case.

Parameters
lhsinput view
rhsinput view
Returns
The ordered comparison value.
  • -1 if lhs is less than rhs
  • 1 if lhs is greater than rhs
  • 0 if the views have identical content.

If one view is the prefix of the other, the shorter view is less (first in the ordering).

Definition at line 30 of file string_view_util.cc.

◆ strcmp()

int strcmp ( const std::string_view & lhs,
const std::string_view & rhs )
inline

Compare views with ordering.

Parameters
lhsinput view
rhsinput view
Returns
The ordered comparison value.
  • -1 if lhs is less than rhs
  • 1 if lhs is greater than rhs
  • 0 if the views have identical content.

If one view is the prefix of the other, the shorter view is less (first in the ordering).

Note
For string views, there is no difference between strcmp and memcmp.
See also
memcmp

Definition at line 64 of file string_view_util.h.