ATLAS Offline Software
Loading...
Searching...
No Matches
FakeBkgTools::Database::StringRef Struct Reference

Note: the following structure is used (instead of a simple std::string) so that XML line numbers can be printed in the error message, which requires keeping track of the position of the string in the original file. More...

#include <Database.h>

Collaboration diagram for FakeBkgTools::Database::StringRef:

Public Member Functions

 operator bool () const
bool operator== (const char *s) const
bool operator!= (const char *s) const
bool operator< (const StringRef &rhs) const
template<class Str>
std::string operator+ (Str s)
 used to check if a piece of text appeared before another piece of text
std::size_t length () const
void clear ()
std::string str () const
 StringRef ()
 StringRef (const char *newptr, const char *newendptr)
 StringRef (const char *newptr, std::size_t length)
void set (const char *newptr, const char *newendptr)
void set (const char *newptr, std::size_t length)
std::string trim () const

Public Attributes

const char * ptr = nullptr
const char * endptr = nullptr

Detailed Description

Note: the following structure is used (instead of a simple std::string) so that XML line numbers can be printed in the error message, which requires keeping track of the position of the string in the original file.

Might be rewritten around a std::string_view one day

Definition at line 95 of file Database.h.

Constructor & Destructor Documentation

◆ StringRef() [1/3]

FakeBkgTools::Database::StringRef::StringRef ( )
inline

Definition at line 113 of file Database.h.

113{}

◆ StringRef() [2/3]

FakeBkgTools::Database::StringRef::StringRef ( const char * newptr,
const char * newendptr )
inline

Definition at line 114 of file Database.h.

114: ptr(newptr), endptr(newendptr) {}

◆ StringRef() [3/3]

FakeBkgTools::Database::StringRef::StringRef ( const char * newptr,
std::size_t length )
inline

Definition at line 115 of file Database.h.

115: ptr(newptr), endptr(newptr+length) {}
std::size_t length() const
Definition Database.h:110

Member Function Documentation

◆ clear()

void FakeBkgTools::Database::StringRef::clear ( )
inline

Definition at line 111 of file Database.h.

111{ ptr = endptr = nullptr; }

◆ length()

std::size_t FakeBkgTools::Database::StringRef::length ( ) const
inline

Definition at line 110 of file Database.h.

110{ return (endptr - ptr); }

◆ operator bool()

FakeBkgTools::Database::StringRef::operator bool ( ) const
inline

Definition at line 98 of file Database.h.

98{ return ptr && endptr && (ptr!=endptr); }

◆ operator!=()

bool FakeBkgTools::Database::StringRef::operator!= ( const char * s) const
inline

Definition at line 107 of file Database.h.

107{ return !operator==(s); }
bool operator==(const char *s) const
Definition Database.h:99

◆ operator+()

template<class Str>
std::string FakeBkgTools::Database::StringRef::operator+ ( Str s)
inline

used to check if a piece of text appeared before another piece of text

Definition at line 109 of file Database.h.

109{ return str() + s; }

◆ operator<()

bool FakeBkgTools::Database::StringRef::operator< ( const StringRef & rhs) const
inline

Definition at line 108 of file Database.h.

108{ return endptr < rhs.ptr; }

◆ operator==()

bool FakeBkgTools::Database::StringRef::operator== ( const char * s) const
inline

C++14

if people don't use a C++14-compliant compiler

Definition at line 99 of file Database.h.

100 {
101 #if __cplusplus >= 201402L
102 return std::equal(ptr, endptr, s, s+std::strlen(s));
103 #else
104 return str() == s;
105 #endif
106 }

◆ set() [1/2]

void FakeBkgTools::Database::StringRef::set ( const char * newptr,
const char * newendptr )
inline

Definition at line 116 of file Database.h.

116{ *this = StringRef(newptr, newendptr); }

◆ set() [2/2]

void FakeBkgTools::Database::StringRef::set ( const char * newptr,
std::size_t length )
inline

Definition at line 117 of file Database.h.

117{ *this = StringRef(newptr, length); }

◆ str()

std::string FakeBkgTools::Database::StringRef::str ( ) const
inline

Definition at line 112 of file Database.h.

112{ return std::string(ptr, endptr); }

◆ trim()

std::string Database::StringRef::trim ( ) const

Definition at line 1162 of file Database.cxx.

1163{
1164 if(!ptr) return "";
1165 auto beg=ptr, end=endptr-1;
1166 while(std::isspace(*beg) && beg<end) ++beg;
1167 while(std::isspace(*end) && end>beg) --end;
1168 return std::string(beg, end+1);
1169}

Member Data Documentation

◆ endptr

const char * FakeBkgTools::Database::StringRef::endptr = nullptr

Definition at line 97 of file Database.h.

◆ ptr

const char* FakeBkgTools::Database::StringRef::ptr = nullptr

Definition at line 97 of file Database.h.


The documentation for this struct was generated from the following files: