OnixS C++ Eurex T7 Market and Reference Data (EMDI, MDI, RDI, EOBI) Handlers 18.2.0
API documentation
Loading...
Searching...
No Matches
TimeSpan.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#pragma once
20
22#include <string>
23
24namespace OnixS
25{
26 namespace Eurex
27 {
28 namespace MarketData
29 {
31 struct ONIXS_EUREX_EMDI_API TimeSpanFormats
32 {
44 };
45
48
52 class ONIXS_EUREX_EMDI_API TimeSpan
53 {
54 public:
57
64 TimeSpan (int hours, int minutes, int seconds, int nanoseconds = 0);
65
72 TimeSpan (int days, int hours, int minutes, int seconds, int nanoseconds);
73
77
79 TimeSpan (const TimeSpan& other);
80
82 long long totalSeconds() const;
83
86 int days() const;
87
90 int hours() const;
91
94 int minutes() const;
95
98 int seconds() const;
99
102 int milliseconds() const;
103
106 int microseconds() const;
107
110 int nanoseconds() const;
111
113 bool operator == (const TimeSpan& other) const;
114
116 bool operator != (const TimeSpan& other) const;
117
119 bool operator < (const TimeSpan& other) const;
120
122 bool operator >(const TimeSpan& other) const;
123
125 TimeSpan& operator += (const TimeSpan& other);
126
128 TimeSpan& operator -= (const TimeSpan& other);
129
131 TimeSpan& operator = (const TimeSpan& other);
132
135 void toString (std::string& str, TimeSpanFormat format = TimeSpanFormats::SDHHMMSSnsec) const;
136
139 std::string toString (TimeSpanFormat format = TimeSpanFormats::SDHHMMSSnsec) const;
140
142 static TimeSpan deserialize (const std::string& str);
143
145 static const TimeSpan Zero;
146
147 private:
148 long long seconds_;
149 int nanoseconds_;
150 };
151
152 inline long long TimeSpan::totalSeconds() const
153 {
154 return seconds_;
155 }
156
157 inline int TimeSpan::nanoseconds() const
158 {
159 return nanoseconds_;
160 }
161
162 inline std::string TimeSpan::toString (TimeSpanFormat format) const
163 {
164 std::string str;
165
166 toString (str, format);
167
168 return str;
169 }
170 }
171 }
172}
TimeSpan(int days, int hours, int minutes, int seconds, int nanoseconds)
TimeSpan()
Initializes zero span.
static TimeSpan deserialize(const std::string &str)
De-serializes time interval from its text presentation.
TimeSpan(const TimeSpan &other)
Initializes as clone of other instance.
long long totalSeconds() const
Whole number of seconds in time interval.
Definition TimeSpan.h:152
TimeSpan(long long totalSeconds, int nanoseconds)
static const TimeSpan Zero
Time interval of zero length.
Definition TimeSpan.h:145
void toString(std::string &str, TimeSpanFormat format=TimeSpanFormats::SDHHMMSSnsec) const
TimeSpan(int hours, int minutes, int seconds, int nanoseconds=0)
TimeSpanFormats::Enum TimeSpanFormat
Time span format.
Definition TimeSpan.h:47
Time span formats supported.
Definition TimeSpan.h:32