TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
fmt::BasicStringRef< Char > Class Template Reference

#include <format.h>

Public Member Functions

 BasicStringRef (const Char *s, std::size_t size)
 
 BasicStringRef (const Char *s)
 
 BasicStringRef (const std::basic_string< Char > &s)
 
std::basic_string< Charto_string () const
 
const Chardata () const
 
std::size_t size () const
 
int compare (BasicStringRef other) const
 

Private Attributes

const Chardata_
 
std::size_t size_
 

Friends

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

Detailed Description

template<typename Char>
class fmt::BasicStringRef< Char >

A string reference. It can be constructed from a C string or std::string.

You can use one of the following typedefs for common character types:

+---------—+----------------------—+ | Type | Definition | +============+=========================+ | StringRef | BasicStringRef<char> | +---------—+----------------------—+ | WStringRef | BasicStringRef<wchar_t> | +---------—+----------------------—+

This class is most useful as a parameter type to allow passing different types of strings to a function, for example::

template <typename... Args> std::string format(StringRef format_str, const Args & ... args);

format("{}", 42); format(std::string("{}"), 42);

Constructor & Destructor Documentation

template<typename Char>
fmt::BasicStringRef< Char >::BasicStringRef ( const Char s,
std::size_t  size 
)
inline

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

412 : data_(s), size_(size) {}
std::size_t size() const
Definition: format.h:444
const Char * data_
Definition: format.h:407
std::size_t size_
Definition: format.h:408
template<typename Char>
fmt::BasicStringRef< Char >::BasicStringRef ( const Char s)
inline

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

float length(float v)
Definition: vectorMath.h:208
const Char * data_
Definition: format.h:407
std::size_t size_
Definition: format.h:408
template<typename Char>
fmt::BasicStringRef< Char >::BasicStringRef ( const std::basic_string< Char > &  s)
inline

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

429  : data_(s.c_str()), size_(s.size()) {}
const Char * data_
Definition: format.h:407
std::size_t size_
Definition: format.h:408

Member Function Documentation

template<typename Char>
int fmt::BasicStringRef< Char >::compare ( BasicStringRef< Char other) const
inline
447  {
448  std::size_t size = size_ < other.size_ ? size_ : other.size_;
449  int result = std::char_traits<Char>::compare(data_, other.data_, size);
450  if (result == 0)
451  result = size_ == other.size_ ? 0 : (size_ < other.size_ ? -1 : 1);
452  return result;
453  }
std::size_t size() const
Definition: format.h:444
const Char * data_
Definition: format.h:407
std::size_t size_
Definition: format.h:408
template<typename Char>
const Char* fmt::BasicStringRef< Char >::data ( ) const
inline

Returns a pointer to the string data.

441 { return data_; }
const Char * data_
Definition: format.h:407

+ Here is the caller graph for this function:

template<typename Char>
std::size_t fmt::BasicStringRef< Char >::size ( ) const
inline

Returns the string size.

444 { return size_; }
std::size_t size_
Definition: format.h:408

+ Here is the caller graph for this function:

template<typename Char>
std::basic_string<Char> fmt::BasicStringRef< Char >::to_string ( ) const
inline

Converts a string reference to an std::string object.

436  {
437  return std::basic_string<Char>(data_, size_);
438  }
const Char * data_
Definition: format.h:407
std::size_t size_
Definition: format.h:408

Friends And Related Function Documentation

template<typename Char>
bool operator!= ( BasicStringRef< Char lhs,
BasicStringRef< Char rhs 
)
friend
458  {
459  return lhs.compare(rhs) != 0;
460  }
template<typename Char>
bool operator< ( BasicStringRef< Char lhs,
BasicStringRef< Char rhs 
)
friend
461  {
462  return lhs.compare(rhs) < 0;
463  }
template<typename Char>
bool operator<= ( BasicStringRef< Char lhs,
BasicStringRef< Char rhs 
)
friend
464  {
465  return lhs.compare(rhs) <= 0;
466  }
template<typename Char>
bool operator== ( BasicStringRef< Char lhs,
BasicStringRef< Char rhs 
)
friend
455  {
456  return lhs.compare(rhs) == 0;
457  }
template<typename Char>
bool operator> ( BasicStringRef< Char lhs,
BasicStringRef< Char rhs 
)
friend
467  {
468  return lhs.compare(rhs) > 0;
469  }
template<typename Char>
bool operator>= ( BasicStringRef< Char lhs,
BasicStringRef< Char rhs 
)
friend
470  {
471  return lhs.compare(rhs) >= 0;
472  }

Member Data Documentation

template<typename Char>
const Char* fmt::BasicStringRef< Char >::data_
private
template<typename Char>
std::size_t fmt::BasicStringRef< Char >::size_
private

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