Public Types | Public Member Functions | Private Attributes | Friends | List of all members
basic_string_view< Char > Class Template Reference

#include <core.h>

Public Types

typedef Char char_type
 
typedef const Char * iterator
 

Public Member Functions

FMT_CONSTEXPR basic_string_view () FMT_NOEXCEPT
 
FMT_CONSTEXPR basic_string_view (const Char *s, size_t count) FMT_NOEXCEPT
 
 basic_string_view (const Char *s)
 
template<typename Alloc >
FMT_CONSTEXPR basic_string_view (const std::basic_string< Char, Alloc > &s) FMT_NOEXCEPT
 
FMT_CONSTEXPR const Char * data () const
 
FMT_CONSTEXPR size_t size () const
 
FMT_CONSTEXPR iterator begin () const
 
FMT_CONSTEXPR iterator end () const
 
FMT_CONSTEXPR void remove_prefix (size_t n)
 
int compare (basic_string_view other) const
 

Private Attributes

const Char * data_
 
size_t size_
 

Friends

bool operator== (basic_string_view lhs, basic_string_view rhs)
 
bool operator!= (basic_string_view lhs, basic_string_view rhs)
 
bool operator< (basic_string_view lhs, basic_string_view rhs)
 
bool operator<= (basic_string_view lhs, basic_string_view rhs)
 
bool operator> (basic_string_view lhs, basic_string_view rhs)
 
bool operator>= (basic_string_view lhs, basic_string_view rhs)
 

Detailed Description

template<typename Char>
class basic_string_view< Char >

An implementation of std::basic_string_view for pre-C++17. It provides a subset of the API. fmt::basic_string_view is used for format strings even if std::string_view is available to prevent issues when a library is compiled with a different -std option than the client code (which is not recommended).

Definition at line 350 of file core.h.

Member Typedef Documentation

template<typename Char>
typedef Char basic_string_view< Char >::char_type

Definition at line 356 of file core.h.

template<typename Char>
typedef const Char* basic_string_view< Char >::iterator

Definition at line 357 of file core.h.

Constructor & Destructor Documentation

template<typename Char>
FMT_CONSTEXPR basic_string_view< Char >::basic_string_view ( )
inline

Definition at line 359 of file core.h.

359 : data_(FMT_NULL), size_(0) {}
size_t size_
Definition: core.h:353
const Char * data_
Definition: core.h:352
#define FMT_NULL
Definition: core.h:107
template<typename Char>
FMT_CONSTEXPR basic_string_view< Char >::basic_string_view ( const Char *  s,
size_t  count 
)
inline

Constructs a string reference object from a C string and a size.

Definition at line 362 of file core.h.

363  : data_(s), size_(count) {}
size_t size_
Definition: core.h:353
const Char * data_
Definition: core.h:352
static QCString * s
Definition: config.cpp:1042
template<typename Char>
basic_string_view< Char >::basic_string_view ( const Char *  s)
inline

Constructs a string reference object from a C string computing the size with std::char_traits<Char>::length.

Definition at line 371 of file core.h.

372  : data_(s), size_(std::char_traits<Char>::length(s)) {}
size_t size_
Definition: core.h:353
const Char * data_
Definition: core.h:352
static QCString * s
Definition: config.cpp:1042
template<typename Char>
template<typename Alloc >
FMT_CONSTEXPR basic_string_view< Char >::basic_string_view ( const std::basic_string< Char, Alloc > &  s)
inline

Constructs a string reference from a std::basic_string object.

Definition at line 376 of file core.h.

378  : data_(s.data()), size_(s.size()) {}
size_t size_
Definition: core.h:353
const Char * data_
Definition: core.h:352

Member Function Documentation

template<typename Char>
FMT_CONSTEXPR iterator basic_string_view< Char >::begin ( ) const
inline

Definition at line 391 of file core.h.

391 { return data_; }
const Char * data_
Definition: core.h:352
template<typename Char>
int basic_string_view< Char >::compare ( basic_string_view< Char >  other) const
inline

Definition at line 400 of file core.h.

400  {
401  size_t str_size = size_ < other.size_ ? size_ : other.size_;
402  int result = std::char_traits<Char>::compare(data_, other.data_, str_size);
403  if (result == 0)
404  result = size_ == other.size_ ? 0 : (size_ < other.size_ ? -1 : 1);
405  return result;
406  }
static QCString result
int compare(unsigned *r, sha1::digest_t const &d)
Definition: sha1_test_2.cc:61
size_t size_
Definition: core.h:353
const Char * data_
Definition: core.h:352
template<typename Char>
FMT_CONSTEXPR const Char* basic_string_view< Char >::data ( ) const
inline

Returns a pointer to the string data.

Definition at line 386 of file core.h.

386 { return data_; }
const Char * data_
Definition: core.h:352
template<typename Char>
FMT_CONSTEXPR iterator basic_string_view< Char >::end ( void  ) const
inline

Definition at line 392 of file core.h.

392 { return data_ + size_; }
size_t size_
Definition: core.h:353
const Char * data_
Definition: core.h:352
template<typename Char>
FMT_CONSTEXPR void basic_string_view< Char >::remove_prefix ( size_t  n)
inline

Definition at line 394 of file core.h.

394  {
395  data_ += n;
396  size_ -= n;
397  }
size_t size_
Definition: core.h:353
const Char * data_
Definition: core.h:352
std::size_t n
Definition: format.h:3399
template<typename Char>
FMT_CONSTEXPR size_t basic_string_view< Char >::size ( void  ) const
inline

Returns the string size.

Definition at line 389 of file core.h.

389 { return size_; }
size_t size_
Definition: core.h:353

Friends And Related Function Documentation

template<typename Char>
bool operator!= ( basic_string_view< Char >  lhs,
basic_string_view< Char >  rhs 
)
friend

Definition at line 411 of file core.h.

411  {
412  return lhs.compare(rhs) != 0;
413  }
int compare(basic_string_view other) const
Definition: core.h:400
template<typename Char>
bool operator< ( basic_string_view< Char >  lhs,
basic_string_view< Char >  rhs 
)
friend

Definition at line 414 of file core.h.

414  {
415  return lhs.compare(rhs) < 0;
416  }
int compare(basic_string_view other) const
Definition: core.h:400
template<typename Char>
bool operator<= ( basic_string_view< Char >  lhs,
basic_string_view< Char >  rhs 
)
friend

Definition at line 417 of file core.h.

417  {
418  return lhs.compare(rhs) <= 0;
419  }
int compare(basic_string_view other) const
Definition: core.h:400
template<typename Char>
bool operator== ( basic_string_view< Char >  lhs,
basic_string_view< Char >  rhs 
)
friend

Definition at line 408 of file core.h.

408  {
409  return lhs.compare(rhs) == 0;
410  }
int compare(basic_string_view other) const
Definition: core.h:400
template<typename Char>
bool operator> ( basic_string_view< Char >  lhs,
basic_string_view< Char >  rhs 
)
friend

Definition at line 420 of file core.h.

420  {
421  return lhs.compare(rhs) > 0;
422  }
int compare(basic_string_view other) const
Definition: core.h:400
template<typename Char>
bool operator>= ( basic_string_view< Char >  lhs,
basic_string_view< Char >  rhs 
)
friend

Definition at line 423 of file core.h.

423  {
424  return lhs.compare(rhs) >= 0;
425  }
int compare(basic_string_view other) const
Definition: core.h:400

Member Data Documentation

template<typename Char>
const Char* basic_string_view< Char >::data_
private

Definition at line 352 of file core.h.

template<typename Char>
size_t basic_string_view< Char >::size_
private

Definition at line 353 of file core.h.


The documentation for this class was generated from the following file: