summaryrefslogtreecommitdiffstats
path: root/debian/uncrustify-trinity/uncrustify-trinity-0.73.0/tests/expected/cpp/30030-Timestamp.h
blob: 998b7d6fb4741637dcc869d51d56c82622bf6309 (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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
/**
 * @file Timestamp.h
 * Definition of class example::Timestamp.
 */

#ifndef __Timestamp_h_
#define __Timestamp_h_

#include <string>

namespace example {
class IStreamable;
class InStream;
class OutStream;

/**
 * Timestamp is a timestamp with nanosecond resolution.
 */
class Timestamp
  : public IStreamable
{
public:

/**
 * Default constructor.
 */
Timestamp();

/**
 * Constructor.
 *
 * @param sec   The seconds
 * @param nsec  The nanoseconds
 */
Timestamp(long sec, unsigned long nsec);

/**
 * Destructor.
 */
virtual ~Timestamp();

/**
 * Adds two timestamps.
 *
 * @param rhs The other timestamp
 * @return The resulting timestamp
 */
Timestamp operator+(const Timestamp& rhs) const;

/**
 * Substracts two timestamps.
 *
 * @param rhs The other timestamp
 * @return The resulting timestamp
 */
Timestamp operator-(const Timestamp& rhs) const;

/**
 * Compares two timestamps.
 *
 * @param rhs The other timestamp
 * @return true if timestamp is smaller than the given timestamp
 */
bool operator<(const Timestamp& rhs) const;

/**
 * Compares two timestamps.
 *
 * @param rhs The other timestamp
 * @return true if timestamp is greater than the given timestamp
 */
bool operator>(const Timestamp& rhs) const;

/**
 * Compares two timestamps.
 *
 * @param rhs The other timestamp
 * @return true if timestamp is equal to the given timestamp
 */
bool operator==(const Timestamp& rhs) const;

/**
 * Compares two timestamps.
 *
 * @param rhs The other timestamp
 * @return true if timestamp is not equal to the given timestamp
 */
bool operator!=(const Timestamp& rhs) const;

/**
 * Adds an other timestamp.
 *
 * @param rhs The other timestamp
 */
void operator+=(const Timestamp& rhs);

/**
 * Adds milliseconds.
 *
 * @param ms The milliseconds
 * @return The resulting timestamp
 */
Timestamp addMilliseconds(unsigned long ms) const;

/**
 * Adds nanoseconds.
 *
 * @param ns The nanoseconds
 * @return The resulting timestamp
 */
Timestamp addNanoseconds(unsigned long ns) const;

/**
 * Checks if this timestamp is zero.
 *
 * @return true if timestamp is zero
 */
bool isZero() const;

/**
 * Gets the milliseconds.
 * @attention Negativ timestamp return zero
 *
 * @return The milliseconds
 */
unsigned long getMilliseconds() const;

/**
 * Divide timestamps by two.
 *
 * @return The resulting timestamp
 */
Timestamp divideByTwo();

/**
 * Gets the string-representation.
 *
 * @return The string representation
 */
std::string getString() const;

/**
 * Gets the string-representation in milliseconds.
 *
 * @return The string representation
 */
std::string getStringMilliseconds() const;

/**
 * Resets the timestamp.
 */
void reset();

/** The seconds */
long sec;

/** The nanoseconds */
unsigned long nsec;

InStream& operator <<(InStream& in);

OutStream& operator >>(OutStream& out) const;
};
} // namespace

#endif // __Timestamp_h_