.. _program_listing_file__tmp_ws_src_point_cloud_msg_wrapper_point_cloud_msg_wrapper_include_point_cloud_msg_wrapper_field_properties.hpp: Program Listing for File field_properties.hpp ============================================= |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/point_cloud_msg_wrapper/point_cloud_msg_wrapper/include/point_cloud_msg_wrapper/field_properties.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp // Copyright 2021 Apex.AI, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef POINT_CLOUD_MSG_WRAPPER__FIELD_PROPERTIES_HPP_ #define POINT_CLOUD_MSG_WRAPPER__FIELD_PROPERTIES_HPP_ #include #include namespace point_cloud_msg_wrapper { inline std::uint32_t sizeof_field(const std::uint8_t datatype) { switch (datatype) { case sensor_msgs::msg::PointField::INT8: case sensor_msgs::msg::PointField::UINT8: return 2U; case sensor_msgs::msg::PointField::INT16: case sensor_msgs::msg::PointField::UINT16: return 2U; case sensor_msgs::msg::PointField::INT32: case sensor_msgs::msg::PointField::UINT32: case sensor_msgs::msg::PointField::FLOAT32: return 4U; case sensor_msgs::msg::PointField::FLOAT64: return 8U; } throw std::runtime_error("Unexpected datatype provided"); } template inline constexpr std::uint32_t get_field_count() { static_assert(sizeof(T) == -1, "Only specializations of this function are expected"); return 0U; } template inline constexpr std::uint8_t get_field_datatype() { static_assert(sizeof(T) == -1, "Only specializations of this function are expected"); return 0U; } template<> inline constexpr std::uint32_t get_field_count() {return 1U;} template<> inline constexpr std::uint32_t get_field_count() {return 1U;} template<> inline constexpr std::uint32_t get_field_count() {return 1U;} template<> inline constexpr std::uint32_t get_field_count() {return 1U;} template<> inline constexpr std::uint32_t get_field_count() {return 1U;} template<> inline constexpr std::uint32_t get_field_count() {return 1U;} template<> inline constexpr std::uint32_t get_field_count() {return 1U;} template<> inline constexpr std::uint32_t get_field_count() {return 1U;} template<> inline constexpr std::uint32_t get_field_count() {return 2U;} template<> inline constexpr std::uint32_t get_field_count() {return 2U;} template<> inline constexpr std::uint8_t get_field_datatype() { return sensor_msgs::msg::PointField::FLOAT32; } template<> inline constexpr std::uint8_t get_field_datatype() { return sensor_msgs::msg::PointField::FLOAT64; } template<> inline constexpr std::uint8_t get_field_datatype() { return sensor_msgs::msg::PointField::INT8; } template<> inline constexpr std::uint8_t get_field_datatype() { return sensor_msgs::msg::PointField::UINT8; } template<> inline constexpr std::uint8_t get_field_datatype() { return sensor_msgs::msg::PointField::INT16; } template<> inline constexpr std::uint8_t get_field_datatype() { return sensor_msgs::msg::PointField::UINT16; } template<> inline constexpr std::uint8_t get_field_datatype() { return sensor_msgs::msg::PointField::INT32; } template<> inline constexpr std::uint8_t get_field_datatype() { return sensor_msgs::msg::PointField::UINT32; } template<> inline constexpr std::uint8_t get_field_datatype() { return sensor_msgs::msg::PointField::INT32; } template<> inline constexpr std::uint8_t get_field_datatype() { return sensor_msgs::msg::PointField::UINT32; } } // namespace point_cloud_msg_wrapper #endif // POINT_CLOUD_MSG_WRAPPER__FIELD_PROPERTIES_HPP_