string_util.hpp

/***************************************************************************
 * 
 * Copyright (c) 2011 **.com, Inc. All Rights Reserved
 * 
 **************************************************************************/



/**
 * @file string_util.hpp
 * @author zhujingwei
 * @date 2011/07/01 15:33:39
 * @brief 
 *  
 **/

#include <sstream>

#ifndef  __STRING_UTIL_H_
#define  __STRING_UTIL_H_

namespace util {

template<typename T>
inline T& left_trim(T &sz) {
	typename T::iterator ite = sz.begin();
	for(; ite != sz.end(); ++ite) {
		if (!isspace(*ite)){
			break;
		}
	}
	if (sz.end() == ite) {
		sz.clear();
	} else {
	    sz.erase(sz.begin(), ite);
	}
	return sz;
}

template<typename T>
inline T& right_trim(T &sz) {
	typename T::iterator ite = sz.end() - 1;
    for (; ;ite--) {
        if (!isspace(*ite)) {
            sz.erase(ite + 1, sz.end());
            break;
        }
        if (ite == sz.begin()) {
            sz.clear();
            break;
        }
    }
	return sz;
}

template<typename T>
inline T& trim(T &sz) {
	return left_trim(right_trim(sz));
}

template<typename T>
inline bool starts_with(const T &src, const T &subsz) {
    return (0 == src.find(subsz));
}

template<typename T>
inline bool ends_with(const T &src, const T &subsz) {
	size_t idx = src.rfind(subsz);
	return (idx != std::string::npos) && (idx == (src.length() - subsz.length()));
}

template<typename S, typename D>
inline D parse_string(const S &sz) {
    D dest;
	std::istringstream iss(sz);
	iss >> dest;
	return dest;
}

template<typename D>
inline D parse_string(const std::string &sz) {
    D dest;
	std::istringstream iss(sz);
	iss >> dest;
	return dest;
}

template<typename S, typename D>
inline D to_string(const S &num) {
	 std::ostringstream oss;
	 oss << num;
	 return oss.str();
}

template<typename S>
inline std::string to_string(const S &num) {
	 std::ostringstream oss;
	 oss << num;
	 return oss.str();
}

}
#endif // __STRING_UTIL_H_

 
// Copyright (c) 2024锛孌-Robotics. // // 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. #include "include/centernet_3d_detection_node.h" #include <unistd.h> #include <fstream> #include <memory> #include <string> #include <vector> #include <sys/stat.h> #ifdef CV_BRIDGE_PKG_ENABLED #include <cv_bridge/cv_bridge.h> #endif #include "rclcpp/rclcpp.hpp" #include "dnn_node/dnn_node.h" #include "dnn_node/util/image_proc.h" #include "opencv2/imgproc/types_c.h" CenterNet3DDetectionNode::CenterNet3DDetectionNode(const std::string &node_name, const NodeOptions &options) : DnnNode(node_name, options), output_frameCount_(0) { this->declare_parameter<std::string>("config_file_path", config_file_path_); this->declare_parameter<int>("shared_mem", shared_mem_); this->declare_parameter<std::string>("ai_msg_pub_topic_name", msg_pub_topic_name_); this->declare_parameter<std::string>("image_sub_topic_name", ros_img_topic_name_); this->declare_parameter<std::string>("feed_image", feed_image_); this->declare_parameter<int>("dump_render_img", dump_render_img_); this->get_parameter<std::string>("config_file_path", config_file_path_); this->get_parameter<int>("shared_mem", shared_mem_); this->get_parameter<std::string>("ai_msg_pub_topic_name", msg_pub_topic_name_); this->get_parameter<std::string>("image_sub_topic_name"
03-13
### Mapbox `variant.hpp` 头文件的相关信息 #### 关于 `variant.hpp` 的背景 `variant.hpp` 是由 **Mapbox Variant** 项目提供的一种实现 C++11 和 C++14 版本的 `std::variant` 替代方案的头文件[^2]。此项目的目的是在标准库尚未完全支持 `std::variant`(C++17 引入)的情况下,为开发者提供一种兼容的方式。 #### 如何获取 `variant.hpp` 可以通过访问该项目的仓库地址下载所需文件。根据描述中的链接,可以前往以下 GitCode 地址获取完整的源码和文档: - 项目地址: [https://gitcode.com/gh_mirrors/va/variant](https://gitcode.com/gh_mirrors/va/variant) 在此项目中,`variant.hpp` 文件通常位于根目录下或者特定子目录中。建议克隆整个仓库并查阅其 README 文档以了解具体使用方式。 #### 使用示例 下面是一个简单的代码片段展示如何引入和使用 `variant.hpp` 中的功能: ```cpp #include "variant.hpp" int main() { // 创建一个 variant 类型变量,它可以存储 int 或 std::string mapbox::util::variant<int, std::string> v = 42; // 访问 variant 值的方法之一:通过 get<T>() try { int value = mapbox::util::get<int>(v); printf("Variant contains an integer: %d\n", value); } catch (const mapbox::util::bad_get& e) { printf("Error accessing the variant: %s\n", e.what()); } return 0; } ``` 上述代码展示了如何利用 `mapbox::util::variant` 来替代传统的联合体或动态分配对象来处理多种数据类型的场景。 #### 配置注意事项 如果在配置过程中遇到依赖项缺失的情况(如 ICU 库),需确认开发环境中已正确安装这些必要的第三方库。例如,在构建 Mapnik 时可能会涉及类似的依赖关系管理问题[^3]。对于 ICU 相关错误,可尝试重新设置环境变量路径或将对应 `.h` 文件加入包含目录列表。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值