Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JManip.hh File Reference

I/O manipulators. More...

#include <string>
#include <ostream>
#include <sstream>
#include <iomanip>
#include <functional>

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  JFormat_t
 Data structure for format specifications. More...
 
struct  JFormat
 Auxiliary class to temporarily define format specifications. More...
 
struct  LAMBDA
 Auxiliary data structure to convert (lambda) function to printable object. More...
 

Namespaces

namespace  JLANG
 Auxiliary classes and methods for language specific functionality.
 
namespace  JPP
 This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
 

Enumerations

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

Functions

int JLANG::getIndex ()
 Get index for user I/O manipulation.
 
int getPrintOption (std::ostream &out)
 Get print option.
 
void setPrintOption (std::ostream &out, const int option)
 Set print option.
 
bool getShortprint (std::ostream &out)
 Get short print option.
 
void setShortprint (std::ostream &out)
 Set short print option.
 
bool getMediumprint (std::ostream &out)
 Get medium print option.
 
void setMediumprint (std::ostream &out)
 Set medium print option.
 
bool getLongprint (std::ostream &out)
 Get long print option.
 
void setLongprint (std::ostream &out)
 Set long print option.
 
std::ostream & shortprint (std::ostream &out)
 Set short printing.
 
std::ostream & mediumprint (std::ostream &out)
 Set medium printing.
 
std::ostream & longprint (std::ostream &out)
 Set long printing.
 
std::ostream & newline (std::ostream &out)
 Print newline character.
 
std::ostream & whitespace (std::ostream &out)
 Print white space character.
 
std::ostream & tab (std::ostream &out)
 Print tab character.
 
std::ostream & rewind (std::ostream &out)
 Rewind character.
 
template<class T >
JFormat_tgetFormat ()
 Get format for given type.
 
template<class T >
JFormat_t getFormat (const JFormat_t &format)
 Get format for given type.
 
template<class T >
void setFormat (const JFormat_t &format)
 Set format for given type.
 

Detailed Description

I/O manipulators.

Author
mdejong

Definition in file JManip.hh.

Function Documentation

◆ getPrintOption()

int getPrintOption ( std::ostream & out)
inline

Get print option.

Parameters
outoutput stream
Returns
print option

Definition at line 51 of file JManip.hh.

52{
53 return out.iword(JLANG::getIndex());
54}
int getIndex()
Get index for user I/O manipulation.
Definition JManip.hh:26

◆ setPrintOption()

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

Set print option.

Parameters
outoutput stream
optionprint option

Definition at line 63 of file JManip.hh.

64{
65 out.iword(JLANG::getIndex()) = option;
66}

◆ 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 75 of file JManip.hh.

76{
78}
int getPrintOption(std::ostream &out)
Get print option.
Definition JManip.hh:51
@ SHORT_PRINT
short print
Definition JManip.hh:38

◆ setShortprint()

void setShortprint ( std::ostream & out)
inline

Set short print option.

Parameters
outoutput stream

Definition at line 86 of file JManip.hh.

87{
89}
void setPrintOption(std::ostream &out, const int option)
Set print option.
Definition JManip.hh:63

◆ 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 98 of file JManip.hh.

99{
100 return getPrintOption(out) == JLANG::MEDIUM_PRINT;
101}
@ MEDIUM_PRINT
medium print
Definition JManip.hh:39

◆ setMediumprint()

void setMediumprint ( std::ostream & out)
inline

Set medium print option.

Parameters
outoutput stream

Definition at line 109 of file JManip.hh.

110{
112}

◆ 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 121 of file JManip.hh.

122{
123 return getPrintOption(out) == JLANG::LONG_PRINT;
124}
@ LONG_PRINT
long print
Definition JManip.hh:40

◆ setLongprint()

void setLongprint ( std::ostream & out)
inline

Set long print option.

Parameters
outoutput stream

Definition at line 132 of file JManip.hh.

133{
135}

◆ shortprint()

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

Set short printing.

Parameters
outoutput stream
Returns
output stream

Definition at line 144 of file JManip.hh.

145{
146 setShortprint(out);
147
148 return out;
149}
void setShortprint(std::ostream &out)
Set short print option.
Definition JManip.hh:86

◆ mediumprint()

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

Set medium printing.

Parameters
outoutput stream
Returns
output stream

Definition at line 158 of file JManip.hh.

159{
160 setMediumprint(out);
161
162 return out;
163}
void setMediumprint(std::ostream &out)
Set medium print option.
Definition JManip.hh:109

◆ longprint()

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

Set long printing.

Parameters
outoutput stream
Returns
output stream

Definition at line 172 of file JManip.hh.

173{
174 setLongprint(out);
175
176 return out;
177}
void setLongprint(std::ostream &out)
Set long print option.
Definition JManip.hh:132

◆ newline()

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

Print newline character.

Parameters
outoutput stream
Returns
output stream

Definition at line 186 of file JManip.hh.

187{
188 return out << '\n';
189}

◆ whitespace()

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

Print white space character.

Parameters
outoutput stream
Returns
output stream

Definition at line 198 of file JManip.hh.

199{
200 return out << ' ';
201}

◆ tab()

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

Print tab character.

Parameters
outoutput stream
Returns
output stream

Definition at line 210 of file JManip.hh.

211{
212 return out << '\t';
213}

◆ rewind()

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

Rewind character.

Parameters
outoutput stream
Returns
output stream

Definition at line 222 of file JManip.hh.

223{
224 return (out << '\r').flush();
225}

◆ getFormat() [1/2]

template<class T >
JFormat_t & getFormat ( )
inline

Get format for given type.

Returns
format

Definition at line 682 of file JManip.hh.

683{
684 static JFormat_t manip;
685
686 return manip;
687}
Data structure for format specifications.
Definition JManip.hh:524

◆ getFormat() [2/2]

template<class T >
JFormat_t getFormat ( const JFormat_t & format)
inline

Get format for given type.

Parameters
formatdefault format
Returns
actual format

Definition at line 697 of file JManip.hh.

698{
699 const JFormat_t& buffer = getFormat<T>();
700
701 if (buffer.is_valid())
702 return buffer;
703 else
704 return format;
705}
JFormat_t & getFormat()
Get format for given type.
Definition JManip.hh:682
bool is_valid() const
Check validity of this manipulator.
Definition JManip.hh:574

◆ setFormat()

template<class T >
void setFormat ( const JFormat_t & format)
inline

Set format for given type.

Parameters
formatformat

Definition at line 714 of file JManip.hh.

715{
716 getFormat<T>() = format;
717}