OpenCores
URL https://opencores.org/ocsvn/w11/w11/trunk

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.6/] [tools/] [src/] [librtools/] [RosFill.cpp] - Blame information for rev 40

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 wfjm
// $Id: RosFill.cpp 488 2013-02-16 18:49:47Z mueller $
2 10 wfjm
//
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 19 wfjm
  \version $Id: RosFill.cpp 488 2013-02-16 18:49:47Z mueller $
24 10 wfjm
  \brief   Implemenation of RosFill .
25
*/
26
 
27
#include "RosFill.hpp"
28
 
29
using namespace std;
30
 
31
/*!
32
  \class Retro::RosFill
33
  \brief I/O appicator to generate fill characters.
34
 
35
  An \c RosFill object will add a given number of fill characters to an output
36
  stream each time the object is inserted into the stream. The fill character
37
  and the repeat count are specified when the object is constructed.
38
 
39
  A typical usage of \c RosFill is to implement indention, especially when the
40
  amount of indention is only known at runtime. The a Dump() function of a
41
  class may use use \c RosFill following the pattern:
42
  \code
43
void xyz::Dump(ostream& os, int indent) const
44
{
45
  RosFill bl(indent);
46
 
47
  os << bl << "-- xyz " << " @ " << this << endl;
48
  os << bl << "  fMember1:    " << fMember1 << endl;
49
  os << bl << "  fMember2:    " << fMember2 << endl;
50
  fEmbeddedClass.Dump(os, indent+2);
51
  return;
52
}
53
  \endcode
54
 
55
  The indention is passed with \c indent. The object \c bl is setup to
56
  create \c indent blanks and thrown into the outstream \c os at the
57
  start of each output line. The \c Dump() function of member variables of
58
  class type is called with a increamented indention (here \c indent+2).
59
  This finally produces a nicely structured output.
60
*/
61
 
62 19 wfjm
// all method definitions in namespace Retro
63
namespace Retro {
64
 
65 10 wfjm
//------------------------------------------+-----------------------------------
66
/*!
67
  \relates RosFill
68
  \brief ostream insertion operator.
69
*/
70
 
71 19 wfjm
std::ostream& operator<<(std::ostream& os, const RosFill& obj)
72 10 wfjm
{
73
  for (int i=0; i<obj.Count(); i++) os.put(obj.Fill());
74
  return os;
75
}
76
 
77
//------------------------------------------+-----------------------------------
78
/*!
79
  \relates RosFill
80
  \brief string insertion operator.
81
*/
82
 
83 19 wfjm
std::string& operator<<(std::string& os, const RosFill& obj)
84 10 wfjm
{
85
  for (int i=0; i<obj.Count(); i++) os.push_back(obj.Fill());
86
  return os;
87
}
88
 
89 19 wfjm
} // end namespace Retro

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.