OnixS C++ MTS Cash SDP Handler 1.9.4
API documentation
Loading...
Searching...
No Matches
Time.h
Go to the documentation of this file.
1/*
2* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3*
4* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5* and international copyright treaties.
6*
7* Access to and use of the software is governed by the terms of the applicable OnixS Software
8* Services Agreement (the Agreement) and Customer end user license agreements granting
9* a non-assignable, non-transferable and non-exclusive license to use the software
10* for it's own data processing purposes under the terms defined in the Agreement.
11*
12* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13* of this source code or associated reference material to any other location for further reproduction
14* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15*
16* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17* the terms of the Agreement is a violation of copyright law.
18*/
19
20#pragma once
21
22#if defined __linux__
23#include <unistd.h>
24#include <sys/time.h>
25#endif
26
28
29#include <ostream>
30#include <string>
31
32namespace OnixS {
33namespace Mts {
34namespace Cash {
35namespace SDP {
36
37#if defined _WIN32
38
39typedef
40unsigned __int64
41AbsoluteHighResolutionTimeImpl;
42
43typedef
44__int64
45RelativeHighResolutionTimeImpl;
46
47#elif defined __linux__
48
49typedef timeval AbsoluteHighResolutionTimeImpl;
50typedef struct Nothing {} RelativeHighResolutionTimeImpl;
51#else
52
53#error High resolution time services are not defined for a given platform.
54
55#endif
58typedef AbsoluteHighResolutionTimeImpl Timestamp;
59
62struct ONIXS_MTS_CASH_SDP_API HighResolutionTimeFields
63{
64 unsigned short year;
65 unsigned short month;
66 unsigned short day;
67
68 unsigned short hour;
69 unsigned short minute;
70 unsigned short seconds;
71
72 unsigned int microseconds;
73
76 void fromAbsolute (const AbsoluteHighResolutionTimeImpl&);
77
80 void toAbsolute (AbsoluteHighResolutionTimeImpl*) const;
81
84 void fromString (const std::string&);
85
88 std::string toString() const;
89};
90
91typedef long long HighResolutionTimeSpan;
92
95class ONIXS_MTS_CASH_SDP_API HighResolutionTime
96{
97public:
101
105
109
113
116 bool isValid() const;
117
121
124 std::string toString() const;
125
128 void setToNow();
129
132 bool operator == (const HighResolutionTime&) const;
133
136 bool operator != (const HighResolutionTime&) const;
137
141
145
149
152 static HighResolutionTime parse (const std::string& time);
153
154protected:
155 friend struct TimestampHelpers;
156#if defined _WIN32
159 static HighResolutionTime createFromRelative (RelativeHighResolutionTimeImpl value);
160#elif defined __linux__
163 static HighResolutionTime createFromAbsolute (AbsoluteHighResolutionTimeImpl value);
164#endif
165private:
166 enum ValueKind { Invalid, Absolute, Relative };
167
168 union Value
169 {
170 AbsoluteHighResolutionTimeImpl asAbsolute;
171 RelativeHighResolutionTimeImpl asRelative;
172 };
173
174 Value value_;
175 ValueKind kind_;
176
177 HighResolutionTime (ValueKind kind);
178};
179
181{
182 return ! (Invalid == kind_);
183}
184
185ONIXS_MTS_CASH_SDP_API std::ostream& operator << (std::ostream& os, const HighResolutionTime&);
186}
187}
188}
189}
static HighResolutionTime parse(const std::string &time)
HighResolutionTime(const HighResolutionTimeFields &)
HighResolutionTime(const HighResolutionTime &)
static HighResolutionTime now()
void getFields(HighResolutionTimeFields *fields) const
long long HighResolutionTimeSpan
Definition Time.h:91
AbsoluteHighResolutionTimeImpl Timestamp
Definition Time.h:58
unsigned long long UInt64
Definition Defines.h:47
ONIXS_MTS_CASH_SDP_API std::ostream & operator<<(std::ostream &stream, TradeImpactService::Enum value)
void fromAbsolute(const AbsoluteHighResolutionTimeImpl &)
void toAbsolute(AbsoluteHighResolutionTimeImpl *) const