Skip to content

Commit

Permalink
VER: Release 0.17.1
Browse files Browse the repository at this point in the history
  • Loading branch information
threecgreen authored Apr 8, 2024
2 parents d6669f6 + 5ac56ba commit a56e606
Show file tree
Hide file tree
Showing 27 changed files with 91 additions and 78 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 0.17.1 - 2024-04-08

### Enhancements
- Added support for Conan-installed zstd (credit: @Hailios)

### Bug fixes
- Added missing copying of `ts_event` when upgrading structs from DBNv1 to DBNv2
- Fixed setting of compiler warnings and warnings that had accumulated

## 0.17.0 - 2024-04-01

### Enhancements
Expand Down
8 changes: 3 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ cmake_minimum_required(VERSION 3.14)
# Project details
#

project("databento" VERSION 0.17.0 LANGUAGES CXX)
project("databento" VERSION 0.17.1 LANGUAGES CXX)
string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPERCASE)

#
Expand Down Expand Up @@ -102,16 +102,14 @@ message(STATUS "Added all header and implementation files.")

target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11)
include(cmake/CompilerWarnings.cmake)
set_project_warnings(${PROJECT_NAME})
set_target_warnings(${PROJECT_NAME})
include(cmake/Sanitizers.cmake)

# Ensure std::string debug info is included
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_options(${PROJECT_NAME} PRIVATE -fstandalone-debug)
endif()

verbose_message("Applied compiler warnings.")

#
# Model project dependencies
#
Expand Down Expand Up @@ -211,7 +209,7 @@ target_link_libraries(
OpenSSL::Crypto
OpenSSL::SSL
Threads::Threads
zstd::zstd
${ZSTD_TARGET}
)

target_compile_definitions(
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ These examples can be compiled by enabling the cmake option `DATABENTO_ENABLE_EX

## Documentation

You can find more detailed examples and the full API documentation on the [Databento doc site](https://docs.databento.com/getting-started?historical=cpp&live=cpp).
You can find more detailed examples and the full API documentation on the [Databento doc site](https://databento.com/docs/getting-started?historical=cpp&live=cpp).

## License

Expand Down
18 changes: 7 additions & 11 deletions cmake/CompilerWarnings.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# from here:
#
# https://github.com/lefticus/cppbestpractices/blob/master/02-Use_the_Tools_Avai
# lable.md
# https://github.com/lefticus/cppbestpractices/blob/master/02-Use_the_Tools_Available.md
# Courtesy of Jason Turner

function(set_project_warnings project_name)
function(set_target_warnings target)
set(MSVC_WARNINGS
/w14242 # 'identifier': conversion from 'type1' to 'type1', possible loss
# of data
Expand Down Expand Up @@ -71,6 +70,7 @@ function(set_project_warnings project_name)
# probably wanted
-Wuseless-cast # warn if you perform a cast to the same type
-Wno-ignored-attributes
-Wno-dangling-reference # False positives with nlohmann_json
)

if (${PROJECT_NAME}_WARNINGS_AS_ERRORS)
Expand All @@ -80,18 +80,14 @@ function(set_project_warnings project_name)
endif()

if(MSVC)
set(PROJECT_WARNINGS ${MSVC_WARNINGS})
set(WARNINGS ${MSVC_WARNINGS})
elseif(CMAKE_CXX_COMPILER_ID MATCHES ".*Clang")
set(PROJECT_WARNINGS ${CLANG_WARNINGS})
set(WARNINGS ${CLANG_WARNINGS})
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(PROJECT_WARNINGS ${GCC_WARNINGS})
set(WARNINGS ${GCC_WARNINGS})
else()
message(AUTHOR_WARNING "No compiler warnings set for '${CMAKE_CXX_COMPILER_ID}' compiler.")
endif()

add_compile_options(${PROJECT_WARNINGS})

if(NOT TARGET ${project_name})
message(AUTHOR_WARNING "${project_name} is not a target, thus no compiler warning were added.")
endif()
target_compile_options(${target} PRIVATE ${WARNINGS})
endfunction()
12 changes: 12 additions & 0 deletions cmake/FindZstd.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,15 @@ if(ZSTD_FOUND AND NOT TARGET zstd::zstd)
INTERFACE_INCLUDE_DIRECTORIES ${ZSTD_INCLUDE_DIR}
)
endif()

# Check if the Conan-provided target exists
if(TARGET zstd::libzstd_static)
# If the Conan target exists, use it
set(ZSTD_TARGET zstd::libzstd_static)
elseif(TARGET zstd::zstd)
# If the system-installed target exists, use it
set(ZSTD_TARGET zstd::zstd)
else()
# Error out if neither target is found
message(FATAL_ERROR "Zstd target not found.")
endif()
1 change: 1 addition & 0 deletions cmake/Utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ function(add_example_target name file)
databento::databento
)
target_compile_features(${name} PUBLIC cxx_std_11)
set_target_warnings(${name})
endfunction()
2 changes: 0 additions & 2 deletions include/databento/batch.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#pragma once

#include <cstddef>
#include <cstdint>
#include <ostream>
#include <string>
#include <vector>

#include "databento/datetime.hpp" // UnixNanos
#include "databento/enums.hpp" // JobState, Delivery, Packaging, Schema, SType

namespace databento {
Expand Down
1 change: 0 additions & 1 deletion include/databento/dbn_file_store.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <string>

#include "databento/dbn.hpp" // Metadata
#include "databento/dbn_decoder.hpp" // DbnDecoder
#include "databento/enums.hpp" // VersionUpgradePolicy
#include "databento/timeseries.hpp" // MetadataCallback, RecordCallback
Expand Down
1 change: 0 additions & 1 deletion include/databento/flag_set.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <bitset>
#include <cstdint>
#include <ostream>
#include <string>

namespace databento {
// Transparent wrapper around the bit flags used in several DBN record types.
Expand Down
1 change: 0 additions & 1 deletion include/databento/historical.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,6 @@ class Historical {
DbnFileStore TimeseriesGetRangeToFile(const HttplibParams& params,
const std::string& file_path);

ILogReceiver* log_receiver_;
const std::string key_;
const std::string gateway_;
detail::HttpClient client_;
Expand Down
1 change: 0 additions & 1 deletion include/databento/live.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include <cstdint>
#include <string>

#include "databento/enums.hpp" // VersionUpgradePolicy
Expand Down
1 change: 0 additions & 1 deletion include/databento/live_blocking.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include <array>
#include <chrono> // milliseconds
#include <cstdint>
#include <memory>
#include <string>
#include <vector>

Expand Down
2 changes: 0 additions & 2 deletions include/databento/live_threaded.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
#include <vector>

#include "databento/datetime.hpp" // UnixNanos
#include "databento/dbn.hpp" // Metadata
#include "databento/detail/scoped_thread.hpp" // ScopedThread
#include "databento/enums.hpp" // Schema, SType
#include "databento/record.hpp" // Record
#include "databento/timeseries.hpp" // MetadataCallback, RecordCallback

namespace databento {
Expand Down
1 change: 0 additions & 1 deletion include/databento/metadata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <map>
#include <ostream>
#include <string>
#include <vector>

#include "databento/enums.hpp" // FeedMode, DatasetCondition, Schema

Expand Down
1 change: 0 additions & 1 deletion include/databento/record.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#pragma once

#include <array>
#include <chrono> // nanoseconds
#include <cstddef>
#include <cstdint>
#include <cstring> // strncmp
Expand Down
1 change: 0 additions & 1 deletion include/databento/symbology.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#pragma once

#include <cstdint>
#include <ostream>
#include <string>
#include <unordered_map>
Expand Down
2 changes: 1 addition & 1 deletion pkg/PKGBUILD
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Maintainer: Databento <[email protected]>
_pkgname=databento-cpp
pkgname=databento-cpp-git
pkgver=0.17.0
pkgver=0.17.1
pkgrel=1
pkgdesc="Official C++ client for Databento"
arch=('any')
Expand Down
14 changes: 9 additions & 5 deletions src/compat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ namespace databento {
InstrumentDefMsgV2 InstrumentDefMsgV1::ToV2() const {
InstrumentDefMsgV2 ret{
RecordHeader{sizeof(InstrumentDefMsgV2) / RecordHeader::kLengthMultiplier,
RType::InstrumentDef, hd.publisher_id, hd.instrument_id},
RType::InstrumentDef, hd.publisher_id, hd.instrument_id,
hd.ts_event},
ts_recv,
min_price_increment,
display_factor,
Expand Down Expand Up @@ -72,7 +73,7 @@ InstrumentDefMsgV2 InstrumentDefMsgV1::ToV2() const {
contract_multiplier_unit,
flow_schedule_type,
tick_rule,
};
{}};
std::copy(currency.begin(), currency.end(), ret.currency.begin());
std::copy(settl_currency.begin(), settl_currency.end(),
ret.settl_currency.begin());
Expand All @@ -95,7 +96,8 @@ InstrumentDefMsgV2 InstrumentDefMsgV1::ToV2() const {
ErrorMsgV2 ErrorMsgV1::ToV2() const {
ErrorMsgV2 ret{
RecordHeader{sizeof(ErrorMsgV2) / RecordHeader::kLengthMultiplier,
RType::Error, hd.publisher_id, hd.instrument_id},
RType::Error, hd.publisher_id, hd.instrument_id,
hd.ts_event},
{},
std::numeric_limits<std::uint8_t>::max(),
std::numeric_limits<std::uint8_t>::max()};
Expand All @@ -106,7 +108,8 @@ ErrorMsgV2 ErrorMsgV1::ToV2() const {
SymbolMappingMsgV2 SymbolMappingMsgV1::ToV2() const {
SymbolMappingMsgV2 ret{
RecordHeader{sizeof(SymbolMappingMsgV2) / RecordHeader::kLengthMultiplier,
RType::SymbolMapping, hd.publisher_id, hd.instrument_id},
RType::SymbolMapping, hd.publisher_id, hd.instrument_id,
hd.ts_event},
// invalid
static_cast<SType>(std::numeric_limits<std::uint8_t>::max()),
{},
Expand All @@ -125,7 +128,8 @@ SymbolMappingMsgV2 SymbolMappingMsgV1::ToV2() const {
SystemMsgV2 SystemMsgV1::ToV2() const {
SystemMsgV2 ret{
RecordHeader{sizeof(SystemMsgV2) / RecordHeader::kLengthMultiplier,
RType::System, hd.publisher_id, hd.instrument_id},
RType::System, hd.publisher_id, hd.instrument_id,
hd.ts_event},
{},
std::numeric_limits<std::uint8_t>::max()};
std::copy(msg.begin(), msg.end(), ret.msg.begin());
Expand Down
7 changes: 3 additions & 4 deletions src/datetime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,9 @@ std::string ToIso8601(UnixNanos unix_nanos) {
return "UNDEF_TIMESTAMP";
}
std::array<char, 80> buf{};
const auto time =
static_cast<std::time_t>(std::chrono::duration_cast<std::chrono::seconds>(
unix_nanos.time_since_epoch())
.count());
const std::time_t time = std::chrono::duration_cast<std::chrono::seconds>(
unix_nanos.time_since_epoch())
.count();
std::tm tm = {};
#ifdef _WIN32
if (::gmtime_s(&tm, &time) != 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/dbn_decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ std::string Consume(std::vector<std::uint8_t>::const_iterator& byte_it,
const std::ptrdiff_t num_bytes, const char* context) {
const auto cstr = Consume(byte_it, num_bytes);
// strnlen isn't portable
const std::size_t str_len = std::find(cstr, cstr + num_bytes, '\0') - cstr;
const auto str_len = std::find(cstr, cstr + num_bytes, '\0') - cstr;
if (str_len == num_bytes) {
throw databento::DbnResponseError{std::string{"Invalid "} + context +
" missing null terminator"};
}
return std::string{cstr, str_len};
return std::string{cstr, static_cast<std::size_t>(str_len)};
}
} // namespace

Expand Down
8 changes: 3 additions & 5 deletions src/historical.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,15 +148,13 @@ std::string PathJoin(const std::string& dir, const std::string& path) {

Historical::Historical(ILogReceiver* log_receiver, std::string key,
HistoricalGateway gateway)
: log_receiver_{log_receiver},
key_{std::move(key)},
: key_{std::move(key)},
gateway_{UrlFromGateway(gateway)},
client_{log_receiver, key_, gateway_} {}

Historical::Historical(ILogReceiver* log_receiver, std::string key,
std::string gateway, std::uint16_t port)
: log_receiver_{log_receiver},
key_{std::move(key)},
: key_{std::move(key)},
gateway_{std::move(gateway)},
client_{log_receiver, key_, gateway_, port} {}

Expand Down Expand Up @@ -908,7 +906,7 @@ void Historical::TimeseriesGetRange(const HttplibParams& params,
break;
}
}
} catch (const std::exception& exc) {
} catch (const std::exception&) {
should_continue = false;
// wait for thread to finish before checking for exceptions
stream.Join();
Expand Down
4 changes: 2 additions & 2 deletions src/live_threaded.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ using databento::LiveThreaded;

struct LiveThreaded::Impl {
template <typename... A>
explicit Impl(ILogReceiver* log_receiver, A&&... args)
: log_receiver{log_receiver},
explicit Impl(ILogReceiver* log_recv, A&&... args)
: log_receiver{log_recv},
blocking{log_receiver, std::forward<A>(args)...} {}

void NotifyOfStop() {
Expand Down
4 changes: 4 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ set(
src/zstd_stream_tests.cpp
)
add_executable(${PROJECT_NAME} ${test_headers} ${test_sources})
if(WIN32)
# Disable warnings
target_compile_options(${PROJECT_NAME} PRIVATE /w)
endif()
find_package(Threads REQUIRED)

target_link_libraries(
Expand Down
14 changes: 9 additions & 5 deletions test/src/dbn_decoder_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,13 +157,17 @@ TEST_F(DbnDecoderTests, TestUpgradeSymbolMappingWithTsOut) {
DbnDecoder::DecodeRecordCompat(1, VersionUpgradePolicy::Upgrade, true,
&compat_buffer, Record{&orig.rec.hd});
const auto& upgraded = res.Get<WithTsOut<SymbolMappingMsgV2>>();
ASSERT_EQ(orig.ts_out, upgraded.ts_out);
ASSERT_STREQ(orig.rec.STypeInSymbol(), upgraded.rec.STypeInSymbol());
ASSERT_STREQ(orig.rec.STypeOutSymbol(), upgraded.rec.STypeOutSymbol());
EXPECT_EQ(orig.rec.hd.rtype, upgraded.rec.hd.rtype);
EXPECT_EQ(orig.rec.hd.instrument_id, upgraded.rec.hd.instrument_id);
EXPECT_EQ(orig.rec.hd.publisher_id, upgraded.rec.hd.publisher_id);
EXPECT_EQ(orig.rec.hd.ts_event, upgraded.rec.hd.ts_event);
EXPECT_EQ(orig.ts_out, upgraded.ts_out);
EXPECT_STREQ(orig.rec.STypeInSymbol(), upgraded.rec.STypeInSymbol());
EXPECT_STREQ(orig.rec.STypeOutSymbol(), upgraded.rec.STypeOutSymbol());
// `length` properly set
ASSERT_EQ(upgraded.rec.hd.Size(), sizeof(upgraded));
EXPECT_EQ(upgraded.rec.hd.Size(), sizeof(upgraded));
// used compat buffer
ASSERT_EQ(reinterpret_cast<const std::uint8_t*>(&upgraded),
EXPECT_EQ(reinterpret_cast<const std::uint8_t*>(&upgraded),
compat_buffer.data());
}

Expand Down
Loading

0 comments on commit a56e606

Please sign in to comment.