dbp::format Class Reference

String format. More...

#include <strutils.h>

List of all members.

Public Member Functions

 format (const std::string &source)
 Constructor.
std::string str () const
 Format a string.
template<class T >
formatoperator% (const T &x)
 Assign the formatting parameter.

Friends

std::ostream & operator<< (std::ostream &, format &)
 Format a string.

Detailed Description

String format.

The format class formats a string by replacing of parameter markers by parameter values. Each parameter marker should be in the following format: {x}, where "x" - is a parameter number as passed to the class. Parameters are assigned by % operator, for example:

int i = 1;
// prints "The 1-st test string"
cout << dbp::format("The {0}-st {1} string") % i % "test";

Constructor & Destructor Documentation

dbp::format::format ( const std::string &  source  )  [inline]

Constructor.

Parameters:
source a string to format

Member Function Documentation

template<class T >
format& dbp::format::operator% ( const T &  x  )  [inline]

Assign the formatting parameter.

Parameters:
x a formatting parameter
std::string dbp::format::str (  )  const

Format a string.

Returns:
a formatted string

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  ,
format  
) [friend]

Format a string.

Formats a string and outputs to ostream-compatible class.


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

 
Support This Project
SourceForge.net Logo