Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Namespaces | Enumerations | Functions
JManip.hh File Reference

I/O manipulators. More...

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

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...
 

Namespaces

 JLANG
 Auxiliary classes and methods for language specific functionality.
 
 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. 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...
 
template<class T >
JFormat_tgetFormat ()
 Get format for given type. More...
 
template<class T >
JFormat_t getFormat (const JFormat_t &format)
 Get format for given type. More...
 
template<class T >
void setFormat (const JFormat_t &format)
 Set format for given type. More...
 

Detailed Description

I/O manipulators.

Author
mdejong

Definition in file JManip.hh.

Function Documentation

int getPrintOption ( std::ostream &  out)
inline

Get print option.

Parameters
outoutput stream
Returns
print option

Definition at line 50 of file JManip.hh.

51 {
52  return out.iword(JLANG::getIndex());
53 }
int getIndex()
Get index for user I/O manipulation.
Definition: JManip.hh:25
void setPrintOption ( std::ostream &  out,
const int  option 
)
inline

Set print option.

Parameters
outoutput stream
optionprint option

Definition at line 62 of file JManip.hh.

63 {
64  out.iword(JLANG::getIndex()) = option;
65 }
int getIndex()
Get index for user I/O manipulation.
Definition: JManip.hh:25
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 74 of file JManip.hh.

75 {
76  return getPrintOption(out) == JLANG::SHORT_PRINT;
77 }
short print
Definition: JManip.hh:37
int getPrintOption(std::ostream &out)
Get print option.
Definition: JManip.hh:50
void setShortprint ( std::ostream &  out)
inline

Set short print option.

Parameters
outoutput stream

Definition at line 85 of file JManip.hh.

86 {
88 }
short print
Definition: JManip.hh:37
void setPrintOption(std::ostream &out, const int option)
Set print option.
Definition: JManip.hh:62
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 97 of file JManip.hh.

98 {
99  return getPrintOption(out) == JLANG::MEDIUM_PRINT;
100 }
medium print
Definition: JManip.hh:38
int getPrintOption(std::ostream &out)
Get print option.
Definition: JManip.hh:50
void setMediumprint ( std::ostream &  out)
inline

Set medium print option.

Parameters
outoutput stream

Definition at line 108 of file JManip.hh.

109 {
110  return setPrintOption(out, JLANG::MEDIUM_PRINT);
111 }
medium print
Definition: JManip.hh:38
void setPrintOption(std::ostream &out, const int option)
Set print option.
Definition: JManip.hh:62
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 120 of file JManip.hh.

121 {
122  return getPrintOption(out) == JLANG::LONG_PRINT;
123 }
long print
Definition: JManip.hh:39
int getPrintOption(std::ostream &out)
Get print option.
Definition: JManip.hh:50
void setLongprint ( std::ostream &  out)
inline

Set long print option.

Parameters
outoutput stream

Definition at line 131 of file JManip.hh.

132 {
133  return setPrintOption(out, JLANG::LONG_PRINT);
134 }
long print
Definition: JManip.hh:39
void setPrintOption(std::ostream &out, const int option)
Set print option.
Definition: JManip.hh:62
std::ostream& shortprint ( std::ostream &  out)
inline

Set short printing.

Parameters
outoutput stream
Returns
output stream

Definition at line 143 of file JManip.hh.

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

Set medium printing.

Parameters
outoutput stream
Returns
output stream

Definition at line 157 of file JManip.hh.

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

Set long printing.

Parameters
outoutput stream
Returns
output stream

Definition at line 171 of file JManip.hh.

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

Print newline character.

Parameters
outoutput stream
Returns
output stream

Definition at line 185 of file JManip.hh.

186 {
187  return out << '\n';
188 }
std::ostream& whitespace ( std::ostream &  out)
inline

Print white space character.

Parameters
outoutput stream
Returns
output stream

Definition at line 197 of file JManip.hh.

198 {
199  return out << ' ';
200 }
std::ostream& tab ( std::ostream &  out)
inline

Print tab character.

Parameters
outoutput stream
Returns
output stream

Definition at line 209 of file JManip.hh.

210 {
211  return out << '\t';
212 }
std::ostream& rewind ( std::ostream &  out)
inline

Rewind character.

Parameters
outoutput stream
Returns
output stream

Definition at line 221 of file JManip.hh.

222 {
223  return (out << '\r').flush();
224 }
template<class T >
JFormat_t& getFormat ( )
inline

Get format for given type.

Returns
format

Definition at line 679 of file JManip.hh.

680 {
681  static JFormat_t manip;
682 
683  return manip;
684 }
Data structure for format specifications.
Definition: JManip.hh:521
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 694 of file JManip.hh.

695 {
696  const JFormat_t& buffer = getFormat<T>();
697 
698  if (buffer.is_valid())
699  return buffer;
700  else
701  return format;
702 }
bool is_valid() const
Check validity of this manipulator.
Definition: JManip.hh:571
Data structure for format specifications.
Definition: JManip.hh:521
template<class T >
void setFormat ( const JFormat_t format)
inline

Set format for given type.

Parameters
formatformat

Definition at line 711 of file JManip.hh.

712 {
713  getFormat<T>() = format;
714 }