Skip to content

Commit 7e113e8

Browse files
committed
MOD: Rename STypes in C++
1 parent 9036b8a commit 7e113e8

File tree

6 files changed

+58
-16
lines changed

6 files changed

+58
-16
lines changed

CHANGELOG.md

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
# Changelog
22

3+
## 0.21.0 - TBD
4+
5+
### Breaking changes
6+
- Renamed `SType::Nasdaq` variant to `SType::NasdaqSymbol`
7+
- Renamed `SType::Cms` variant to `SType::CmsSymbol`
8+
9+
### Bug fixes
10+
- Added missing `ToString` and `FromString` branches for `SType::NasdaqSymbol` and
11+
`SType::CmsSymbol`
12+
- Removed `has_header_v` variable template that broke C++11 compatibility
13+
314
## 0.20.1 - 2024-07-16
415

516
### Enhancements
6-
- Improved installation with `CMake`: license is now installed, transitive dependencies are configured
7-
when importing package
17+
- Improved installation with `CMake`: license is now installed, transitive dependencies
18+
are configured when importing package
819

920
## 0.20.0 - 2024-07-09
1021

include/databento/dbn_encoder.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ class DbnEncoder {
1818
template <typename R>
1919
void EncodeRecord(const R& record) {
2020
static_assert(
21-
has_header_v<R>,
21+
has_header<R>::value,
2222
"must be a DBN record struct with an `hd` RecordHeader field");
2323
EncodeRecord(Record{&record.hd});
2424
}
2525
template <typename R>
2626
void EncodeRecord(const WithTsOut<R> record) {
2727
static_assert(
28-
has_header_v<R>,
28+
has_header<R>::value,
2929
"must be a DBN record struct with an `hd` RecordHeader field");
3030
EncodeRecord(Record{&record.rec.hd});
3131
}

include/databento/enums.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <iosfwd>
55
#include <string>
66

7-
#include "databento/publishers.hpp" // Dataset, Publisher, Venue, FromString
7+
#include "databento/publishers.hpp" // FromString
88

99
namespace databento {
1010
// Represents a historical data center gateway location.

include/databento/record.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ struct has_header : std::false_type {};
5252
template <typename T>
5353
struct has_header<T, detail::void_t<decltype(std::declval<T>().hd)>>
5454
: std::is_same<decltype(std::declval<T>().hd), RecordHeader> {};
55-
template <typename T>
56-
constexpr bool has_header_v = has_header<T>::value;
5755

5856
class Record {
5957
public:

include/databento/symbol_map.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class TsSymbolMap {
3737
template <typename R>
3838
Store::const_iterator Find(const R& rec) const {
3939
static_assert(
40-
has_header_v<R>,
40+
has_header<R>::value,
4141
"must be a DBN record struct with an `hd` RecordHeader field");
4242
date::year_month_day index_date{
4343
date::sys_days{date::floor<date::days>(rec.IndexTs())}};
@@ -50,7 +50,7 @@ class TsSymbolMap {
5050
template <typename R>
5151
const std::string& At(const R& rec) const {
5252
static_assert(
53-
has_header_v<R>,
53+
has_header<R>::value,
5454
"must be a DBN record struct with an `hd` RecordHeader field");
5555
date::year_month_day index_date{
5656
date::sys_days{date::floor<date::days>(rec.IndexTs())}};
@@ -88,7 +88,7 @@ class PitSymbolMap {
8888
template <typename R>
8989
const std::string& At(const R& rec) const {
9090
static_assert(
91-
has_header_v<R>,
91+
has_header<R>::value,
9292
"must be a DBN record struct with an `hd` RecordHeader field");
9393
return map_.at(rec.hd.instrument_id);
9494
}

src/enums.cpp

Lines changed: 39 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ const char* ToString(Schema schema) {
5353
case Schema::Definition: {
5454
return "definition";
5555
}
56-
case Schema::Imbalance: {
57-
return "imbalance";
58-
}
5956
case Schema::Statistics: {
6057
return "statistics";
6158
}
6259
case Schema::Status: {
6360
return "status";
6461
}
62+
case Schema::Imbalance: {
63+
return "imbalance";
64+
}
6565
case Schema::Cbbo: {
6666
return "cbbo";
6767
}
@@ -148,6 +148,12 @@ const char* ToString(SType stype) {
148148
case SType::Parent: {
149149
return "parent";
150150
}
151+
case SType::NasdaqSymbol: {
152+
return "nasdaq_symbol";
153+
}
154+
case SType::CmsSymbol: {
155+
return "cms_symbol";
156+
}
151157
default: {
152158
return "unknown";
153159
}
@@ -522,6 +528,9 @@ const char* ToString(StatType stat_type) {
522528
case StatType::Delta: {
523529
return "Delta";
524530
}
531+
case StatType::UncrossingPrice: {
532+
return "UncrossingPrice";
533+
}
525534
default: {
526535
return "Unknown";
527536
}
@@ -915,15 +924,33 @@ Schema FromString(const std::string& str) {
915924
if (str == "definition") {
916925
return Schema::Definition;
917926
}
918-
if (str == "imbalance") {
919-
return Schema::Imbalance;
920-
}
921927
if (str == "statistics") {
922928
return Schema::Statistics;
923929
}
924930
if (str == "status") {
925931
return Schema::Status;
926932
}
933+
if (str == "imbalance") {
934+
return Schema::Imbalance;
935+
}
936+
if (str == "cbbo") {
937+
return Schema::Cbbo;
938+
}
939+
if (str == "cbbo-1s") {
940+
return Schema::Cbbo1S;
941+
}
942+
if (str == "cbbo-1m") {
943+
return Schema::Cbbo1M;
944+
}
945+
if (str == "tcbbo") {
946+
return Schema::Tcbbo;
947+
}
948+
if (str == "bbo-1s") {
949+
return Schema::Bbo1S;
950+
}
951+
if (str == "bbo-1m") {
952+
return Schema::Bbo1M;
953+
}
927954
throw InvalidArgumentError{"FromString<Schema>", "str",
928955
"unknown value '" + str + '\''};
929956
}
@@ -984,6 +1011,12 @@ SType FromString(const std::string& str) {
9841011
if (str == "parent") {
9851012
return SType::Parent;
9861013
}
1014+
if (str == "nasdaq_symbol" || str == "nasdaq") {
1015+
return SType::NasdaqSymbol;
1016+
}
1017+
if (str == "cms_symbol" || str == "cms") {
1018+
return SType::CmsSymbol;
1019+
}
9871020
throw InvalidArgumentError{"FromString<SType>", "str",
9881021
"unknown value '" + str + '\''};
9891022
}

0 commit comments

Comments
 (0)