dxFeed Graal CXX API v8.1.0
Loading...
Searching...
No Matches
Common.hpp
1// Copyright (c) 2025 Devexperts LLC.
2// SPDX-License-Identifier: MPL-2.0
3
4#pragma once
5
6#include "./Conf.hpp"
7
8#include "../exceptions/InvalidArgumentException.hpp"
9#include "./utils/StringUtils.hpp"
10
12
13#ifdef __cpp_lib_bit_cast
14# include <bit>
15#endif
16#include <algorithm>
17#include <climits>
18#include <concepts>
19#include <cstring>
20
21#include <charconv>
22#include <chrono>
23#include <cmath>
24#include <limits>
25#include <string>
26#include <type_traits>
27#include <utility>
28#include <variant>
29
30#include "utils/debug/Debug.hpp"
31
32#include <bits/bits.hpp>
33
35
36namespace detail {
37template <typename, template <class...> class> struct IsInstanceImpl : std::false_type {};
38
39template <template <class...> class C, typename... Ts> struct IsInstanceImpl<C<Ts...>, C> : std::true_type {};
40} // namespace detail
41
42template <typename T, template <class...> class C> constexpr bool isInstanceOf = detail::IsInstanceImpl<T, C>::value;
43template <typename T, template <class...> class C>
44concept InstanceOf = isInstanceOf<T, C>;
45
46template <typename T>
47concept Integral = std::is_integral_v<T>;
48
49template <typename T>
50concept EnumConcept = std::is_enum_v<T>;
51
52template <class From, class To>
53concept ConvertibleTo = std::is_convertible_v<From, To> && requires { static_cast<To>(std::declval<From>()); };
54
55template <class T, class U>
56concept Derived = std::is_base_of_v<U, T>;
57
58template <class T, class U>
59concept Extends = Derived<T, U>;
60
61template <class T, class U>
62concept BaseOf = Derived<U, T>;
63
64template <typename T>
65concept PairLike = requires(T t) {
66 t.first;
67 t.second;
68};
69
70template <typename T>
71concept MapLike = requires(T t) {
72 { std::begin(t) } -> std::input_iterator;
73 { std::end(t) } -> std::sentinel_for<decltype(std::begin(t))>;
74} && PairLike<std::remove_cvref_t<decltype(*std::begin(std::declval<T &>()))>>;
75
76namespace detail {
77template <typename T>
78struct RemoveAllPointers
79 : std::conditional_t<std::is_pointer_v<T>, RemoveAllPointers<std::remove_pointer_t<T>>, std::type_identity<T>> {};
80} // namespace detail
81
82template <typename T> using RemoveAllPointers = typename detail::RemoveAllPointers<T>::type;
83
84template <class... Ts> struct Overloads : Ts... {
85 using Ts::operator()...;
86};
87
88template <class... Ts> Overloads(Ts...) -> Overloads<Ts...>;
89
90struct DXFeedEventListener {};
91
92struct DXEndpointStateChangeListener {};
93
94struct IpfPropertyChangeListener {};
95
96struct InstrumentProfileUpdateListener {};
97
98template <typename... T> constexpr void ignoreUnused(const T &...) {
99}
100
101constexpr inline auto is_constant_evaluated(bool default_value = false) noexcept -> bool {
102#ifdef __cpp_lib_is_constant_evaluated
103 ignoreUnused(default_value);
104 return std::is_constant_evaluated();
105#else
106 return default_value;
107#endif
108}
109
110// Implementation of std::bit_cast for pre-C++20.
111template <typename To, typename From>
112constexpr To bit_cast(const From &from)
113#if __cpp_concepts
114 requires(sizeof(To) == sizeof(From))
115#endif
116{
117#ifdef __cpp_lib_bit_cast
118 if (is_constant_evaluated())
119 return std::bit_cast<To>(from);
120#endif
121 auto to = To();
122 // The cast suppresses a bogus -Wclass-memaccess on GCC.
123 std::memcpy(static_cast<void *>(&to), &from, sizeof(to));
124 return to;
125}
126
127/// Lightweight implementation of "nullable bool"
128enum class Tristate : std::uint8_t {
129 FALSE = 0,
130 TRUE = 1,
131 NONE = 2,
132};
133
134#define DXFCPP_MACRO_CONCAT(a, b) DXFCPP_MACRO_CONCAT_INNER(a, b)
135#define DXFCPP_MACRO_CONCAT_INNER(a, b) a##b
136#define DXFCPP_MACRO_UNIQUE_NAME(base) DXFCPP_MACRO_CONCAT(base, __LINE__)
137
138namespace detail {
139template <typename Func> struct OnScopeExit {
140 Func func;
141
142 // ReSharper disable once CppNonExplicitConvertingConstructor
143 OnScopeExit(const Func &f) : func(static_cast<Func &&>(f)) { // NOLINT(*-explicit-constructor)
144 }
145
146 // ReSharper disable once CppNonExplicitConvertingConstructor
147 OnScopeExit(Func &&f) : func(f) { // NOLINT(*-explicit-constructor)
148 }
149
150 OnScopeExit(const OnScopeExit &) = delete;
151
152 ~OnScopeExit() {
153 func();
154 }
155};
156} // namespace detail
157
158#define DXFCPP_FINALLY(...) detail::OnScopeExit DXFCPP_MACRO_UNIQUE_NAME(ose__) = __VA_ARGS__
159
160template <typename GraalList, typename ElementWrapper> struct GraalListUtils {
161 static std::ptrdiff_t calculateSize(std::ptrdiff_t initSize) noexcept {
162 using ListType = GraalList;
163 using SizeType = decltype(ListType::size);
164
165 if (initSize < 0) {
166 return 0;
167 }
168
169 if (initSize > std::numeric_limits<SizeType>::max()) {
170 return std::numeric_limits<SizeType>::max();
171 }
172
173 return initSize;
174 }
175
176 static void *newList(std::ptrdiff_t size) {
177 using ListType = GraalList;
178 using SizeType = decltype(ListType::size);
179 using ElementType = std::remove_pointer_t<decltype(ListType::elements)>;
180
181 auto *list = new ListType{static_cast<SizeType>(size), nullptr};
182
183 if (size == 0) {
184 return static_cast<void *>(list);
185 }
186
187 list->elements = new ElementType[static_cast<std::size_t>(size)]{nullptr};
188
189 return list;
190 }
191
192 static bool setElement(void *graalList, std::ptrdiff_t elementIdx, void *element) noexcept {
193 using ListType = GraalList;
194 using SizeType = decltype(ListType::size);
195 using ElementType = std::remove_pointer_t<decltype(ListType::elements)>;
196
197 if (graalList == nullptr || elementIdx < 0 || elementIdx >= std::numeric_limits<SizeType>::max() ||
198 element == nullptr) {
199 return false;
200 }
201
202 static_cast<ListType *>(graalList)->elements[elementIdx] = static_cast<ElementType>(element);
203
204 return true;
205 }
206
207 static bool freeElements(void *graalList, std::ptrdiff_t count) {
208 using ListType = GraalList;
209 using SizeType = decltype(ListType::size);
210
211 if (graalList == nullptr || count < 0 || count >= std::numeric_limits<SizeType>::max()) {
212 return false;
213 }
214
215 auto *list = static_cast<ListType *>(graalList);
216
217 for (SizeType i = 0; i < count; i++) {
218 if (list->elements[i]) {
219 ElementWrapper::freeGraal(static_cast<void *>(list->elements[i]));
220 }
221 }
222
223 delete[] list->elements;
224 delete list;
225
226 return true;
227 }
228
229 static void freeList(void *graalList) {
230 using ListType = GraalList;
231 using SizeType = decltype(ListType::size);
232
233 if (graalList == nullptr) {
234 return;
235 }
236
237 auto list = static_cast<ListType *>(graalList);
238
239 if (list->size > 0 && list->elements != nullptr) {
240 for (SizeType elementIndex = 0; elementIndex < list->size; elementIndex++) {
241 if (list->elements[elementIndex]) {
242 ElementWrapper::freeGraal(static_cast<void *>(list->elements[elementIndex]));
243 }
244 }
245
246 delete[] list->elements;
247 }
248
249 delete list;
250 }
251
252 static std::vector<ElementWrapper> fromList(void *graalList) {
253 using ListType = GraalList;
254 using SizeType = decltype(ListType::size);
255
256 if (!graalList) {
257 return {};
258 }
259
260 std::vector<ElementWrapper> result{};
261
262 auto list = static_cast<ListType *>(graalList);
263
264 if (list->size > 0 && list->elements != nullptr) {
265 for (SizeType elementIndex = 0; elementIndex < list->size; elementIndex++) {
266 if (list->elements[elementIndex]) {
267 result.emplace_back(ElementWrapper::fromGraal(static_cast<void *>(list->elements[elementIndex])));
268 }
269 }
270 }
271
272 return result;
273 }
274};
275
276/**
277 * @return The number of milliseconds that have passed since the start of the Unix epoch (1970-01-01).
278 */
279inline auto now() {
280 return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch())
281 .count();
282}
283
284namespace math {
285/**
286 * Returns the largest value that is less than or equal to the algebraic quotient, as Java Math.floorDiv(long, long).
287 * floorDiv(INT64_MIN, -1) is INT64_MIN, as in Java.
288 *
289 * @throws InvalidArgumentException if `y` is 0 (Java throws ArithmeticException).
290 */
291static constexpr std::int64_t floorDiv(std::int64_t x, std::int64_t y) {
292 if (y == 0) {
293 throw InvalidArgumentException("/ by zero");
294 }
295
296 // INT64_MIN / -1 overflows (undefined behavior in C++); Java wraps the result to INT64_MIN.
297 if (x == std::numeric_limits<std::int64_t>::min() && y == -1) {
298 return x;
299 }
300
301 std::int64_t quotient = x / y;
302
303 // The division truncates towards zero: when the signs differ and there is a remainder, round down.
304 if (x % y != 0 && (x < 0) != (y < 0)) {
305 quotient--;
306 }
307
308 return quotient;
309}
310
311/**
312 * Returns the floor modulus `x - floorDiv(x, y) * y` (the sign of the result is the sign of `y`), as Java
313 * Math.floorMod(long, long), without the overflow of that expression.
314 *
315 * @throws InvalidArgumentException if `y` is 0 (Java throws ArithmeticException).
316 */
317static constexpr std::int64_t floorMod(std::int64_t x, std::int64_t y) {
318 if (y == 0) {
319 throw InvalidArgumentException("/ by zero");
320 }
321
322 // x % -1 is 0, but INT64_MIN % -1 overflows (undefined behavior in C++).
323 if (y == -1) {
324 return 0;
325 }
326
327 std::int64_t remainder = x % y;
328
329 // The remainder has the sign of x: when the signs differ, move it to the sign of y. |remainder| < |y| and the signs
330 // are opposite, so the sum does not overflow.
331 if (remainder != 0 && (remainder < 0) != (y < 0)) {
332 remainder += y;
333 }
334
335 return remainder;
336}
337
338static const double NaN = std::numeric_limits<double>::quiet_NaN();
339
340// The functions below compare floating-point numbers exactly on purpose.
343
344/**
345 * Exact IEEE 754 equality of floating-point numbers, as @c == in Java: NaN is not equal to anything, and positive and
346 * negative zero are equal. Use it where an exact comparison is intended (-Wfloat-equal reports the others).
347 *
348 * @param a The first value.
349 * @param b The second value.
350 * @return @c true if the values are equal; @c false otherwise.
351 */
352template <std::floating_point T, std::floating_point U> constexpr bool exactlyEquals(T a, U b) noexcept {
353 return a == b;
354}
355
356/**
357 * Compares two double values using Java @c Double.equals semantics.
358 * All NaN values are considered equal, while positive and negative zero are considered different.
359 *
360 * @param a The first value.
361 * @param b The second value.
362 * @return @c true if the values are equal; @c false otherwise.
363 */
364inline bool doubleEquals(double a, double b) noexcept {
365 if (std::isnan(a) || std::isnan(b)) {
366 return std::isnan(a) && std::isnan(b);
367 }
368
369 if (a != b) {
370 return false;
371 }
372
373 return a != 0.0 || std::signbit(a) == std::signbit(b);
374}
375
376/**
377 * Compares two double values using Java @c Double.compare semantics.
378 * NaN is greater than every other value and all NaN values compare as equal. Positive zero is greater than negative
379 * zero.
380 *
381 * @param a The first value.
382 * @param b The second value.
383 * @return A negative value if @p a is less than @p b, zero if they are equal, or a positive value otherwise.
384 */
385inline std::int32_t doubleCompare(double a, double b) noexcept {
386 if (a < b) {
387 return -1;
388 }
389
390 if (a > b) {
391 return 1;
392 }
393
394 if (doubleEquals(a, b)) {
395 return 0;
396 }
397
398 if (std::isnan(a)) {
399 return 1;
400 }
401
402 if (std::isnan(b)) {
403 return -1;
404 }
405
406 return std::signbit(a) ? -1 : 1;
407}
408
409/**
410 * Checks whether a double value can be safely converted to @c std::int64_t without losing its fractional part.
411 *
412 * @param value The value to check.
413 * @return @c true if the value is finite, integral, and within the range of @c std::int64_t;
414 * @c false otherwise.
415 */
416inline bool isInt64(double value) noexcept {
417 return std::isfinite(value) && value >= static_cast<double>(std::numeric_limits<std::int64_t>::min()) &&
418 value < -static_cast<double>(std::numeric_limits<std::int64_t>::min()) && value == std::trunc(value);
419}
420
421/**
422 * Checks whether two floating-point values are approximately equal using explicit relative and absolute tolerances.
423 * Equal infinities compare as equal, while NaN values never compare as approximately equal.
424 *
425 * @tparam T The type of the first floating-point value.
426 * @tparam U The type of the second floating-point value.
427 * @param a The first value.
428 * @param b The second value.
429 * @param relativeTolerance The non-negative relative tolerance.
430 * @param absoluteTolerance The non-negative absolute tolerance used for values close to zero.
431 * @return @c true if the values are equal within either tolerance; @c false otherwise or if a tolerance is invalid.
432 */
433template <std::floating_point T, std::floating_point U>
434inline bool approximatelyEquals(T a, U b, double relativeTolerance, double absoluteTolerance) noexcept {
435 if (!std::isfinite(relativeTolerance) || !std::isfinite(absoluteTolerance) || relativeTolerance < 0.0 ||
436 absoluteTolerance < 0.0) {
437 return false;
438 }
439
440 using CommonType = std::common_type_t<T, U, double>;
441
442 const auto first = static_cast<CommonType>(a);
443 const auto second = static_cast<CommonType>(b);
444
445 if (first == second) {
446 return true;
447 }
448
449 if (!std::isfinite(first) || !std::isfinite(second)) {
450 return false;
451 }
452
453 const auto difference = std::abs(first - second);
454 const auto scale = std::max(std::abs(first), std::abs(second));
455
456 return difference <= std::max(static_cast<CommonType>(absoluteTolerance),
457 static_cast<CommonType>(relativeTolerance) * scale);
458}
459
462
463} // namespace math
464
465namespace time_nanos_util {
466static constexpr std::int64_t NANOS_IN_MILLIS = 1'000'000LL;
467
468/**
469 * Returns time measured in nanoseconds since epoch from the time in milliseconds and its nano part.
470 * The result of this method is `timeMillis * 1'000'000 + timeNanoPart`.
471 *
472 * @param timeMillis time in milliseconds since epoch.
473 * @param timeNanoPart nanoseconds part that shall lie within [0..999999] interval.
474 * @return time measured in nanoseconds since epoch.
475 */
476static constexpr std::int64_t getNanosFromMillisAndNanoPart(std::int64_t timeMillis, std::int32_t timeNanoPart) {
477 return (timeMillis * NANOS_IN_MILLIS) + timeNanoPart;
478}
479
480/**
481 * Returns time measured in milliseconds since Java epoch from the time in nanoseconds.
482 * Idea is that nano part of time shall be within [0..999999] interval
483 * so that the following equation always holds
484 * `getMillisFromNanos(timeNanos) * 1'000'000 + getNanoPartFromNanos(timeNanos) == timeNanos`.
485 *
486 * @param timeNanos time measured in nanoseconds since epoch
487 * @return time measured in milliseconds since epoch.
488 * @see ::getNanoPartFromNanos()
489 */
490static constexpr std::int64_t getMillisFromNanos(std::int64_t timeNanos) {
491 return math::floorDiv(timeNanos, NANOS_IN_MILLIS);
492}
493
494/**
495 * Returns nano part of time.
496 * Idea is that nano part of time shall be within [0..999999] interval
497 * so that the following equation always holds
498 * `getMillisFromNanos(timeNanos) * 1'000'000 + getNanoPartFromNanos(timeNanos) == timeNanos`.
499 *
500 * @param timeNanos time measured in nanoseconds since epoch
501 * @return time measured in milliseconds since epoch.
502 * @see ::getMillisFromNanos()
503 */
504static constexpr std::int32_t getNanoPartFromNanos(std::int64_t timeNanos) {
505 return static_cast<std::int32_t>(math::floorMod(timeNanos, NANOS_IN_MILLIS));
506}
507
508} // namespace time_nanos_util
509
510namespace time_util {
511/// Number of milliseconds in a second.
512static constexpr std::int64_t SECOND = 1000LL;
513
514/// Number of milliseconds in a minute.
515static constexpr std::int64_t MINUTE = 60LL * SECOND;
516
517/// Number of milliseconds in an hour.
518static constexpr std::int64_t HOUR = 60LL * MINUTE;
519
520/// Number of milliseconds in an day.
521static constexpr std::int64_t DAY = 24LL * HOUR;
522
523/**
524 * Returns correct number of milliseconds with proper handling negative values.
525 * Idea is that number of milliseconds shall be within [0..999] interval
526 *
527 * @param timeMillis The timestamp in milliseconds
528 * @return a correct number of milliseconds
529 */
530static constexpr std::int32_t getMillisFromTime(std::int64_t timeMillis) {
531 return static_cast<std::int32_t>(math::floorMod(timeMillis, SECOND));
532}
533
534/**
535 * Returns correct number of seconds with proper handling negative values and overflows.
536 * Idea is that number of milliseconds shall be within [0..999] interval
537 *
538 * @param timeMillis The timestamp in milliseconds
539 * @return a correct number of second
540 */
541static constexpr std::int32_t getSecondsFromTime(std::int64_t timeMillis) {
542 if (timeMillis >= 0) {
543 return static_cast<std::int32_t>(
544 std::min(timeMillis / SECOND, static_cast<std::int64_t>(std::numeric_limits<std::int32_t>::max())));
545 }
546
547 return static_cast<std::int32_t>(
548 std::max((timeMillis + 1) / SECOND - 1, static_cast<std::int64_t>(std::numeric_limits<std::int32_t>::min())));
549}
550} // namespace time_util
551
552namespace math_util {
553
554/**
555 * Returns quotient according to number theory - i.e. when remainder is zero or positive.
556 *
557 * @tparam T The dividend's and divisor's type
558 * @param a dividend
559 * @param b divisor
560 * @return quotient according to number theory
561 */
562template <Integral T> constexpr static T div(T a, T b) {
563 if (a >= 0) {
564 return a / b;
565 }
566
567 if (b >= 0) {
568 return ((a + 1) / b) - 1;
569 }
570
571 return ((a + 1) / b) + 1;
572}
573
574template <Integral T> constexpr static T abs(T a) {
575 return a < 0 ? -a : a;
576}
577
578} // namespace math_util
579
580namespace day_util {
581
582DXFCXX_DISABLE_GCC_WARNINGS_PUSH("-Wunused-variable")
583static std::int32_t DAY_OF_YEAR[] = {0, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365};
585
586/**
587 * Returns yyyymmdd integer in Gregorian calendar for a specified day identifier.
588 * The day identifier is defined as the number of days since Unix epoch of January 1, 1970.
589 * The result is equal to `yearSign * (abs(year) * 10000 + month * 100 + day)`, where year,
590 * month, and day are in Gregorian calendar, month is between 1 and 12 inclusive, and day is counted from 1.
591 *
592 * @param dayId The day id
593 * @return integer date
594 */
595constexpr static std::int32_t getYearMonthDayByDayId(std::int32_t dayId) {
596 std::int32_t j = dayId + 2472632; // this shifts the epoch back to astronomical year -4800
597 std::int32_t g = math_util::div(j, 146097);
598 std::int32_t dg = j - g * 146097;
599 std::int32_t c = (dg / 36524 + 1) * 3 / 4;
600 std::int32_t dc = dg - c * 36524;
601 std::int32_t b = dc / 1461;
602 std::int32_t db = dc - b * 1461;
603 std::int32_t a = (db / 365 + 1) * 3 / 4;
604 std::int32_t da = db - a * 365;
605 std::int32_t y = g * 400 + c * 100 + b * 4 +
606 a; // this is the integer number of full years elapsed since March 1, 4801 BC at 00:00 UTC
607 std::int32_t m = (da * 5 + 308) / 153 -
608 2; // this is the integer number of full months elapsed since the last March 1 at 00:00 UTC
609 std::int32_t d =
610 da - (m + 4) * 153 / 5 + 122; // this is the number of days elapsed since day 1 of the month at 00:00 UTC
611 std::int32_t yyyy = y - 4800 + (m + 2) / 12;
612 std::int32_t mm = (m + 2) % 12 + 1;
613 std::int32_t dd = d + 1;
614 std::int32_t yyyymmdd = math_util::abs(yyyy) * 10000 + mm * 100 + dd;
615
616 return yyyy >= 0 ? yyyymmdd : -yyyymmdd;
617}
618
619std::int32_t getDayIdByYearMonthDay(std::int32_t year, std::int32_t month, std::int32_t day);
620
621} // namespace day_util
622
623// The bit operations of the bits library: shifts with a defined result for any shift (0 or -1 for the type width or
624// more, the other direction for a negative shift) and bitwise operations of mixed types. The names stay in dxfcpp.
625using org::ttldtor::bits::Max;
626
627using org::ttldtor::bits::leftArithmeticShift;
628using org::ttldtor::bits::leftLogicalShift;
629using org::ttldtor::bits::rightArithmeticShift;
630using org::ttldtor::bits::rightLogicalShift;
631using org::ttldtor::bits::sal;
632using org::ttldtor::bits::sar;
633using org::ttldtor::bits::shl;
634using org::ttldtor::bits::shr;
635
636using org::ttldtor::bits::andOp;
637using org::ttldtor::bits::orOp;
638using org::ttldtor::bits::xorOp;
639
640template <Integral F, Integral M, Integral S> static constexpr F getBits(F flags, M mask, S shift) noexcept {
641 return static_cast<F>(andOp(shr(flags, shift), mask));
642}
643
644template <Integral T> static constexpr T setBits(T flags, T mask, T shift, T bits) noexcept {
645 if constexpr (std::is_signed_v<T>) {
646 using U = std::make_unsigned_t<T>;
647
648 return static_cast<T>((static_cast<U>(flags) & ~(static_cast<U>(mask) << static_cast<U>(shift))) |
649 ((static_cast<U>(bits) & static_cast<U>(mask)) << static_cast<U>(shift)));
650 } else {
651 return static_cast<T>((flags & ~(mask << shift)) | ((bits & mask) << shift));
652 }
653}
654
655template <Integral F, Integral M, Integral S, Integral B>
656static constexpr F setBits(F flags, M mask, S shift, B bits) noexcept {
657 if constexpr (std::is_signed_v<F> || std::is_signed_v<M> || std::is_signed_v<S> || std::is_signed_v<B>) {
658 using U = std::make_unsigned_t<Max<F, M, S, B>>;
659
660 return static_cast<F>((static_cast<U>(flags) & ~(static_cast<U>(mask) << static_cast<U>(shift))) |
661 ((static_cast<U>(bits) & static_cast<U>(mask)) << static_cast<U>(shift)));
662 } else {
663 return (flags & ~(mask << shift)) | ((bits & mask) << shift);
664 }
665}
666
667template <std::size_t Bits> struct hashMixImpl;
668
669template <> struct hashMixImpl<64> {
670 constexpr static std::uint64_t fn(std::uint64_t x) noexcept {
671 std::uint64_t const m = (static_cast<std::uint64_t>(0xe9846af) << 32) + 0x9b1a615d;
672
673 x ^= x >> 32;
674 x *= m;
675 x ^= x >> 32;
676 x *= m;
677 x ^= x >> 28;
678
679 return x;
680 }
681};
682
683template <> struct hashMixImpl<32> {
684 constexpr static std::uint32_t fn(std::uint32_t x) noexcept {
685 std::uint32_t const m1 = 0x21f0aaad;
686 std::uint32_t const m2 = 0x735a2d97;
687
688 x ^= x >> 16;
689 x *= m1;
690 x ^= x >> 15;
691 x *= m2;
692 x ^= x >> 15;
693
694 return x;
695 }
696};
697
698constexpr static std::size_t hashMix(std::size_t v) noexcept {
699 return hashMixImpl<sizeof(std::size_t) * CHAR_BIT>::fn(v);
700}
701
702template <class T> constexpr void hashCombine(std::size_t &seed, const T &v) noexcept {
703 seed = hashMix(seed + 0x9e3779b9 + std::hash<T>()(v));
704}
705
706template <Integral T, Integral U> constexpr std::size_t pack(T t, U u) noexcept {
707 constexpr auto sizeOfSize = sizeof(std::size_t) * CHAR_BIT;
708
709 return orOp(shl(t, sizeOfSize / 2), u);
710}
711
712constexpr std::pair<std::size_t, std::size_t> unpack(std::size_t v) noexcept {
713 constexpr auto sizeOfSize = sizeof(std::size_t) * CHAR_BIT;
714
715 return {shr(v, sizeOfSize / 2), andOp(v, shr(~std::size_t{}, sizeOfSize / 2))};
716}
717
718template <typename T, typename U> T fitToType(const U &size) {
719 static_assert(sizeof(T) <= sizeof(U));
720
721 return static_cast<T>(static_cast<U>(std::numeric_limits<T>::max()) < size ? std::numeric_limits<T>::max() : size);
722}
723
724/**
725 * A simple wrapper around strings or something similar to strings to reduce the amount of code for methods that take
726 * strings as input.
727 */
730
731 private:
732 DataType data_{};
733
734 public:
735 StringLikeWrapperOld(std::string_view sv) : data_{sv} {
736 }
737
738 StringLikeWrapperOld(const char *chars) : data_{chars == nullptr ? std::string_view{} : std::string_view{chars}} {
739 }
740
741 StringLikeWrapperOld(const std::string &s) : data_{s} {
742 }
743
744 StringLikeWrapperOld(std::string &&s) : data_{std::move(s)} {
745 }
746
747 template <auto N>
748 StringLikeWrapperOld(const char (&chars)[N]) : StringLikeWrapperOld{std::string_view{chars, chars + N}} {
749 }
750
751 operator std::string() const {
752 if (auto sv = std::get_if<std::string_view>(&data_); sv) {
753 return {sv->data(), sv->size()};
754 } else {
755 return std::get<std::string>(data_);
756 }
757 }
758
759 operator std::string_view() const & {
760 if (auto sv = std::get_if<std::string_view>(&data_); sv) {
761 return *sv;
762 } else {
763 return std::get<std::string>(data_);
764 }
765 }
766
767 const char *data() const {
768 if (auto sv = std::get_if<std::string_view>(&data_); sv) {
769 return sv->data();
770 } else {
771 return std::get<std::string>(data_).c_str();
772 }
773 }
774
775 const char *c_str() const {
776 return data();
777 }
778
779 bool empty() const {
780 if (auto sv = std::get_if<std::string_view>(&data_); sv) {
781 return sv->empty();
782 } else {
783 return std::get<std::string>(data_).empty();
784 }
785 }
786
787 std::size_t size() const {
788 if (auto sv = std::get_if<std::string_view>(&data_); sv) {
789 return sv->size();
790 } else {
791 return std::get<std::string>(data_).size();
792 }
793 }
794
795 std::size_t length() const {
796 return size();
797 }
798
799 bool ends_with(const StringLikeWrapperOld &sw) const {
800 if (auto sv = std::get_if<std::string_view>(&data_); sv) {
801 return sv->ends_with(sw);
802 } else {
803 return std::get<std::string>(data_).ends_with(sw);
804 }
805 }
806
808 if (auto sv = std::get_if<std::string_view>(&data_); sv) {
809 auto sv2 = sv->substr(pos, count);
810
811 return {sv2.data(), sv2.size()};
812 } else {
813 return std::get<std::string>(data_).substr(pos, count);
814 }
815 }
816
817 bool operator==(const StringLikeWrapperOld &sw) const {
818 return sw.operator std::string_view() == this->operator std::string_view();
819 }
820
822 return sw1.operator std::string() + sw2.operator std::string();
823 }
824
825 explicit operator double() const {
826 double result{};
827
828 // At the moment, clang\apple clang's std lib does not support a version of the `from_chars` function (needed
829 // for `std::string_view`) for the `double` type.
830#ifdef _LIBCPP_VERSION
831 auto s = this->operator std::string();
832
833 result = std::stod(s);
834#else
835 auto sw = this->operator std::string_view();
836
837 std::from_chars(sw.data(), sw.data() + sw.size(), result);
838#endif
839
840 return result;
841 }
842};
843
844namespace util {
845
846void throwInvalidChar(char c, const std::string &name);
847
848inline void checkChar(char c, std::uint32_t mask, const std::string &name) {
849 if ((andOp(c, ~mask)) != 0) {
850 throwInvalidChar(c, name);
851 }
852}
853
854} // namespace util
855
856namespace math {
857
858template <Integral Type, typename ResultType = int> ResultType compare(Type v1, Type v2) {
859 if (v1 < v2) {
860 return -1;
861 }
862
863 if (v2 < v1) {
864 return 1;
865 }
866
867 return 0;
868}
869
870inline int compare(double d1, double d2) {
871 if (std::isnan(d1) || std::isnan(d2)) {
872 return std::isnan(d1) ? (std::isnan(d2) ? 0 : -1) : 1;
873 }
874
875 if (d1 < d2) {
876 return -1;
877 }
878
879 if (d1 > d2) {
880 return 1;
881 }
882
883 return 0;
884}
885
886} // namespace math
887
889
#define DXFCPP_MACRO_CONCAT_INNER(a, b)
Definition Common.hpp:135
#define DXFCPP_MACRO_CONCAT(a, b)
Definition Common.hpp:134
#define DXFCPP_MACRO_UNIQUE_NAME(base)
Definition Common.hpp:136
#define DXFCXX_DISABLE_MSC_WARNINGS_POP()
Definition Conf.hpp:31
#define DXFCXX_DISABLE_CLANG_WARNINGS_PUSH(warnings)
Definition Conf.hpp:65
#define DXFCPP_END_NAMESPACE
Definition Conf.hpp:97
#define DXFCPP_BEGIN_NAMESPACE
Definition Conf.hpp:94
#define DXFCXX_DISABLE_GCC_WARNINGS_PUSH(warnings)
Definition Conf.hpp:47
#define DXFCXX_DISABLE_CLANG_WARNINGS_POP()
Definition Conf.hpp:67
#define DXFCXX_DISABLE_GCC_WARNINGS_POP()
Definition Conf.hpp:49
#define DXFCXX_DISABLE_MSC_WARNINGS_PUSH(warnings)
Definition Conf.hpp:30
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_name(dxfc_dxendpoint_builder_t builderHandle, const char *name)
Changes the name used to distinguish multiple endpoints in the same process (GraalVM Isolate) in logs...
Definition DXEndpoint.cpp:721
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_properties(dxfc_dxendpoint_builder_t builder, const dxfc_dxendpoint_property_t **properties, size_t size)
Sets all supported properties from the provided properties object.
Definition DXEndpoint.cpp:754
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_password(dxfc_dxendpoint_t endpoint, const char *password)
Changes password for this endpoint.
Definition DXEndpoint.cpp:1002
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_publisher(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxpublisher_t *publisher)
Definition DXEndpoint.cpp:1192
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_supports_property(dxfc_dxendpoint_builder_t builder, const char *key, DXFC_OUT int *supports)
Checks if a property is supported.
Definition DXEndpoint.cpp:781
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_add_state_change_listener(dxfc_dxendpoint_t endpoint, dxfc_dxendpoint_state_change_listener listener)
Adds a listener notified about changes in state property.
Definition DXEndpoint.cpp:1138
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_disconnect(dxfc_dxendpoint_t endpoint)
Terminates all remote network connections.
Definition DXEndpoint.cpp:1053
#define DXFCPP_EXPORT
Definition api.h:35
void * dxfc_dxendpoint_builder_t
The dxFeed endpoint's builder handle.
Definition api.h:207
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_close_and_await_termination(dxfc_dxendpoint_t endpoint)
Closes this endpoint and wait until all pending data processing tasks are completed.
Definition DXEndpoint.cpp:951
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_await_not_connected(dxfc_dxendpoint_t endpoint)
Waits while this endpoint state becomes NOT_CONNECTED or CLOSED.
Definition DXEndpoint.cpp:1104
dxfc_dxendpoint_state_t
Represents the current state of endpoint.
Definition api.h:149
@ DXFC_DXENDPOINT_STATE_CLOSED
Endpoint was closed.
Definition api.h:169
@ DXFC_DXENDPOINT_STATE_NOT_CONNECTED
Endpoint was created by is not connected to remote endpoints.
Definition api.h:153
@ DXFC_DXENDPOINT_STATE_CONNECTING
The connect function was called to establish connection to remove endpoint, but the connection is not...
Definition api.h:159
@ DXFC_DXENDPOINT_STATE_CONNECTED
The connection to the remote endpoint is established.
Definition api.h:164
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_instance(void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Returns a default application-wide singleton instance of dxFeed endpoint with a FEED role.
Definition DXEndpoint.cpp:840
#define DXFC_OUT
Definition api.h:17
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_state(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxendpoint_state_t *state)
Returns the state of this endpoint.
Definition DXEndpoint.cpp:1121
void * dxfc_dxendpoint_t
The dxFeed endpoint handle.
Definition api.h:198
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_property(dxfc_dxendpoint_builder_t builder, const char *key, const char *value)
Sets the specified property.
Definition DXEndpoint.cpp:737
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_free(dxfc_dxendpoint_builder_t builder)
Removes a builder from the registry.
Definition DXEndpoint.cpp:828
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_connect(dxfc_dxendpoint_t endpoint, const char *address)
Connects to the specified remote address.
Definition DXEndpoint.cpp:1019
dxfc_error_code_t
List of error codes.
Definition api.h:49
@ DXFC_EC_ERROR
The error returned if the current operation cannot be completed.
Definition api.h:60
@ DXFC_EC_SUCCESS
OK.
Definition api.h:53
@ DXFC_EC_G_ERR
dxFeed Graal Native API error.
Definition api.h:57
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_remove_state_change_listener(dxfc_dxendpoint_t endpoint, dxfc_dxendpoint_state_change_listener listener)
Removes a listener notified about changes in state property.
Definition DXEndpoint.cpp:1164
DXFCPP_EXPORT dxfc_error_code_t dxfc_system_set_property(const char *key, const char *value)
Sets the system property indicated by the specified key.
Definition System.cpp:74
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_build(dxfc_dxendpoint_builder_t builder, void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Builds the new dxFeed endpoint instance.
Definition DXEndpoint.cpp:798
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_feed(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxfeed_t *feed)
Definition DXEndpoint.cpp:1187
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_await_processed(dxfc_dxendpoint_t endpoint)
Waits until this endpoint stops processing data (becomes quiescent).
Definition DXEndpoint.cpp:1087
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_close(dxfc_dxendpoint_t endpoint)
Closes this endpoint.
Definition DXEndpoint.cpp:934
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_new_builder(DXFC_OUT dxfc_dxendpoint_builder_t *builder)
Creates a new dxFeed endpoint's builder instance.
Definition DXEndpoint.cpp:688
void(* dxfc_dxendpoint_state_change_listener)(dxfc_dxendpoint_state_t old_state, dxfc_dxendpoint_state_t new_state, void *user_data)
The endpoint current state change listener.
Definition api.h:178
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_reconnect(dxfc_dxendpoint_t endpoint)
Terminates all established network connections and initiates connecting again with the same address.
Definition DXEndpoint.cpp:1036
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_role(dxfc_dxendpoint_t endpoint, DXFC_OUT dxfc_dxendpoint_role_t *role)
Returns the role of this endpoint.
Definition DXEndpoint.cpp:968
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_user(dxfc_dxendpoint_t endpoint, const char *user)
Changes username for this endpoint.
Definition DXEndpoint.cpp:985
DXFCPP_EXPORT dxfc_error_code_t dxfc_system_get_property(const char *key, DXFC_OUT char *buffer, size_t buffer_size)
Gets the system property indicated by the specified key.
dxfc_dxendpoint_role_t
Represents the role of an endpoint that was specified during its creation.
Definition api.h:89
@ DXFC_DXENDPOINT_ROLE_PUBLISHER
PUBLISHER endpoint connects to the remote publisher hub (also known as multiplexor) or creates a publ...
Definition api.h:127
@ DXFC_DXENDPOINT_ROLE_STREAM_FEED
STREAM_FEED endpoint is similar to DXFC_DXENDPOINT_ROLE_FEED and also connects to the remote data fee...
Definition api.h:116
@ DXFC_DXENDPOINT_ROLE_FEED
FEED endpoint connects to the remote data feed provider and is optimized for real-time or delayed dat...
Definition api.h:99
@ DXFC_DXENDPOINT_ROLE_STREAM_PUBLISHER
STREAM_PUBLISHER endpoint is similar to DXFC_DXENDPOINT_ROLE_PUBLISHER and also connects to the remot...
Definition api.h:136
@ DXFC_DXENDPOINT_ROLE_LOCAL_HUB
LOCAL_HUB endpoint is a local hub without the ability to establish network connections.
Definition api.h:143
@ DXFC_DXENDPOINT_ROLE_ON_DEMAND_FEED
ON_DEMAND_FEED endpoint is similar to DXFC_DXENDPOINT_ROLE_FEED, but it is designed to be used with d...
Definition api.h:107
void * dxfc_dxpublisher_t
The dxFeed publisher handle.
Definition api.h:217
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_create(void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Creates an endpoint with FEED role.
Definition DXEndpoint.cpp:887
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_get_instance2(dxfc_dxendpoint_role_t role, void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Returns a default application-wide singleton instance of DXEndpoint for a specific role.
Definition DXEndpoint.cpp:863
void * dxfc_dxfeed_t
The dxFeed handle.
Definition api.h:212
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_builder_with_role(dxfc_dxendpoint_builder_t builder, dxfc_dxendpoint_role_t role)
Sets role for the created dxFeed endpoint.
Definition DXEndpoint.cpp:704
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_create2(dxfc_dxendpoint_role_t role, void *user_data, DXFC_OUT dxfc_dxendpoint_t *endpoint)
Creates an endpoint with a specified role.
Definition DXEndpoint.cpp:910
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_free(dxfc_dxendpoint_t endpoint)
Removes the dxFeed endpoint from the registry.
Definition DXEndpoint.cpp:1197
DXFCPP_EXPORT dxfc_error_code_t dxfc_dxendpoint_disconnect_and_clear(dxfc_dxendpoint_t endpoint)
Terminates all remote network connections and clears stored data.
Definition DXEndpoint.cpp:1070
Builder class for DXEndpoint that supports additional configuration properties.
Definition DXEndpoint.hpp:866
std::shared_ptr< DXEndpoint > build()
Builds DXEndpoint instance.
Definition DXEndpoint.cpp:348
std::shared_ptr< Builder > withName(const StringLike &name)
Changes the name used to distinguish multiple endpoints in the same process (GraalVM Isolate) in logs...
Definition DXEndpoint.cpp:391
std::shared_ptr< Builder > withExecutor(const std::shared_ptr< Executor > &executor)
Sets the executor that is used for notifications (events, state changes, etc.) of the endpoint to bui...
Definition DXEndpoint.hpp:995
bool supportsProperty(const StringLike &key) const
Checks if a property is supported.
Definition DXEndpoint.cpp:338
std::shared_ptr< Builder > withProperties(Properties &&properties)
Sets all supported properties from the provided properties object.
Definition DXEndpoint.hpp:957
~Builder() noexcept override
Releases the GraalVM handle.
Definition DXEndpoint.cpp:380
std::shared_ptr< Builder > withRole(Role role)
Sets role for the created DXEndpoint.
Definition DXEndpoint.cpp:300
std::shared_ptr< Builder > withProperty(const StringLike &key, const StringLike &value)
Sets the specified property.
Definition DXEndpoint.cpp:313
Manages network connections to feed or publisher.
Definition DXEndpoint.hpp:179
bool isClosed() const
Definition DXEndpoint.cpp:540
SimpleHandler< void(DXEndpoint::State, DXEndpoint::State)> & onStateChange() noexcept
Returns the onStateChange handler that can be used to add or remove listeners.
Definition DXEndpoint.cpp:552
static const std::string DXFEED_PASSWORD_PROPERTY
"dxfeed.password"
Definition DXEndpoint.hpp:246
static std::shared_ptr< DXEndpoint > create(Role role)
Creates an endpoint with a specified role.
Definition DXEndpoint.cpp:527
std::shared_ptr< DXFeed > getFeed() const
Definition DXEndpoint.cpp:227
std::shared_ptr< DXEndpoint > password(const StringLike &password)
Changes password for this endpoint.
Definition DXEndpoint.cpp:154
State
Represents the current state of endpoint.
Definition DXEndpoint.hpp:444
@ CLOSED
Endpoint was closed.
Definition DXEndpoint.hpp:464
@ CONNECTING
The connect method was called to establish connection to remove endpoint, but the connection is not e...
Definition DXEndpoint.hpp:454
@ CONNECTED
The connection to the remote endpoint is established.
Definition DXEndpoint.hpp:459
@ NOT_CONNECTED
Endpoint was created by is not connected to remote endpoints.
Definition DXEndpoint.hpp:448
std::shared_ptr< DXEndpoint > user(const StringLike &user)
Changes username for this endpoint.
Definition DXEndpoint.cpp:147
void reconnect() const
Terminates all established network connections and initiates connecting again with the same address.
Definition DXEndpoint.cpp:173
static std::shared_ptr< DXEndpoint > create()
Creates an endpoint with FEED role.
Definition DXEndpoint.cpp:518
void removeStateChangeListener(std::size_t listenerId) noexcept
Removes a listener notified about changes in state property.
Definition DXEndpoint.cpp:548
const std::string & getName() const &noexcept
Definition DXEndpoint.cpp:544
Role
Represents the role of an endpoint that was specified during its creation.
Definition DXEndpoint.hpp:373
@ PUBLISHER
PUBLISHER endpoint connects to the remote publisher hub (also known as multiplexor) or creates a publ...
Definition DXEndpoint.hpp:418
@ STREAM_FEED
STREAM_FEED endpoint is similar to DXEndpoint::FEED and also connects to the remote data feed provide...
Definition DXEndpoint.hpp:406
@ LOCAL_HUB
LOCAL_HUB endpoint is a local hub without the ability to establish network connections.
Definition DXEndpoint.hpp:434
@ ON_DEMAND_FEED
ON_DEMAND_FEED endpoint is similar to DXEndpoint::FEED, but it is designed to be used with OnDemandSe...
Definition DXEndpoint.hpp:397
@ STREAM_PUBLISHER
STREAM_PUBLISHER endpoint is similar to DXEndpoint::PUBLISHER and also connects to the remote publish...
Definition DXEndpoint.hpp:427
@ FEED
FEED endpoint connects to the remote data feed provider and is optimized for real-time or delayed dat...
Definition DXEndpoint.hpp:384
std::string toString() const override
Returns a string representation of the current object.
Definition DXEndpoint.cpp:401
void awaitProcessed() const
Waits until this endpoint stops processing data (becomes quiescent).
Definition DXEndpoint.cpp:209
std::shared_ptr< DXPublisher > getPublisher() const
Definition DXEndpoint.cpp:236
static const std::string DXFEED_WILDCARD_ENABLE_PROPERTY
"dxfeed.wildcard.enable"
Definition DXEndpoint.hpp:274
std::size_t addStateChangeListener(std::function< void(State, State)> listener) noexcept
Adds a listener notified about changes in state property.
Definition DXEndpoint.hpp:619
static const std::string DXENDPOINT_EVENT_TIME_PROPERTY
"dxendpoint.eventTime"
Definition DXEndpoint.hpp:319
static const std::string DXPUBLISHER_THREAD_POOL_SIZE_PROPERTY
"dxpublisher.threadPoolSize"
Definition DXEndpoint.hpp:302
State getState() const
Returns the state of this endpoint.
Definition DXEndpoint.cpp:143
static const std::string DXENDPOINT_STORE_EVERYTHING_PROPERTY
"dxendpoint.storeEverything"
Definition DXEndpoint.hpp:332
void awaitNotConnected() const
Waits while this endpoint state becomes NOT_CONNECTED or CLOSED.
Definition DXEndpoint.cpp:200
static std::shared_ptr< DXEndpoint > getInstance(Role role)
Returns a default application-wide singleton instance of DXEndpoint for a specific role.
Definition DXEndpoint.cpp:500
static const std::string DXFEED_AGGREGATION_PERIOD_PROPERTY
"dxfeed.aggregationPeriod"
Definition DXEndpoint.hpp:265
void close() const
Closes this endpoint.
Definition DXEndpoint.cpp:556
static const std::string DXFEED_THREAD_POOL_SIZE_PROPERTY
"dxfeed.threadPoolSize"
Definition DXEndpoint.hpp:255
void disconnect() const
Terminates all remote network connections.
Definition DXEndpoint.cpp:182
void closeAndAwaitTermination() const
Closes this endpoint and wait until all pending data processing tasks are completed.
Definition DXEndpoint.cpp:218
static std::shared_ptr< DXEndpoint > getInstance()
Returns a default application-wide singleton instance of DXEndpoint with a FEED role.
Definition DXEndpoint.cpp:491
static const std::string DXPUBLISHER_ADDRESS_PROPERTY
"dxpublisher.address"
Definition DXEndpoint.hpp:293
static const std::string DXFEED_USER_PROPERTY
"dxfeed.user"
Definition DXEndpoint.hpp:236
static const std::string NAME_PROPERTY
"name"
Definition DXEndpoint.hpp:196
static const std::string DXSCHEME_ENABLED_PROPERTY_PREFIX
"dxscheme.enabled."
Definition DXEndpoint.hpp:366
static const std::string DXPUBLISHER_PROPERTIES_PROPERTY
"dxpublisher.properties"
Definition DXEndpoint.hpp:283
static const std::string DXSCHEME_NANO_TIME_PROPERTY
"dxscheme.nanoTime"
Definition DXEndpoint.hpp:352
static const std::string DXFEED_ADDRESS_PROPERTY
"dxfeed.address"
Definition DXEndpoint.hpp:226
std::shared_ptr< DXEndpoint > executor(const std::shared_ptr< Executor > &executor)
Changes the executor that is used for notifications (events, state changes, etc.) of this endpoint.
Definition DXEndpoint.hpp:655
void disconnectAndClear() const
Terminates all remote network connections and clears stored data.
Definition DXEndpoint.cpp:191
Role getRole() const noexcept
Returns the role of this endpoint.
Definition DXEndpoint.cpp:536
static const std::string DXFEED_PROPERTIES_PROPERTY
"dxfeed.properties"
Definition DXEndpoint.hpp:207
static std::shared_ptr< Builder > newBuilder()
Creates a new Builder instance.
Definition DXEndpoint.cpp:509
std::shared_ptr< DXEndpoint > connect(const StringLike &address)
Connects to the specified remote address.
Definition DXEndpoint.cpp:161
Main entry class for dxFeed API (read it first).
Definition DXFeed.hpp:141
Provides API for publishing of events to local or remote DXFeed.
Definition DXPublisher.hpp:60
Marks all event types that can be received via dxFeed API.
Definition EventType.hpp:37
std::string toString() const override
Returns a string representation of the current object.
Definition api.cpp:67
virtual std::int64_t getEventTime() const noexcept
Returns time when an event was created or zero when time is not available.
Definition api.cpp:54
virtual void assign(std::shared_ptr< EventType > event)
Replaces the contents of the event.
Definition api.cpp:63
virtual void setEventTime(std::int64_t eventTime) noexcept
Changes event creation time.
Definition api.cpp:58
Thrown to indicate that a method has been passed an illegal or inappropriate argument.
Definition InvalidArgumentException.hpp:23
Provides on-demand historical tick data replay controls.
Definition OnDemandService.hpp:77
A helper class needed to construct smart pointers to objects and does not allow explicit construction...
Definition SharedEntity.hpp:89
static auto createShared(Args &&...args)
Creates a smart pointer to an object.
Definition SharedEntity.hpp:104
A base abstract "shared entity" class. Has some helpers for dynamic polymorphism.
Definition SharedEntity.hpp:25
virtual std::string toString() const
Returns a string representation of the current object.
Definition SharedEntity.hpp:78
std::shared_ptr< T > sharedAs() const noexcept
Returns a pointer to the current object wrapped in a smart pointer to type T or std::shared_ptr<T>{nu...
Definition SharedEntity.hpp:69
std::shared_ptr< T > sharedAs() noexcept
Returns a pointer to the current object wrapped in a smart pointer to type T or std::shared_ptr<T>{nu...
Definition SharedEntity.hpp:58
bool is() const noexcept
Checks that the pointer to the current type could be converted to type T* In other words: whether typ...
Definition SharedEntity.hpp:39
A simple wrapper around strings or something similar to strings to reduce the amount of code for meth...
Definition Common.hpp:728
A lightweight wrapper around strings or string-like inputs.
Definition StringUtils.hpp:28
The simple key-value structure that represents an endpoint's property.
Definition api.h:184
const char * key
The property's key.
Definition api.h:186
const char * value
The property's value.
Definition api.h:188