Jpp
Classes | Namespaces | Macros | Enumerations | Functions
JPrint.hh File Reference
#include <string>
#include <ostream>
#include <sstream>
#include <iomanip>
#include "Jeep/JStreamToolkit.hh"

Go to the source code of this file.

Classes

struct  WIDTH
 Auxiliary data structure for alignment of data. More...
 
struct  LEFT
 Auxiliary data structure for alignment of data. More...
 
struct  RIGHT
 Auxiliary data structure for alignment of data. More...
 
struct  FILL
 Auxiliary data structure for sequence of same character. More...
 
struct  CENTER
 Auxiliary data structure for alignment of data. More...
 
struct  CENTER::JCenter
 Auxiliary class for format center. More...
 
struct  FIXED
 Auxiliary data structure for floating point format specification. More...
 
struct  SCIENTIFIC
 Auxiliary data structure for floating point format specification. More...
 
struct  JEEPZ
 Auxiliary data structure for streaming of STL containers. More...
 
struct  JEEPZ::JStream
 Auxiliary class for format STL containers. More...
 
struct  JFlags
 Auxiliary class to temporarily modify format specifications. More...
 

Namespaces

 JEEP
 General puprpose classes and methods.
 
 JPP
 This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 

Macros

#define VARGS_STRING(A, B, ...)   MAKE_STRING(B)
 Make string for variadic macro. More...
 
#define MAKE_STRING(A)   (static_cast<std::ostringstream&>(JEEP::getOstream() << A)).str()
 Make string. More...
 
#define MAKE_CSTRING(A)   JEEP::getCString(MAKE_STRING(A))
 Make C-string. More...
 

Enumerations

enum  JEEP::JPrintOption_t { JEEP::SHORT_PRINT = 1, JEEP::MEDIUM_PRINT = 2, JEEP::LONG_PRINT = 3 }
 Print options. More...
 

Functions

int JEEP::getIndex ()
 Get index for user I/O manipulation. More...
 
std::ostream & JEEP::getOstream ()
 Get output stream for conversion to std::string. More...
 
const char * JEEP::getCString (const std::string &input)
 Get output C-string. More...
 
int getPrintOption (std::ostream &out)
 Get print option. More...
 
void setPrintOption (std::ostream &out, const int option)
 Set print option. More...
 
bool getShortprint (std::ostream &out)
 Get short print option. More...
 
void setShortprint (std::ostream &out)
 Set short print option. More...
 
bool getMediumprint (std::ostream &out)
 Get medium print option. More...
 
void setMediumprint (std::ostream &out)
 Set medium print option. More...
 
bool getLongprint (std::ostream &out)
 Get long print option. More...
 
void setLongprint (std::ostream &out)
 Set long print option. More...
 
std::ostream & shortprint (std::ostream &out)
 Set short printing. More...
 
std::ostream & mediumprint (std::ostream &out)
 Set medium printing. More...
 
std::ostream & longprint (std::ostream &out)
 Set long printing. More...
 
std::ostream & newline (std::ostream &out)
 Print newline character. More...
 
std::ostream & whitespace (std::ostream &out)
 Print white space character. More...
 
std::ostream & tab (std::ostream &out)
 Print tab character. More...
 
std::ostream & rewind (std::ostream &out)
 Rewind character. More...
 

Detailed Description

I/O formatting auxiliaries.

Author
mdejong

Definition in file JPrint.hh.

Macro Definition Documentation

◆ VARGS_STRING

#define VARGS_STRING (   A,
  B,
  ... 
)    MAKE_STRING(B)

Make string for variadic macro.

When called,

  • first argument should correspond to a dummy value;
  • second to the ##__VA_ARGS__ macro; and
  • third to the fall back value (e.g. "");
Parameters
Adummy value
B##__VA_ARGS__ macro
Returns
std::string

Definition at line 690 of file JPrint.hh.

◆ MAKE_STRING

#define MAKE_STRING (   A)    (static_cast<std::ostringstream&>(JEEP::getOstream() << A)).str()

Make string.

Parameters
Astd::ostream compatible construct
Returns
std::string

Definition at line 699 of file JPrint.hh.

◆ MAKE_CSTRING

#define MAKE_CSTRING (   A)    JEEP::getCString(MAKE_STRING(A))

Make C-string.

Parameters
Astd::ostream compatible construct
Returns
C-string

Definition at line 708 of file JPrint.hh.

Function Documentation

◆ getPrintOption()

int getPrintOption ( std::ostream &  out)
inline

Get print option.

Parameters
outoutput stream
Returns
print option

Definition at line 87 of file JPrint.hh.

88 {
89  return out.iword(JEEP::getIndex());
90 }

◆ setPrintOption()

void setPrintOption ( std::ostream &  out,
const int  option 
)
inline

Set print option.

Parameters
outoutput stream
optionprint option

Definition at line 99 of file JPrint.hh.

100 {
101  out.iword(JEEP::getIndex()) = option;
102 }

◆ getShortprint()

bool getShortprint ( std::ostream &  out)
inline

Get short print option.

Parameters
outoutput stream
Returns
true if short print option is on; else false

Definition at line 111 of file JPrint.hh.

112 {
113  return getPrintOption(out) == JEEP::SHORT_PRINT;
114 }

◆ setShortprint()

void setShortprint ( std::ostream &  out)
inline

Set short print option.

Parameters
outoutput stream

Definition at line 122 of file JPrint.hh.

123 {
124  return setPrintOption(out, JEEP::SHORT_PRINT);
125 }

◆ getMediumprint()

bool getMediumprint ( std::ostream &  out)
inline

Get medium print option.

Parameters
outoutput stream
Returns
true if medium print option is on; else false

Definition at line 134 of file JPrint.hh.

135 {
136  return getPrintOption(out) == JEEP::MEDIUM_PRINT;
137 }

◆ setMediumprint()

void setMediumprint ( std::ostream &  out)
inline

Set medium print option.

Parameters
outoutput stream

Definition at line 145 of file JPrint.hh.

146 {
147  return setPrintOption(out, JEEP::MEDIUM_PRINT);
148 }

◆ getLongprint()

bool getLongprint ( std::ostream &  out)
inline

Get long print option.

Parameters
outoutput stream
Returns
true if long print option is on; else false

Definition at line 157 of file JPrint.hh.

158 {
159  return getPrintOption(out) == JEEP::LONG_PRINT;
160 }

◆ setLongprint()

void setLongprint ( std::ostream &  out)
inline

Set long print option.

Parameters
outoutput stream

Definition at line 168 of file JPrint.hh.

169 {
170  return setPrintOption(out, JEEP::LONG_PRINT);
171 }

◆ shortprint()

std::ostream& shortprint ( std::ostream &  out)
inline

Set short printing.

Parameters
outoutput stream
Returns
output stream

Definition at line 180 of file JPrint.hh.

181 {
182  setShortprint(out);
183 
184  return out;
185 }

◆ mediumprint()

std::ostream& mediumprint ( std::ostream &  out)
inline

Set medium printing.

Parameters
outoutput stream
Returns
output stream

Definition at line 194 of file JPrint.hh.

195 {
196  setMediumprint(out);
197 
198  return out;
199 }

◆ longprint()

std::ostream& longprint ( std::ostream &  out)
inline

Set long printing.

Parameters
outoutput stream
Returns
output stream

Definition at line 208 of file JPrint.hh.

209 {
210  setLongprint(out);
211 
212  return out;
213 }

◆ newline()

std::ostream& newline ( std::ostream &  out)
inline

Print newline character.

Parameters
outoutput stream
Returns
output stream

Definition at line 222 of file JPrint.hh.

223 {
224  return out << '\n';
225 }

◆ whitespace()

std::ostream& whitespace ( std::ostream &  out)
inline

Print white space character.

Parameters
outoutput stream
Returns
output stream

Definition at line 234 of file JPrint.hh.

235 {
236  return out << ' ';
237 }

◆ tab()

std::ostream& tab ( std::ostream &  out)
inline

Print tab character.

Parameters
outoutput stream
Returns
output stream

Definition at line 246 of file JPrint.hh.

247 {
248  return out << '\t';
249 }

◆ rewind()

std::ostream& rewind ( std::ostream &  out)
inline

Rewind character.

Parameters
outoutput stream
Returns
output stream

Definition at line 258 of file JPrint.hh.

259 {
260  return (out << '\r').flush();
261 }
setLongprint
void setLongprint(std::ostream &out)
Set long print option.
Definition: JPrint.hh:168
setMediumprint
void setMediumprint(std::ostream &out)
Set medium print option.
Definition: JPrint.hh:145
setPrintOption
void setPrintOption(std::ostream &out, const int option)
Set print option.
Definition: JPrint.hh:99
setShortprint
void setShortprint(std::ostream &out)
Set short print option.
Definition: JPrint.hh:122
JEEP::LONG_PRINT
long print
Definition: JPrint.hh:41
JEEP::MEDIUM_PRINT
medium print
Definition: JPrint.hh:40
JEEP::SHORT_PRINT
short print
Definition: JPrint.hh:39
JEEP::getIndex
int getIndex()
Get index for user I/O manipulation.
Definition: JPrint.hh:27
getPrintOption
int getPrintOption(std::ostream &out)
Get print option.
Definition: JPrint.hh:87