1 |
10 |
wfjm |
// $Id: RosFill.cpp 364 2011-02-26 08:33:01Z mueller $
|
2 |
|
|
//
|
3 |
|
|
// Copyright 2000-2011 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
4 |
|
|
//
|
5 |
|
|
// This program is free software; you may redistribute and/or modify it under
|
6 |
|
|
// the terms of the GNU General Public License as published by the Free
|
7 |
|
|
// Software Foundation, either version 2, or at your option any later version.
|
8 |
|
|
//
|
9 |
|
|
// This program is distributed in the hope that it will be useful, but
|
10 |
|
|
// WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY
|
11 |
|
|
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
12 |
|
|
// for complete details.
|
13 |
|
|
//
|
14 |
|
|
// Revision History:
|
15 |
|
|
// Date Rev Version Comment
|
16 |
|
|
// 2011-02-25 364 1.1 Support << also to string
|
17 |
|
|
// 2011-01-30 357 1.0 Adopted from RosFill
|
18 |
|
|
// 2000-02-29 - - Last change on RosFill
|
19 |
|
|
// ---------------------------------------------------------------------------
|
20 |
|
|
|
21 |
|
|
/*!
|
22 |
|
|
\file
|
23 |
|
|
\version $Id: RosFill.cpp 364 2011-02-26 08:33:01Z mueller $
|
24 |
|
|
\brief Implemenation of RosFill .
|
25 |
|
|
*/
|
26 |
|
|
|
27 |
|
|
#include "RosFill.hpp"
|
28 |
|
|
|
29 |
|
|
using namespace std;
|
30 |
|
|
using namespace Retro;
|
31 |
|
|
|
32 |
|
|
/*!
|
33 |
|
|
\class Retro::RosFill
|
34 |
|
|
\brief I/O appicator to generate fill characters.
|
35 |
|
|
|
36 |
|
|
An \c RosFill object will add a given number of fill characters to an output
|
37 |
|
|
stream each time the object is inserted into the stream. The fill character
|
38 |
|
|
and the repeat count are specified when the object is constructed.
|
39 |
|
|
|
40 |
|
|
A typical usage of \c RosFill is to implement indention, especially when the
|
41 |
|
|
amount of indention is only known at runtime. The a Dump() function of a
|
42 |
|
|
class may use use \c RosFill following the pattern:
|
43 |
|
|
\code
|
44 |
|
|
void xyz::Dump(ostream& os, int indent) const
|
45 |
|
|
{
|
46 |
|
|
RosFill bl(indent);
|
47 |
|
|
|
48 |
|
|
os << bl << "-- xyz " << " @ " << this << endl;
|
49 |
|
|
os << bl << " fMember1: " << fMember1 << endl;
|
50 |
|
|
os << bl << " fMember2: " << fMember2 << endl;
|
51 |
|
|
fEmbeddedClass.Dump(os, indent+2);
|
52 |
|
|
return;
|
53 |
|
|
}
|
54 |
|
|
\endcode
|
55 |
|
|
|
56 |
|
|
The indention is passed with \c indent. The object \c bl is setup to
|
57 |
|
|
create \c indent blanks and thrown into the outstream \c os at the
|
58 |
|
|
start of each output line. The \c Dump() function of member variables of
|
59 |
|
|
class type is called with a increamented indention (here \c indent+2).
|
60 |
|
|
This finally produces a nicely structured output.
|
61 |
|
|
*/
|
62 |
|
|
|
63 |
|
|
//------------------------------------------+-----------------------------------
|
64 |
|
|
/*!
|
65 |
|
|
\relates RosFill
|
66 |
|
|
\brief ostream insertion operator.
|
67 |
|
|
*/
|
68 |
|
|
|
69 |
|
|
std::ostream& Retro::operator<<(std::ostream& os, const RosFill& obj)
|
70 |
|
|
{
|
71 |
|
|
for (int i=0; i<obj.Count(); i++) os.put(obj.Fill());
|
72 |
|
|
return os;
|
73 |
|
|
}
|
74 |
|
|
|
75 |
|
|
//------------------------------------------+-----------------------------------
|
76 |
|
|
/*!
|
77 |
|
|
\relates RosFill
|
78 |
|
|
\brief string insertion operator.
|
79 |
|
|
*/
|
80 |
|
|
|
81 |
|
|
std::string& Retro::operator<<(std::string& os, const RosFill& obj)
|
82 |
|
|
{
|
83 |
|
|
for (int i=0; i<obj.Count(); i++) os.push_back(obj.Fill());
|
84 |
|
|
return os;
|
85 |
|
|
}
|
86 |
|
|
|
87 |
|
|
//------------------------------------------+-----------------------------------
|
88 |
|
|
#if (defined(Retro_NoInline) || defined(Retro_RosFill_NoInline))
|
89 |
|
|
#define inline
|
90 |
|
|
#include "RosFill.ipp"
|
91 |
|
|
#undef inline
|
92 |
|
|
#endif
|