OnixS C++ eSpeed ITCH Market Data Handler 1.7.3
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
20#pragma once
21
22#include <string>
23
26
27
29
31struct ONIXS_ESPEED_ITCH_API TimeSpanFormats
32{
44};
45
48
52class ONIXS_ESPEED_ITCH_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
152inline long long TimeSpan::totalSeconds() const
153{
154 return seconds_;
155}
156
157inline int TimeSpan::nanoseconds() const
158{
159 return nanoseconds_;
160}
161
162inline std::string TimeSpan::toString (TimeSpanFormat format) const
163{
164 std::string str;
165
166 toString (str, format);
167
168 return str;
169}
170
#define ONIXS_ESPEED_ITCH_NAMESPACE_BEGIN
Definition Bootstrap.h:27
#define ONIXS_ESPEED_ITCH_NAMESPACE_END
Definition Bootstrap.h:31
bool operator>(const StrRef &left, const StrRef &right)
Establishes order over string refs.
Definition String.h:440
bool operator<(const StrRef &left, const StrRef &right)
Establishes order over string refs.
Definition String.h:414
bool operator==(const StrRef &left, const StrRef &right)
Compares StrRef instance with another one.
Definition String.h:310
bool operator!=(const StrRef &left, const StrRef &right)
Compares with another instance.
Definition String.h:324
TimeSpanFormats::Enum TimeSpanFormat
Time span format.
Definition TimeSpan.h:47
int microseconds() const
TimeSpan(int days, int hours, int minutes, int seconds, int nanoseconds)
TimeSpan()
Initializes zero span.
int milliseconds() const
int days() const
int nanoseconds() const
Definition TimeSpan.h:157
int minutes() const
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.
int hours() const
long long totalSeconds() const
Whole number of seconds in time interval.
Definition TimeSpan.h:152
TimeSpan(long long totalSeconds, int nanoseconds)
int seconds() const
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)
Time span formats supported.
Definition TimeSpan.h:32
@ HHMMSSmsec
HH:MM:SS.sss.
Definition TimeSpan.h:39
@ SDHHMMSSnsec
HH:MM:SS.sssssssss.
Definition TimeSpan.h:42
@ HHMMSS
HH:MM:SS.
Definition TimeSpan.h:36