w11 - cpp 0.794
Backend server for Rlink and w11
Loading...
Searching...
No Matches
Retro::RosFill Class Reference

I/O appicator to generate fill characters. More...

#include <RosFill.hpp>

Public Member Functions

 RosFill (int count=0, char fill=' ')
 Constructor.
 
int Count () const
 Get repeat count.
 
char Fill () const
 Get fill character.
 

Private Attributes

int fCount
 blank count
 
char fFill
 fill character
 

Related Functions

(Note that these are not member functions.)

std::ostream & operator<< (std::ostream &os, const RosFill &obj)
 ostream insertion operator.
 
std::string & operator<< (std::string &os, const RosFill &obj)
 string insertion operator.
 

Detailed Description

I/O appicator to generate fill characters.

An RosFill object will add a given number of fill characters to an output stream each time the object is inserted into the stream. The fill character and the repeat count are specified when the object is constructed.

A typical usage of RosFill is to implement indention, especially when the amount of indention is only known at runtime. The a Dump() function of a class may use use RosFill following the pattern:

void xyz::Dump(ostream& os, int indent) const
{
RosFill bl(indent);
os << bl << "-- xyz " << " @ " << this << endl;
os << bl << " fMember1: " << fMember1 << endl;
os << bl << " fMember2: " << fMember2 << endl;
fEmbeddedClass.Dump(os, indent+2);
return;
}
I/O appicator to generate fill characters.
Definition: RosFill.hpp:24

The indention is passed with indent. The object bl is setup to create indent blanks and thrown into the outstream os at the start of each output line. The Dump() function of member variables of class type is called with a increamented indention (here indent+2). This finally produces a nicely structured output.

Definition at line 24 of file RosFill.hpp.

Constructor & Destructor Documentation

◆ RosFill()

Retro::RosFill::RosFill ( int  count = 0,
char  fill = ' ' 
)
inline

Constructor.

The fill character is specified with fill, the repeat count is specified with count. Note, that RosFill does not have a default constructor and that this constructor is the only means to set this object up. Note also, that the fill argument can be omitted, the default fill character is a blank.

Definition at line 27 of file RosFill.ipp.

Member Function Documentation

◆ Count()

int Retro::RosFill::Count ( ) const
inline

Get repeat count.

Definition at line 35 of file RosFill.ipp.

References fCount.

Referenced by operator<<().

◆ Fill()

char Retro::RosFill::Fill ( ) const
inline

Get fill character.

Definition at line 43 of file RosFill.ipp.

References fFill.

Referenced by operator<<().

Friends And Related Function Documentation

◆ operator<<() [1/2]

std::ostream & operator<< ( std::ostream &  os,
const RosFill obj 
)
related

ostream insertion operator.

Definition at line 60 of file RosFill.cpp.

References Count(), and Fill().

◆ operator<<() [2/2]

std::string & operator<< ( std::string &  os,
const RosFill obj 
)
related

string insertion operator.

Definition at line 72 of file RosFill.cpp.

References Count(), and Fill().

Member Data Documentation

◆ fCount

int Retro::RosFill::fCount
private

blank count

Definition at line 32 of file RosFill.hpp.

Referenced by Count().

◆ fFill

char Retro::RosFill::fFill
private

fill character

Definition at line 33 of file RosFill.hpp.

Referenced by Fill().


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