Loading...
Searching...
No Matches
String Utilities
Common » Utilities

Utility functions for std::string. More...

Collaboration diagram for String Utilities:

## Functions

template<typename C>
bool | Dune::hasPrefix (const C &c, const char *prefix)
| Check whether a character container has a given prefix.
template<typename C>
bool | Dune::hasSuffix (const C &c, const char *suffix)
| Check whether a character container has a given suffix.
template<class... T>
static std::string | Dune::formatString (const std::string &s, const T &... args)
| Format values according to printf format string.

## Detailed Description

Utility functions for std::string.

## Function Documentation

## formatString()

template<class... T>

std::string Dune::formatString | ( | const std::string & | s,
|  | const T &... | args )

static

Format values according to printf format string.

Parameters

  s | The format string to be used
  args | The valued to be formatted

This is a wrapper to std::snprintf that provides overflow save printf functionality. For up to 1000 characters a static buffer is used. If this is not sufficient a dynamic buffer of appropriate size is allocated.

## hasPrefix()

template<typename C>

bool Dune::hasPrefix | ( | const C & | c,
|  | const char * | prefix )

Check whether a character container has a given prefix.

The container must support the begin() and size() methods.

## hasSuffix()

template<typename C>

bool Dune::hasSuffix | ( | const C & | c,
|  | const char * | suffix )

Check whether a character container has a given suffix.

The container must support the begin() and size() methods and the const_iterator member type.

Note
  This is slow for containers which don't have random access iterators. In the case of containers with bidirectional iterators, this slowness is unnecessary.