Jpp
15.0.5
the software that should make you happy
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
examples
JLang
JEquals.cc
Go to the documentation of this file.
1
2
#include <iostream>
3
#include <iomanip>
4
5
#include "
JLang/JEquals.hh
"
6
7
#include "
Jeep/JParser.hh
"
8
#include "
Jeep/JMessage.hh
"
9
10
11
namespace
{
12
13
using namespace
JPP;
14
15
16
struct
__A__ :
17
public
JEquals
<__A__>
18
{
19
__A__(
int
__value) :
20
value(__value)
21
{}
22
23
bool
equals
(
const
__A__&
object
)
const
24
{
25
return
this->value ==
object
.value;
26
}
27
28
friend
std::ostream&
operator<<
(std::ostream& out,
const
__A__&
object
)
29
{
30
return
out <<
object
.value;
31
}
32
33
int
value;
34
};
35
36
37
struct
__B__ :
38
public
JEquals
<__B__, int>
39
{
40
__B__(
int
__value) :
41
value(__value)
42
{}
43
44
bool
equals
(
const
__B__&
object
)
const
45
{
46
return
this->value ==
object
.value;
47
}
48
49
bool
equals
(
const
int
value)
const
50
{
51
return
this->value == value;
52
}
53
54
friend
std::ostream&
operator<<
(std::ostream& out,
const
__B__&
object
)
55
{
56
return
out <<
object
.value;
57
}
58
59
int
value;
60
};
61
62
/**
63
* Print.
64
*
65
* \param OUT output stream
66
* \param OP operator
67
* \param A first object
68
* \param B second object
69
*/
70
#define PRINT(OUT,OP,A,B) \
71
OUT << "(" << A << ") " << #OP " (" << B << ") => " << (A OP B) << std::endl;
72
}
73
74
/**
75
* \file
76
*
77
* Example program to test JLANG::JComparible class.
78
* \author mdejong
79
*/
80
int
main
(
int
argc,
char
**argv)
81
{
82
using namespace
std;
83
using namespace
JPP;
84
85
int
debug
;
86
87
try
{
88
89
JParser<>
zap(
"Example program to test object comparisons."
);
90
91
zap[
'd'
] =
make_field
(
debug
) = 3;
92
93
zap(argc, argv);
94
}
95
catch
(
const
exception &error) {
96
FATAL
(error.what() << endl);
97
}
98
99
__A__ a1(0);
100
__A__ a2(1);
101
102
PRINT
(cout, ==, a1, a2);
103
PRINT
(cout, !=, a1, a2);
104
105
__B__ b1(0);
106
__B__ b2(1);
107
108
PRINT
(cout, ==, b1, b1);
109
PRINT
(cout, !=, b1, b2);
110
PRINT
(cout, ==, b1, 1);
111
PRINT
(cout, !=, b1, 1);
112
113
ASSERT
(a1 == a1);
114
ASSERT
(a1 != a2);
115
116
ASSERT
(b1 == b1);
117
ASSERT
(b1 != b2);
118
ASSERT
(b1 == 0);
119
ASSERT
(b1 != 1);
120
121
return
0;
122
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1500
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
ASSERT
#define ASSERT(A,...)
Assert macro.
Definition:
JMessage.hh:90
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1961
JLANG::JEquals
Template definition of auxiliary base class for comparison of data structures.
Definition:
JEquals.hh:24
debug
int debug
debug level
Definition:
JSirene.cc:63
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JParser.hh
Utility class to parse command line options.
PRINT
#define PRINT(OUT, OP, A, B)
Print.
Definition:
JEquals.cc:70
operator<<
std::ostream & operator<<(std::ostream &stream, const CLBCommonHeader &header)
Definition:
clb_common_header.hh:72
JMATH::equals
bool equals(const JFirst_t &first, const JSecond_t &second, const double precision=std::numeric_limits< double >::min())
Check equality.
Definition:
JMathToolkit.hh:86
JEquals.hh
Generated by
1.8.5