libDwm-0.9.45
DwmStringUtils.hh File Reference

Miscellaneous string utilities. More...

#include <cerrno>
#include <cstdlib>
#include <climits>
#include <iomanip>
#include <iostream>
#include <limits>
#include <sstream>
#include <stdexcept>
#include <string>
#include <typeinfo>
#include <vector>
#include "DwmTypeName.hh"
Include dependency graph for DwmStringUtils.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Dwm::StringUtils::BadStringConversion
 Simple exception class for StringTo(). More...
 

Functions

bool Dwm::StringUtils::HasSuffix (const std::string &str, const std::string &suffix)
 Returns true if str ends with suffix.
 
bool Dwm::StringUtils::StringToVector (const std::string &s, char sep, std::vector< std::string > &result, bool ignoreEmpty=true)
 Populates result with substrings from s, where each substring is separated by sep in s.
 
template<typename T >
bool Dwm::StringUtils::StringToIntegral (const std::string &s, T &target, int base=0)
 
template<typename T >
bool Dwm::StringUtils::StringTo (const std::string &s, T &target)
 
bool Dwm::StringUtils::StringTo (const std::string &s, std::string &target)
 why anyone would every call this, I don't know.
 
bool Dwm::StringUtils::StringTo (const std::string &s, char &target, int base=0)
 
bool Dwm::StringUtils::StringTo (const std::string &s, signed char &target, int base=0)
 
bool Dwm::StringUtils::StringTo (const std::string &s, unsigned char &target, int base=0)
 
bool Dwm::StringUtils::StringTo (const std::string &s, short &target, int base=0)
 
bool Dwm::StringUtils::StringTo (const std::string &s, unsigned short &target, int base=0)
 
bool Dwm::StringUtils::StringTo (const std::string &s, int &target, int base=0)
 
bool Dwm::StringUtils::StringTo (const std::string &s, unsigned int &target, int base=0)
 
bool Dwm::StringUtils::StringTo (const std::string &s, long &target, int base=0)
 
bool Dwm::StringUtils::StringTo (const std::string &s, unsigned long &target, int base=0)
 
bool Dwm::StringUtils::StringTo (const std::string &s, long long &target, int base=0)
 
bool Dwm::StringUtils::StringTo (const std::string &s, unsigned long long &target, int base=0)
 
bool Dwm::StringUtils::StringTo (const std::string &s, float &target)
 
bool Dwm::StringUtils::StringTo (const std::string &s, double &target)
 
bool Dwm::StringUtils::StringTo (const std::string &s, bool &target)
 
template<typename T >
std::string Dwm::StringUtils::ToString (const T &x, std::ios_base &(*iom)(std::ios_base &)=std::dec)
 

Detailed Description

Miscellaneous string utilities.

Function Documentation

◆ HasSuffix()

bool Dwm::StringUtils::HasSuffix ( const std::string & str,
const std::string & suffix )

Returns true if str ends with suffix.

For example, HasSuffix("foo.cc",".cc") would return true.

Here is the call graph for this function:

◆ StringToVector()

bool Dwm::StringUtils::StringToVector ( const std::string & s,
char sep,
std::vector< std::string > & result,
bool ignoreEmpty = true )

Populates result with substrings from s, where each substring is separated by sep in s.

If ignoreEmpty is true, all empty substrings (a result of immediately adjacent instances of sep or trailing instance(s) of sep) are excluded from result. Returns true if any substrings were placed in result.

Here is the call graph for this function: