-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MDAPI-26] Update Graal SDK to v1.1.21
TimePeriod
- Loading branch information
1 parent
01e0e9a
commit 781a909
Showing
12 changed files
with
283 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
include/dxfeed_graal_cpp_api/isolated/util/IsolatedTimePeriod.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright (c) 2024 Devexperts LLC. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
#pragma once | ||
|
||
#include "../../internal/Conf.hpp" | ||
|
||
#include <cstdint> | ||
#include <string> | ||
#include <string_view> | ||
|
||
DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251) | ||
|
||
#include "../../util/TimePeriod.hpp" | ||
|
||
DXFCPP_BEGIN_NAMESPACE | ||
|
||
namespace isolated::util::IsolatedTimePeriod { | ||
|
||
/* | ||
dxfg_time_period_t* dxfg_TimePeriod_ZERO(graal_isolatethread_t *thread); | ||
dxfg_time_period_t* dxfg_TimePeriod_UNLIMITED(graal_isolatethread_t *thread); | ||
dxfg_time_period_t* dxfg_TimePeriod_valueOf(graal_isolatethread_t *thread, int64_t value); | ||
dxfg_time_period_t* dxfg_TimePeriod_valueOf2(graal_isolatethread_t *thread, const char* value); | ||
int64_t dxfg_TimePeriod_getTime(graal_isolatethread_t *thread, dxfg_time_period_t* timePeriod); | ||
int32_t dxfg_TimePeriod_getSeconds(graal_isolatethread_t *thread, dxfg_time_period_t* timePeriod); | ||
int64_t dxfg_TimePeriod_getNanos(graal_isolatethread_t *thread, dxfg_time_period_t* timePeriod); | ||
*/ | ||
|
||
/* dxfg_time_period_t* */ JavaObjectHandle<TimePeriod> ZERO(); | ||
/* dxfg_time_period_t* */ JavaObjectHandle<TimePeriod> UNLIMITED(); | ||
/* dxfg_time_period_t* */ JavaObjectHandle<TimePeriod> valueOf(std::int64_t value); | ||
/* dxfg_time_period_t* */ JavaObjectHandle<TimePeriod> valueOf(std::string_view value); | ||
std::int64_t getTime(/* dxfg_time_period_t* */ const JavaObjectHandle<TimePeriod>& timePeriod); | ||
std::int32_t getSeconds(/* dxfg_time_period_t* */ const JavaObjectHandle<TimePeriod>& timePeriod); | ||
std::int64_t getNanos(/* dxfg_time_period_t* */ const JavaObjectHandle<TimePeriod>& timePeriod); | ||
|
||
} | ||
|
||
DXFCPP_END_NAMESPACE | ||
|
||
DXFCXX_DISABLE_MSC_WARNINGS_POP() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
// Copyright (c) 2024 Devexperts LLC. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
#pragma once | ||
|
||
#include "../internal/Conf.hpp" | ||
|
||
DXFCXX_DISABLE_MSC_WARNINGS_PUSH(4251) | ||
|
||
#include <cstdint> | ||
|
||
DXFCPP_BEGIN_NAMESPACE | ||
|
||
/** | ||
* Value class for period of time with support for ISO8601 duration format. | ||
*/ | ||
struct DXFCPP_EXPORT TimePeriod { | ||
/// Time-period of zero. | ||
static const TimePeriod ZERO; | ||
|
||
/// Time-period of "infinity" (time of `std::numeric_limits<std::int64_t>::max()` or `LLONG_MAX`). | ||
static const TimePeriod UNLIMITED; | ||
|
||
/** | ||
* Returns TimePeriod with <tt>value</tt> milliseconds. | ||
* | ||
* @param value value in milliseconds | ||
* @return TimePeriod with <tt>value</tt> milliseconds. | ||
*/ | ||
static TimePeriod valueOf(std::int64_t value); | ||
|
||
/** | ||
* Returns TimePeriod with <tt>value</tt> milliseconds. | ||
* | ||
* @param value value in milliseconds | ||
* @return TimePeriod with <tt>value</tt> milliseconds. | ||
*/ | ||
static TimePeriod valueOf(std::chrono::milliseconds value) { | ||
return valueOf(value.count()); | ||
} | ||
|
||
/** | ||
* Returns TimePeriod represented with a given string. | ||
* | ||
* Allowable format is ISO8601 duration, but there are some simplifications and modifications available: | ||
* <ul> | ||
* <li> Letters are case insensitive. | ||
* <li> Letters "P" and "T" can be omitted. | ||
* <li> Letter "S" can be also omitted. In this case last number will be supposed to be seconds. | ||
* <li> Number of seconds can be fractional. So it is possible to define duration accurate within milliseconds. | ||
* <li> Every part can be omitted. It is supposed that it's value is zero then. | ||
* <li> String "inf" recognized as unlimited period. | ||
* </ul> | ||
* | ||
* @param value The string representation | ||
* @return TimePeriod represented with a given string. | ||
*/ | ||
static TimePeriod valueOf(const StringLikeWrapper &value); | ||
|
||
/** | ||
* Returns value in milliseconds. | ||
* | ||
* @return value in milliseconds | ||
*/ | ||
std::int64_t getTime() const; | ||
|
||
/** | ||
* Returns value in seconds. | ||
* | ||
* @return value in seconds | ||
*/ | ||
std::int32_t getSeconds() const; | ||
|
||
/** | ||
* Returns value in nanoseconds. | ||
* | ||
* @return value in nanoseconds | ||
*/ | ||
std::int64_t getNanos() const; | ||
|
||
virtual ~TimePeriod() noexcept = default; | ||
|
||
TimePeriod(const TimePeriod &) = delete; | ||
TimePeriod(TimePeriod &&) noexcept = delete; | ||
TimePeriod &operator=(const TimePeriod &) = delete; | ||
TimePeriod &operator=(const TimePeriod &&) noexcept = delete; | ||
|
||
private: | ||
JavaObjectHandle<TimePeriod> handle_; | ||
|
||
explicit TimePeriod(JavaObjectHandle<TimePeriod> &&handle); | ||
}; | ||
|
||
DXFCPP_END_NAMESPACE | ||
|
||
DXFCXX_DISABLE_MSC_WARNINGS_POP() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright (c) 2024 Devexperts LLC. | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
#include <dxfg_api.h> | ||
|
||
#include <dxfeed_graal_cpp_api/isolated/IsolatedCommon.hpp> | ||
#include <dxfeed_graal_cpp_api/isolated/util/IsolatedTimePeriod.hpp> | ||
|
||
DXFCPP_BEGIN_NAMESPACE | ||
|
||
namespace isolated::util::IsolatedTimePeriod { | ||
/* dxfg_time_period_t* */ JavaObjectHandle<TimePeriod> ZERO() { | ||
return JavaObjectHandle<TimePeriod>(runGraalFunctionAndThrowIfNullptr(dxfg_TimePeriod_ZERO)); | ||
} | ||
|
||
/* dxfg_time_period_t* */ JavaObjectHandle<TimePeriod> UNLIMITED() { | ||
return JavaObjectHandle<TimePeriod>(runGraalFunctionAndThrowIfNullptr(dxfg_TimePeriod_UNLIMITED)); | ||
} | ||
|
||
/* dxfg_time_period_t* */ JavaObjectHandle<TimePeriod> valueOf(std::int64_t value) { | ||
return JavaObjectHandle<TimePeriod>(runGraalFunctionAndThrowIfNullptr(dxfg_TimePeriod_valueOf, value)); | ||
} | ||
|
||
/* dxfg_time_period_t* */ JavaObjectHandle<TimePeriod> valueOf(std::string_view value) { | ||
return JavaObjectHandle<TimePeriod>(runGraalFunctionAndThrowIfNullptr(dxfg_TimePeriod_valueOf2, value.data())); | ||
} | ||
|
||
std::int64_t getTime(/* dxfg_time_period_t* */ const JavaObjectHandle<TimePeriod> &timePeriod) { | ||
if (!timePeriod) { | ||
throw std::invalid_argument( | ||
"Unable to execute function `dxfg_TimePeriod_getTime`. The `timePeriod` handle is invalid"); | ||
} | ||
|
||
return runGraalFunctionAndThrowIfMinusOne(dxfg_TimePeriod_getTime, | ||
static_cast<dxfg_time_period_t *>(timePeriod.get())); | ||
} | ||
|
||
std::int32_t getSeconds(/* dxfg_time_period_t* */ const JavaObjectHandle<TimePeriod> &timePeriod) { | ||
if (!timePeriod) { | ||
throw std::invalid_argument( | ||
"Unable to execute function `dxfg_TimePeriod_getSeconds`. The `timePeriod` handle is invalid"); | ||
} | ||
|
||
return runGraalFunctionAndThrowIfMinusOne(dxfg_TimePeriod_getSeconds, | ||
static_cast<dxfg_time_period_t *>(timePeriod.get())); | ||
} | ||
|
||
std::int64_t getNanos(/* dxfg_time_period_t* */ const JavaObjectHandle<TimePeriod> &timePeriod) { | ||
if (!timePeriod) { | ||
throw std::invalid_argument( | ||
"Unable to execute function `dxfg_TimePeriod_getNanos`. The `timePeriod` handle is invalid"); | ||
} | ||
|
||
return runGraalFunctionAndThrowIfMinusOne(dxfg_TimePeriod_getNanos, | ||
static_cast<dxfg_time_period_t *>(timePeriod.get())); | ||
} | ||
|
||
} // namespace isolated::util::IsolatedTimePeriod | ||
|
||
DXFCPP_END_NAMESPACE |
Oops, something went wrong.