appkit  1.5.1
RoadNarrows Robotics Application Kit
rnr::io Namespace Reference

Input/Output. More...

Classes

struct  osManipIndent
 Output stream indentation manipulator structure. More...
 

Functions

osManipIndent setindent (const long nIndent)
 Set absolute indentation level. More...
 
osManipIndent deltaindent (const long nDelta)
 Set relative delta indentation level. More...
 
osManipIndent indent ()
 Left indent at current stream indentation level. More...
 
std::ostream & operator<< (std::ostream &os, const osManipIndent &f)
 Insert indentation object into output stream. More...
 
ostream & operator<< (ostream &os, const osManipIndent &f)
 Insert indentation object into output stream. More...
 

Detailed Description

Input/Output.

Function Documentation

osManipIndent rnr::io::deltaindent ( const long  nDelta)

Set relative delta indentation level.

Parameters
nDeltaPlus or minus delta from current indentation level.
Returns
Indent manipulation object.

Definition at line 99 of file IOManip.cxx.

References rnr::io::osManipIndent::m_bOut, rnr::io::osManipIndent::m_eChange, and rnr::io::osManipIndent::m_nIndent.

Referenced by rnr::cmd::CommandLine::c14n(), rnr::cmd::CmdDef::formAt(), rnr::cmd::CmdFormDef::lastArg(), and rnr::cmd::CmdArgDef::lookupFlagNames().

100  {
101  osManipIndent obj;
102 
103  obj.m_nIndent = nDelta;
104  obj.m_eChange = osManipIndent::Relative;
105  obj.m_bOut = false;
106 
107  return obj;
108  }
osManipIndent rnr::io::indent ( )

Left indent at current stream indentation level.

Returns
Indent manipulation object.

Definition at line 115 of file IOManip.cxx.

References rnr::io::osManipIndent::m_bOut, rnr::io::osManipIndent::m_eChange, and rnr::io::osManipIndent::m_nIndent.

Referenced by rnr::cmd::CommandLine::c14n(), rnr::cmd::CmdExec::execute(), rnr::cmd::CmdDef::formAt(), rnr::StateMach::getPrevStateId(), rnr::State::getRefTag(), rnr::cmd::CmdFormDef::lastArg(), rnr::cmd::CmdArgDef::lookupFlagNames(), and rnr::cmd::DataSect::~DataSect().

116  {
117  osManipIndent obj;
118 
119  obj.m_nIndent = 0;
120  obj.m_eChange = osManipIndent::NoChange;
121  obj.m_bOut = true;
122 
123  return obj;
124  }
std::ostream& rnr::io::operator<< ( std::ostream &  os,
const osManipIndent f 
)

Insert indentation object into output stream.

Parameters
osOutput stream.
fObject to insert.
Returns
Reference to output stream.
ostream& rnr::io::operator<< ( ostream &  os,
const osManipIndent f 
)

Insert indentation object into output stream.

Parameters
osOutput stream.
fObject to insert.
Returns
Reference to output stream.

Definition at line 134 of file IOManip.cxx.

References rnr::io::osManipIndent::m_bOut, rnr::io::osManipIndent::m_eChange, and rnr::io::osManipIndent::m_nIndent.

135  {
136  const static int index = os.xalloc();
137 
138  long level;
139 
140  switch( f.m_eChange )
141  {
142  case osManipIndent::Relative:
143  level = os.iword(index) + f.m_nIndent;
144  if( level < 0 )
145  {
146  level = 0;
147  }
148  os.iword(index) = level;
149  break;
150  case osManipIndent::Absolute:
151  level = f.m_nIndent >= 0? f.m_nIndent: 0;
152  os.iword(index) = level;
153  break;
154  case osManipIndent::NoChange:
155  default:
156  break;
157  }
158 
159  if( f.m_bOut )
160  {
161  for(level = 0; level < os.iword(index); ++level)
162  {
163  os << ' ';
164  }
165  }
166 
167  return os;
168  }
osManipIndent rnr::io::setindent ( const long  nIndent)

Set absolute indentation level.

Parameters
nIndentNumber of spaces to left indent.
Returns
Indent manipulation object.

Definition at line 81 of file IOManip.cxx.

References rnr::io::osManipIndent::m_bOut, rnr::io::osManipIndent::m_eChange, and rnr::io::osManipIndent::m_nIndent.

Referenced by rnr::cmd::CommandLine::c14n().

82  {
83  osManipIndent obj;
84 
85  obj.m_nIndent = nIndent;
86  obj.m_eChange = osManipIndent::Absolute;
87  obj.m_bOut = false;
88 
89  return obj;
90  }