Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
C API: Implement MEOS_TFloatInst_value and MEOS_TFloatInst_timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
chaitan94 committed Sep 25, 2020
1 parent 3fbbeed commit 8ddefd6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions capi/include/meos/meos_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ MEOS_TFloatInst *MEOS_newTFloatInst(char *serialized);
// Constructor with a value and timestamp
MEOS_TFloatInst *MEOS_newTFloatInst_VT(float value, time_t timestamp);

float MEOS_TFloatInst_value(MEOS_TFloatInst *tfloatinst);
time_t MEOS_TFloatInst_timestamp(MEOS_TFloatInst *tfloatinst);
char *MEOS_TFloatInst_str(MEOS_TFloatInst *tfloatinst);

void MEOS_deleteTFloatInst(MEOS_TFloatInst *tfloatinst);
Expand Down
10 changes: 10 additions & 0 deletions capi/source/meos_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,16 @@ MEOS_TFloatInst *MEOS_newTFloatInst_VT(float value, time_t timestamp) {
new meos::TFloatInst(value, std::chrono::system_clock::from_time_t(timestamp)));
}

float MEOS_TFloatInst_value(MEOS_TFloatInst *tfloatinst) {
auto t = reinterpret_cast<meos::TFloatInst *>(tfloatinst);
return t->getValue();
}

time_t MEOS_TFloatInst_timestamp(MEOS_TFloatInst *tfloatinst) {
auto t = reinterpret_cast<meos::TFloatInst *>(tfloatinst);
return std::chrono::system_clock::to_time_t(t->getTimestamp());
}

// Remember to free the result!
char *MEOS_TFloatInst_str(MEOS_TFloatInst *tfloatinst) {
auto t = reinterpret_cast<meos::TFloatInst *>(tfloatinst);
Expand Down

0 comments on commit 8ddefd6

Please sign in to comment.