Jpp  16.0.2
the software that should make you happy
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | 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__
 

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 & operator>> (std::istream &in, std::vector< int > &object)
 Read std::vector<int> from input. More...
 
std::ostream & 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

#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 131 of file JStreamAvailable.cc.

Function Documentation

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 }
std::istream& operator>> ( std::istream &  in,
std::vector< int > &  object 
)
inline

Read std::vector<int> from input.

Parameters
ininput stream
objectobject
Returns
input stream

Definition at line 55 of file JStreamAvailable.cc.

56 {
57  for (int value; in >> value; ) {
58  object.push_back(value);
59  }
60 
61  return in;
62 }
then fatal Wrong number of arguments fi set_variable DETECTOR $argv[1] set_variable INPUT_FILE $argv[2] eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY source JAcoustics sh $DETECTOR_ID CHECK_EXIT_CODE typeset A TRIPODS get_tripods $WORKDIR tripod txt TRIPODS for EMITTER in
Definition: JCanberra.sh:42
std::ostream& operator<< ( std::ostream &  out,
const std::vector< int > &  object 
)
inline

Write std::vector<int> to output.

Parameters
outoutput stream
objectobject
Returns
output stream

Definition at line 72 of file JStreamAvailable.cc.

73 {
74  for (std::vector<int>::const_iterator i = object.begin(); i != object.end(); ++i) {
75  out << ' ' << *i;
76  }
77 
78  return out;
79 }
int main ( int  argc,
char **  argv 
)

Definition at line 144 of file JStreamAvailable.cc.

145 {
146  using namespace std;
147  using namespace JPP;
148 
149  int debug;
150 
151  try {
152 
153  JParser<> zap("Example program to test availability of I/O stream redirection.");
154 
155  zap['d'] = make_field(debug) = 3;
156 
157  zap(argc, argv);
158  }
159  catch(const exception &error) {
160  FATAL(error.what() << endl);
161  }
162 
163 
164  cout.tie(&cerr);
165 
166  if (debug >= debug_t) {
167 
168  cout << setw(12) << left << "class" << " I/O" << endl;
169  cout << setw(12) << right << setfill('-') << "" << "+---" << setfill(' ') << endl;
170 
171  PRINT(cout, double);
172  PRINT(cout, __A__);
173  PRINT(cout, __B__<int>);
174  PRINT(cout, __C__);
175  PRINT(cout, vector<int>);
176 
177  print(cout, vector<int>(5, 1));
178  print(cout, vector<double>(5, 1.0));
179 
180  __A__ a;
181  __B__<int> b;
182  __C__ c;
183 
184  cout << "STREAM << __A__: " << STREAM("?") << a << endl;
185  cout << "STREAM << __B__: " << STREAM("?") << b << endl;
186  cout << "STREAM << __C__: " << STREAM("?") << c << endl;
187  }
188 
191  ASSERT(!JStreamAvailable< __B__<int> >::has_istream);
192  ASSERT( JStreamAvailable< __B__<int> >::has_ostream);
195  ASSERT( JStreamAvailable< vector<int> >::has_istream);
196  ASSERT( JStreamAvailable< vector<int> >::has_ostream);
197  ASSERT(!JStreamAvailable< vector<double> >::has_istream);
198  ASSERT(!JStreamAvailable< vector<double> >::has_ostream);
199 
200  return 0;
201 }
Utility class to parse command line options.
Definition: JParser.hh:1500
debug
Definition: JMessage.hh:29
Test availability of stream operators.
#define ASSERT(A,...)
Assert macro.
Definition: JMessage.hh:90
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition: JParser.hh:1961
Auxiliary data structure for handling std::ostream.
int debug
debug level
Definition: JSirene.cc:63
print
Definition: JConvertDusj.sh:44
#define FATAL(A)
Definition: JMessage.hh:67
#define PRINT(OUT, CLASS)
Print class parameters.
then JCalibrateToT a
Definition: JTuneHV.sh:116
$WORKDIR ev_configure_domsimulator txt echo process $DOM_SIMULATOR $i $SOURCE_HOST[$index] csh c(setenv ROOTSYS $ROOTSYS &&source $JPP_DIR/setenv.csh $JPP_DIR &&($DOM_SIMULATOR\-u\$NAME\$\-H\$SERVER\$\-M\$LOGGER\$\-d $DEBUG</dev/null > &/dev/null &))'