libMesh::OStringStream Class Reference

#include <o_string_stream.h>

List of all members.

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 196 of file o_string_stream.h.


Member Typedef Documentation

typedef std::string::size_type libMesh::OStringStream::sizetype

convenient typedef

Definition at line 213 of file o_string_stream.h.


Constructor & Destructor Documentation

libMesh::OStringStream::OStringStream (  )  [inline]

Default constructor.

Definition at line 203 of file o_string_stream.h.

00203                    : std::ostringstream()
00204    {
00205      // [JWP] TODO: I will remove this class at the next libmesh
00206      // release or on on March 21, 2013, whichever comes first.
00207      libmesh_deprecated();
00208    }

libMesh::OStringStream::~OStringStream (  )  [inline]

Default destructor.

Definition at line 213 of file o_string_stream.h.

00213 {};


Member Function Documentation

void libMesh::OStringStream::left ( const sizetype  w,
const int  n 
) [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 321 of file o_string_stream.h.

References print_ws().

00323  {
00324    libmesh_assert_less (w, 30);
00325    char buf[30];
00326    // form string as desired
00327    sprintf (buf, "%d", n);
00328    *this << buf;
00329    // pad with whitespaces afterwards
00330    print_ws (w-std::string(buf).size());
00331  }

void libMesh::OStringStream::left ( const sizetype  w,
const sizetype  prec,
const Real  r,
const char  c = ' ' 
) [inline]

Outputs in a OStringStream, where r was directed in ragged left style with size w and precision prec.

Definition at line 300 of file o_string_stream.h.

References print_ws().

00304  {
00305    libmesh_assert_less (w, 30);
00306    char buf[30];
00307    char format[8];
00308    // form the format for r
00309    // ALTERNATIVE: sprintf (format, "%%%d.%df", int((w-prec)/2), prec);
00310    sprintf (format, "%%.%df", prec);
00311    // form string as desired
00312    sprintf (buf, format, r);
00313    *this << buf;
00314    // pad with whitespaces afterwards
00315    print_ws (w-std::string(buf).size(), c);
00316    // ALTERNATIVE: print_ws (w-int((w-prec)/2));
00317  }

void libMesh::OStringStream::left ( const sizetype  w,
const std::string &  s 
) [inline]

Outputs in a OStringStream, where s was directed in ragged left style with size w.

Definition at line 290 of file o_string_stream.h.

References print_ws().

00292  {
00293    *this << s;
00294    // pad with whitespaces afterwards
00295    print_ws ((w-s.size()));
00296  }

void libMesh::OStringStream::print_ws ( const sizetype  n,
const char  c = ' ' 
) [inline, protected]

Appends n chars (defaults to whitespaces) to the string s.

Definition at line 380 of file o_string_stream.h.

Referenced by left(), and right().

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

void libMesh::OStringStream::right ( const sizetype  w,
const sizetype  prec,
const Real  r,
const char  c = ' ' 
) [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 345 of file o_string_stream.h.

References print_ws().

00349  {
00350    libmesh_assert_less (w, 30);
00351    char buf[30];
00352    char format[8];
00353    // form the format for r
00354    sprintf (format, "%%.%df", prec);
00355    // form string as desired
00356    sprintf (buf, format, r);
00357    // first pad with the user-defined char
00358    print_ws (w-std::string(buf).size(), c);
00359    // then print the float
00360    *this << buf;
00361  }

void libMesh::OStringStream::right ( const sizetype  w,
const std::string &  s 
) [inline]

Outputs in a OStringStream, where s was directed in ragged right style with size w.

Definition at line 335 of file o_string_stream.h.

References print_ws().

00337  {
00338    // first pad with whitespaces
00339    print_ws ((w-s.size()));
00340    *this << s;
00341  }

void libMesh::OStringStream::scientific ( const sizetype  w,
const Real  r 
) [inline]

Outputs in a OStringStream, where r was directed in scientific style with size w.

Definition at line 365 of file o_string_stream.h.

00367  {
00368    libmesh_assert_less (w, 30);
00369    char buf[30];
00370    char format[8];
00371    // form the format for r
00372    sprintf (format, "%%%de", w);
00373    // form string as desired
00374    sprintf (buf, format, r);
00375    *this << buf;
00376  }


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

Site Created By: libMesh Developers
Last modified: February 05 2013 19:55:32 UTC

Hosted By:
SourceForge.net Logo