Jpp  debug
the software that should make you happy
Classes | Namespaces | Macros | Functions
JStreamAvailable.cc File Reference

Example program to test JLANG::JStreamAvailable class. More...

#include <iostream>
#include <iomanip>
#include <vector>
#include "JLang/JStreamAvailable.hh"
#include "JLang/JBool.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Classes

struct  __A__
 
struct  __B__< T >
 
struct  __C__
 

Namespaces

 std
 

Macros

#define PRINT(OUT, CLASS)
 Print class parameters. More...
 

Functions

template<class T >
std::ostream & operator<< (std::ostream &out, const __B__< T > &object)
 Write object to output. More...
 
std::istream & std::operator>> (std::istream &in, std::vector< int > &object)
 Read std::vector<int> from input. More...
 
std::ostream & std::operator<< (std::ostream &out, const std::vector< int > &object)
 Write std::vector<int> to output. More...
 
int main (int argc, char **argv)
 

Detailed Description

Example program to test JLANG::JStreamAvailable class.

Author
mdejong

Definition in file JStreamAvailable.cc.

Macro Definition Documentation

◆ PRINT

#define PRINT (   OUT,
  CLASS 
)
Value:
OUT << std::setw(12) << std::left << #CLASS << ' ' ; \
OUT << JStreamAvailable<CLASS>::has_istream << '/'; \
OUT << JStreamAvailable<CLASS>::has_ostream << std::endl;

Print class parameters.

Parameters
OUToutput stream
CLASSclass

Definition at line 132 of file JStreamAvailable.cc.

Function Documentation

◆ operator<<()

template<class T >
std::ostream& operator<< ( std::ostream &  out,
const __B__< T > &  object 
)
inline

Write object to output.

Parameters
outoutput stream
objectobject
Returns
output stream

Definition at line 39 of file JStreamAvailable.cc.

40 {
41  return out << "__B__";
42 }

◆ main()

int main ( int  argc,
char **  argv 
)

Definition at line 145 of file JStreamAvailable.cc.

146 {
147  using namespace std;
148  using namespace JPP;
149 
150  int debug;
151 
152  try {
153 
154  JParser<> zap("Example program to test availability of I/O stream redirection.");
155 
156  zap['d'] = make_field(debug) = 3;
157 
158  zap(argc, argv);
159  }
160  catch(const exception &error) {
161  FATAL(error.what() << endl);
162  }
163 
164 
165  if (debug >= debug_t) {
166 
167  cout << setw(12) << left << "class" << " I/O" << endl;
168  cout << setw(12) << right << setfill('-') << "" << "+---" << setfill(' ') << endl;
169 
170  PRINT(cout, double);
171  PRINT(cout, __A__);
172  PRINT(cout, __B__<int>);
173  PRINT(cout, __C__);
174  PRINT(cout, vector<int>);
175 
176  print(cout, vector<int>(5, 1));
177  print(cout, vector<double>(5, 1.0));
178 
179  __A__ a;
180  __B__<int> b;
181  __C__ c;
182 
183  cout << "STREAM << __A__: " << STREAM("?") << a << endl;
184  cout << "STREAM << __B__: " << STREAM("?") << b << endl;
185  cout << "STREAM << __C__: " << STREAM("?") << c << endl;
186  }
187 
190  ASSERT(!JStreamAvailable< __B__<int> >::has_istream);
191  ASSERT( JStreamAvailable< __B__<int> >::has_ostream);
194  ASSERT( JStreamAvailable< std::vector<int> >::has_istream);
195  ASSERT( JStreamAvailable< vector<int> >::has_ostream);
196  ASSERT(!JStreamAvailable< vector<double> >::has_istream);
197  ASSERT(!JStreamAvailable< vector<double> >::has_ostream);
198 
199  return 0;
200 }
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
#define FATAL(A)
Definition: JMessage.hh:67
int debug
debug level
Definition: JSirene.cc:69
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:2158
#define PRINT(OUT, CLASS)
Print class parameters.
Utility class to parse command line options.
Definition: JParser.hh:1714
Test availability of stream operators.
const double a
Definition: JQuadrature.cc:42
std::ostream & print(std::ostream &out, const JTestSummary &summary, const char delimiter=' ', const bool useColors=true)
Print test summary.
@ debug_t
debug
Definition: JMessage.hh:29
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Definition: JSTDTypes.hh:14
Auxiliary data structure for handling std::ostream.