blob: 4e7d7856f09651ad7029f20fbe3664980dc2cf74 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
/*
Copyright (C) 2013-2020, Dirk Krause
SPDX-License-Identifier: BSD-3-Clause
*/
/*
WARNING: This file was generated by the dkct program (see
http://dktools.sourceforge.net/ for details).
Changes you make here will be lost if dkct is run again!
You should modify the original source and run dkct on it.
Original source: Dk4Comparable.cpt
*/
/** @file Dk4Comparable.h Header file for the Dk4Comparable module.
*/
#ifndef DK4COMPARABLE_H_INCLUDED
/** Avoid multiple inclusions. */
#define DK4COMPARABLE_H_INCLUDED 1
#line 8 "Dk4Comparable.cpt"
#ifndef DK4CONF_H_INCLUDED
#if DK4_BUILDING_DKTOOLS4
#include "dk4conf.h"
#else
#include <dktools-4/dk4conf.h>
#endif
#endif
#if DK4_HAVE_STDLIB_H
#include <stdlib.h>
#endif
#if DK4_HAVE_UNISTD_H
#include <unistd.h>
#endif
/** Namespace to protect Container and Iterator from name collisions.
*/
namespace DkTools4 {
/** Comparable is a general base class for objects we want to compare,
for example for sorted storage.
Derived classes must implement the compareAgainst() method.
*/
class Comparable
{
public:
/** Compare object against another object or some data.
Derived classes must implement this method.
The comparison is used by sorted containers.
Example: When storing persons (name and age) we can use
crit=0 as comparison criteria in the container to compare
person object against person object.
When searching the container for an object with a specific name
we can use crit=1 for comparisons of the object against a
string.
@param pt Address of other object or data.
@param crit Comparison criteria, see documentation of
derived classes for class-specific numbers.
@return Positive number if larger than ptr, 0 if
evaluates equal to ptr, negative number if
smaller than ptr.
*/
virtual
int
compareAgainst(void const *ptr, int crit) const = 0;
/** Compare two pointers
@param l Left pointer.
@param r Right pointer.
@param cr Comparison criteria.
@return 1 for left object is large, 0 for right object
is large, 0 for objects evaluating equally.
*/
static
int
compareTwoPointers(void const *l, void const *r, int cr);
/** Virtual destructor required by compiler.
*/
virtual
~Comparable();
}; /* End of class Comparable. */
} /* End of namespace DkTools4 */
#endif
|