libzypp 17.31.23
zypp::str::Format Class Reference

Convenient building of std::string with boost::format. More...

#include <base/String.h>

Public Member Functions

 Format ()
 
 Format (const std::string &format_r)
 
template<class Tp >
Formatoperator% (Tp &&arg)
 
 operator std::string () const
 
std::string asString () const
 
std::string str () const
 
const boost::format & fmter () const
 
boost::format & fmter ()
 

Protected Attributes

boost::format _fmter
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &str, const Format &obj)
 Stream output.
 

Detailed Description

Convenient building of std::string with boost::format.

Basically a boost::format autoconvertible to std::string for building string arguments.

Note
It won't complain about malformed or incomplete format strings. Usefull when dealing with translations or classes providing a default formater.
void fnc( const std::string & txt_r );
fnc( str::Format("Hello %1%") % 13 );
std::string txt( str::Format("Hello %1%") % 13 );
Convenient building of std::string with boost::format.
Definition: String.h:253

Definition at line 252 of file String.h.

Constructor & Destructor Documentation

◆ Format() [1/2]

zypp::str::Format::Format ( )
inline

Definition at line 254 of file String.h.

◆ Format() [2/2]

zypp::str::Format::Format ( const std::string &  format_r)
inline

Definition at line 255 of file String.h.

Member Function Documentation

◆ operator%()

template<class Tp >
Format & zypp::str::Format::operator% ( Tp &&  arg)
inline

Definition at line 258 of file String.h.

◆ operator std::string()

zypp::str::Format::operator std::string ( ) const
inline

Definition at line 261 of file String.h.

◆ asString()

std::string zypp::str::Format::asString ( ) const
inline

Definition at line 262 of file String.h.

◆ str()

std::string zypp::str::Format::str ( ) const
inline

Definition at line 263 of file String.h.

◆ fmter() [1/2]

const boost::format & zypp::str::Format::fmter ( ) const
inline

Definition at line 265 of file String.h.

◆ fmter() [2/2]

boost::format & zypp::str::Format::fmter ( )
inline

Definition at line 266 of file String.h.

Friends And Related Function Documentation

◆ operator<<()

std::ostream & operator<< ( std::ostream &  str,
const Format obj 
)
related

Stream output.

Definition at line 273 of file String.h.

Member Data Documentation

◆ _fmter

boost::format zypp::str::Format::_fmter
protected

Definition at line 269 of file String.h.


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