Poster of Linux kernelThe best gift for a Linux geek
OStringStream

OStringStream

Section: C Library Functions (3) Updated: Thu Apr 7 2011
Local index Up
 

NAME

OStringStream -  

SYNOPSIS


#include <o_string_stream.h>  

Public Types


typedef std::string::size_type sizetype
 

Public Member Functions


OStringStream ()

~OStringStream ()

void left (const sizetype w, const std::string &s)

void left (const sizetype w, const sizetype prec, const Real r, const char c= ' ')

void left (const sizetype w, const int n)

void right (const sizetype w, const std::string &s)

void right (const sizetype w, const sizetype prec, const Real r, const char c= ' ')

void scientific (const sizetype w, const Real r)
 

Protected Member Functions


void print_ws (const sizetype n, const char c= ' ')
 

Detailed Description

This class provides a compatibility class for broken features in the ostringstream of the older GCC versions. Other compilers do not see this class.

Definition at line 195 of file o_string_stream.h.  

Member Typedef Documentation

 

typedef std::string::size_type OStringStream::sizetypeconvenient typedef

Definition at line 207 of file o_string_stream.h.  

Constructor & Destructor Documentation

 

OStringStream::OStringStream () [inline]Default constructor.

Definition at line 202 of file o_string_stream.h.

: std::ostringstream() {};
 

OStringStream::~OStringStream () [inline]Default destructor.

Definition at line 207 of file o_string_stream.h.

{};
 

Member Function Documentation

 

void OStringStream::left (const sizetypew, const std::string &s) [inline]Outputs in a OStringStream, where s was directed in ragged left style with size w.

Definition at line 284 of file o_string_stream.h.

References print_ws().

 {
   *this << s;
   // pad with whitespaces afterwards
   print_ws ((w-s.size()));
 }
 

void OStringStream::left (const sizetypew, const sizetypeprec, const Realr, const charc = ' ') [inline]Outputs in a OStringStream, where r was directed in ragged left style with size w and precision prec.

Definition at line 294 of file o_string_stream.h.

References print_ws().

 {
   libmesh_assert (w < 30);
   char buf[30];  
   char format[8];
   // form the format for r
   // ALTERNATIVE: sprintf (format, '%%%d.%df', int((w-prec)/2), prec);
   sprintf (format, '%%.%df', prec);
   // form string as desired
   sprintf (buf, format, r);
   *this << buf;
   // pad with whitespaces afterwards
   print_ws (w-std::string(buf).size(), c);
   // ALTERNATIVE: print_ws (w-int((w-prec)/2));
 }
 

void OStringStream::left (const sizetypew, const intn) [inline]Outputs in a OStringStream, where r was directed in ragged left style with size w, padded with chars c, defaults to whitespace.

Definition at line 315 of file o_string_stream.h.

References print_ws().

 {
   libmesh_assert (w < 30);
   char buf[30];  
   // form string as desired
   sprintf (buf, '%d', n);
   *this << buf;
   // pad with whitespaces afterwards
   print_ws (w-std::string(buf).size());
 }
 

void OStringStream::print_ws (const sizetypen, const charc = ' ') [inline, protected]Appends n chars (defaults to whitespaces) to the string s.

Definition at line 374 of file o_string_stream.h.

Referenced by left(), and right().

 {
   for (sizetype i = 0; i < n; i++)
     *this << c;
 }
 

void OStringStream::right (const sizetypew, const std::string &s) [inline]Outputs in a OStringStream, where s was directed in ragged right style with size w.

Definition at line 329 of file o_string_stream.h.

References print_ws().

 {
   // first pad with whitespaces
   print_ws ((w-s.size()));
   *this << s;
 }
 

void OStringStream::right (const sizetypew, const sizetypeprec, const Realr, const charc = ' ') [inline]Outputs in a OStringStream, where r was directed in ragged right style with size w and precision prec. The leading characters are c, defaults to whitespaces.

Definition at line 339 of file o_string_stream.h.

References print_ws().

 {
   libmesh_assert (w < 30);
   char buf[30];  
   char format[8];
   // form the format for r
   sprintf (format, '%%.%df', prec);
   // form string as desired
   sprintf (buf, format, r);
   // first pad with the user-defined char
   print_ws (w-std::string(buf).size(), c);
   // then print the float
   *this << buf;
 }
 

void OStringStream::scientific (const sizetypew, const Realr) [inline]Outputs in a OStringStream, where r was directed in scientific style with size w.

Definition at line 359 of file o_string_stream.h.

 {
   libmesh_assert (w < 30);
   char buf[30];  
   char format[8];
   // form the format for r
   sprintf (format, '%%%de', w);
   // form string as desired
   sprintf (buf, format, r);
   *this << buf;
 }

 

Author

Generated automatically by Doxygen for libMesh from the source code.


 

Index

NAME
SYNOPSIS
Public Types
Public Member Functions
Protected Member Functions
Detailed Description
Member Typedef Documentation
typedef std::string::size_type OStringStream::sizetypeconvenient typedef
Constructor & Destructor Documentation
OStringStream::OStringStream () [inline]Default constructor.
OStringStream::~OStringStream () [inline]Default destructor.
Member Function Documentation
void OStringStream::left (const sizetypew, const std::string &s) [inline]Outputs in a OStringStream, where s was directed in ragged left style with size w.
void OStringStream::left (const sizetypew, const sizetypeprec, const Realr, const charc = ' ') [inline]Outputs in a OStringStream, where r was directed in ragged left style with size w and precision prec.
void OStringStream::left (const sizetypew, const intn) [inline]Outputs in a OStringStream, where r was directed in ragged left style with size w, padded with chars c, defaults to whitespace.
void OStringStream::print_ws (const sizetypen, const charc = ' ') [inline, protected]Appends n chars (defaults to whitespaces) to the string s.
void OStringStream::right (const sizetypew, const std::string &s) [inline]Outputs in a OStringStream, where s was directed in ragged right style with size w.
void OStringStream::right (const sizetypew, const sizetypeprec, const Realr, const charc = ' ') [inline]Outputs in a OStringStream, where r was directed in ragged right style with size w and precision prec. The leading characters are c, defaults to whitespaces.
void OStringStream::scientific (const sizetypew, const Realr) [inline]Outputs in a OStringStream, where r was directed in scientific style with size w.
Author

This document was created by man2html, using the manual pages.
Time: 21:51:51 GMT, April 16, 2011