Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JSTDObjectWriter.cc File Reference

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

#include <string>
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include "JLang/JSTDObjectWriter.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to test JLANG::JSTDObjectWriter class.

Author
mdejong

Definition in file JSTDObjectWriter.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 61 of file JSTDObjectWriter.cc.

62{
63 using namespace std;
64
65 int debug;
66
67 try {
68
69 JParser<> zap("Example program to test object output using STD containers.");
70
71 zap['d'] = make_field(debug) = 3;
72
73 zap(argc, argv);
74 }
75 catch(const exception &error) {
76 FATAL(error.what() << endl);
77 }
78
79
80 using namespace JPP;
81
83
84 data.push_back(3.0);
85 data.push_back(2.0);
86 data.push_back(1.0);
87
88 print(cout, debug, "data", data.begin(), data.end());
89
90 {
92
93 buffer_type buffer;
94
95 JSTDObjectWriter<double> out(buffer);
96
97 for (vector<double>::const_iterator i = data.begin(); i != data.end(); ++i) {
98 out.put(*i);
99 }
100
101 print(cout, debug, "JSTDObjectWriter<double>(vector<double>&);", buffer.begin(), buffer.end());
102
103 ASSERT(equals(data.begin(), data.end(),
104 buffer.begin(), buffer.end()));
105 }
106 {
107 typedef set<double> buffer_type;
108
109 buffer_type buffer;
110
111 JSTDObjectWriter<double> out(buffer);
112
113 for (vector<double>::const_iterator i = data.begin(); i != data.end(); ++i) {
114 out.put(*i);
115 }
116
117 print(cout, debug, "JSTDObjectWriter<double>(set<double>&);", buffer.begin(), buffer.end());
118
119 ASSERT(equals(data.rbegin(), data.rend(),
120 buffer.begin(), buffer.end()));
121 }
122
123 return 0;
124}
#define ASSERT(A,...)
Assert macro.
Definition JMessage.hh:90
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
void print(const TH1 &h1, std::ostream &out)
Print histogram parameters.
Implementation of object output from STD container.
Utility class to parse command line options.
Definition JParser.hh:1698
bool equals(const JFirst_t &first, const JSecond_t &second, const double precision=std::numeric_limits< double >::min())
Check equality.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).