gem5  v21.0.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Functions
str.hh File Reference
#include <cstring>
#include <limits>
#include <locale>
#include <stdexcept>
#include <string>
#include <type_traits>
#include <vector>
#include "base/logging.hh"

Go to the source code of this file.

Functions

void eat_lead_white (std::string &s)
 
void eat_end_white (std::string &s)
 
void eat_white (std::string &s)
 
std::string to_lower (const std::string &s)
 
bool split_first (const std::string &s, std::string &lhs, std::string &rhs, char c)
 
bool split_last (const std::string &s, std::string &lhs, std::string &rhs, char c)
 
void tokenize (std::vector< std::string > &vector, const std::string &s, char token, bool ign=true)
 
template<class T >
std::enable_if_t<(std::is_integral< T >::value||std::is_floating_point< T >::value||std::is_enum< T >::value) &&!std::is_same< bool, T >::value, bool > to_number (const std::string &value, T &retval)
 Turn a string representation of a number, either integral, floating point, or enum into an actual number. More...
 
bool to_bool (const std::string &value, bool &retval)
 Turn a string representation of a boolean into a boolean value. More...
 
std::string quote (const std::string &s)
 
bool startswith (const char *s, const char *prefix)
 Return true if 's' starts with the prefix string 'prefix'. More...
 
bool startswith (const std::string &s, const char *prefix)
 Return true if 's' starts with the prefix string 'prefix'. More...
 
bool startswith (const std::string &s, const std::string &prefix)
 Return true if 's' starts with the prefix string 'prefix'. More...
 
String to number helper functions for signed and unsigned

integeral type, as well as enums and floating-point types.

template<class T >
std::enable_if_t< std::is_integral< T >::value &&std::is_signed< T >::value, T > __to_number (const std::string &value)
 
template<class T >
std::enable_if_t< std::is_integral< T >::value &&!std::is_signed< T >::value, T > __to_number (const std::string &value)
 
template<class T >
std::enable_if_t< std::is_enum< T >::value, T > __to_number (const std::string &value)
 
template<class T >
std::enable_if_t< std::is_floating_point< T >::value, T > __to_number (const std::string &value)
 

Function Documentation

◆ __to_number() [1/4]

template<class T >
std::enable_if_t<std::is_integral<T>::value && std::is_signed<T>::value, T> __to_number ( const std::string &  value)

Definition at line 113 of file str.hh.

References MipsISA::r.

◆ __to_number() [2/4]

template<class T >
std::enable_if_t<std::is_integral<T>::value && !std::is_signed<T>::value, T> __to_number ( const std::string &  value)

Definition at line 131 of file str.hh.

References MipsISA::r.

◆ __to_number() [3/4]

template<class T >
std::enable_if_t<std::is_enum<T>::value, T> __to_number ( const std::string &  value)

Definition at line 146 of file str.hh.

References MipsISA::r, and X86ISA::type.

◆ __to_number() [4/4]

template<class T >
std::enable_if_t<std::is_floating_point<T>::value, T> __to_number ( const std::string &  value)

Definition at line 158 of file str.hh.

References MipsISA::r.

◆ eat_end_white()

void eat_end_white ( std::string &  s)
inline

Definition at line 56 of file str.hh.

References ArmISA::s.

Referenced by eat_white(), IniFile::load(), and TEST().

◆ eat_lead_white()

void eat_lead_white ( std::string &  s)
inline

Definition at line 46 of file str.hh.

References ArmISA::s.

Referenced by eat_white(), and TEST().

◆ eat_white()

void eat_white ( std::string &  s)
inline

◆ quote()

std::string quote ( const std::string &  s)
inline

Definition at line 218 of file str.hh.

References ArmISA::s.

Referenced by TEST().

◆ split_first()

bool split_first ( const std::string &  s,
std::string &  lhs,
std::string &  rhs,
char  c 
)

Definition at line 35 of file str.cc.

References ArmISA::c, ArmISA::offset, and ArmISA::s.

Referenced by TEST().

◆ split_last()

bool split_last ( const std::string &  s,
std::string &  lhs,
std::string &  rhs,
char  c 
)

Definition at line 50 of file str.cc.

References ArmISA::c, ArmISA::offset, and ArmISA::s.

Referenced by TEST().

◆ startswith() [1/3]

bool startswith ( const char *  s,
const char *  prefix 
)
inline

Return true if 's' starts with the prefix string 'prefix'.

Definition at line 239 of file str.hh.

References ArmISA::s.

Referenced by Process::absolutePath(), chdirFunc(), Process::checkPathRedirect(), normalizePath(), openatFunc(), procInfo(), System::stripSystemName(), and TEST().

◆ startswith() [2/3]

bool startswith ( const std::string &  s,
const char *  prefix 
)
inline

Return true if 's' starts with the prefix string 'prefix'.

Definition at line 249 of file str.hh.

References ArmISA::s.

◆ startswith() [3/3]

bool startswith ( const std::string &  s,
const std::string &  prefix 
)
inline

Return true if 's' starts with the prefix string 'prefix'.

Definition at line 259 of file str.hh.

References ArmISA::s.

◆ to_bool()

bool to_bool ( const std::string &  value,
bool &  retval 
)
inline

◆ to_lower()

std::string to_lower ( const std::string &  s)
inline

Definition at line 71 of file str.hh.

References ArmISA::c, ArmISA::len, and ArmISA::s.

Referenced by TEST(), and to_bool().

◆ to_number()

template<class T >
std::enable_if_t<(std::is_integral<T>::value || std::is_floating_point<T>::value || std::is_enum<T>::value) && !std::is_same<bool, T>::value, bool> to_number ( const std::string &  value,
T &  retval 
)
inline

Turn a string representation of a number, either integral, floating point, or enum into an actual number.

Use to_bool for booleans.

Parameters
valueThe string representing the number
retvalThe resulting value
Returns
True if the parsing was successful

Definition at line 183 of file str.hh.

References panic.

◆ tokenize()

void tokenize ( std::vector< std::string > &  vector,
const std::string &  s,
char  token,
bool  ign = true 
)

Generated on Tue Mar 23 2021 19:41:31 for gem5 by doxygen 1.8.17