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

Example program to test assignment of comma separated values (see JCSV.hh). More...

#include <iostream>
#include <iomanip>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <iterator>
#include <algorithm>
#include "JLang/JCSV.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 assignment of comma separated values (see JCSV.hh).

Author
mdejong

Definition in file JCSV.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 42 of file JCSV.cc.

43{
44 using namespace std;
45 using namespace JPP;
46
47 int debug;
48
49 try {
50
51 JParser<> zap("Example program to test assignment of comma separated values.");
52
53 zap['d'] = make_field(debug) = 0;
54
55 zap(argc, argv);
56 }
57 catch(const exception &error) {
58 FATAL(error.what() << endl);
59 }
60
61 const int a = 7;
62 const int b = 8;
63 const int c = 9;
64 const int d = 10;
65
66 {
67 vector<int> buffer;
68
69 assign(buffer) = a, b, c, d;
70
71 ASSERT(get(buffer,0) == a);
72 ASSERT(get(buffer,1) == b);
73 ASSERT(get(buffer,2) == c);
74 ASSERT(get(buffer,3) == d);
75 }
76
77 {
78 set<int> buffer;
79
80 assign(buffer) = d, c, b, a;
81
82 ASSERT(get(buffer,0) == a);
83 ASSERT(get(buffer,1) == b);
84 ASSERT(get(buffer,2) == c);
85 ASSERT(get(buffer,3) == d);
86 }
87
88 {
89 map<int, int> buffer;
90
91 assign(buffer) = make_pair(1,-1), make_pair(2,-2), make_pair(3,-3), make_pair(4,-4);
92
93 ASSERT(buffer[1] == -1);
94 ASSERT(buffer[2] == -2);
95 ASSERT(buffer[3] == -3);
96 ASSERT(buffer[4] == -4);
97 }
98
99 {
100 deque<int> buffer;
101
102 assign(front_inserter(buffer)) = b, a;
103 assign(back_inserter (buffer)) = c, d;
104
105 ASSERT(get(buffer,0) == a);
106 ASSERT(get(buffer,1) == b);
107 ASSERT(get(buffer,2) == c);
108 ASSERT(get(buffer,3) == d);
109 }
110
111 return 0;
112}
#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
Utility class to parse command line options.
Definition JParser.hh:1698
const double a
JAssignSequence< typename JContainer_t::value_type > assign(JContainer_t &out)
Helper method to assign sequence of Comma Separated Values to output container.
Definition JCSV.hh:129
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).