Skip to content

Commit

Permalink
Fix z_view_string_t to std::string conversion (#45)
Browse files Browse the repository at this point in the history
* Fix `z_view_string_t` to `std::string` conversion

* Fix formatting
  • Loading branch information
fuzzypixelz authored Nov 27, 2024
1 parent b485a93 commit 0dffa49
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions rmw_zenoh_cpp/src/detail/rmw_service_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ void service_data_handler(z_loaned_query_t * query, void * data)
RMW_ZENOH_LOG_ERROR_NAMED(
"rmw_zenoh_cpp",
"Unable to obtain ServiceData from data for "
"service for %s",
z_loan(keystr)
"service for %.*s",
static_cast<int>(z_string_len(z_loan(keystr))),
z_string_data(z_loan(keystr))
);
return;
}
Expand Down
4 changes: 3 additions & 1 deletion rmw_zenoh_cpp/src/detail/rmw_subscription_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,14 @@ void sub_data_handler(z_loaned_sample_t * sample, void * data)
z_owned_slice_t slice;
z_bytes_to_slice(payload, &slice);

std::string topic_name(z_string_data(z_loan(keystr)), z_string_len(z_loan(keystr)));

sub_data->add_new_message(
std::make_unique<SubscriptionData::Message>(
slice,
z_timestamp_ntp64_time(z_sample_timestamp(sample)),
std::move(attachment)),
z_string_data(z_loan(keystr)));
&topic_name);
}
} // namespace

Expand Down
5 changes: 4 additions & 1 deletion rmw_zenoh_cpp/src/detail/zenoh_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ void create_map_and_set_sequence_num(
}

///=============================================================================
ZenohQuery::ZenohQuery(const z_loaned_query_t * query, std::chrono::nanoseconds::rep received_timestamp) {
ZenohQuery::ZenohQuery(
const z_loaned_query_t * query,
std::chrono::nanoseconds::rep received_timestamp)
{
z_query_clone(&query_, query);
received_timestamp_ = received_timestamp;
}
Expand Down

0 comments on commit 0dffa49

Please sign in to comment.