Skip to content

Commit

Permalink
Use boost's regex library instead of C++11's std mechanism
Browse files Browse the repository at this point in the history
  • Loading branch information
Panagiotis Vlantis committed May 13, 2024
1 parent 5a4b3b7 commit ba5ded1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion rosbag_snapshot/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ project(rosbag_snapshot)

find_package(catkin REQUIRED COMPONENTS rosbag rosbag_snapshot_msgs roscpp rosgraph_msgs std_srvs topic_tools)

find_package(Boost REQUIRED COMPONENTS program_options)
find_package(Boost REQUIRED COMPONENTS program_options regex)

catkin_package(
CATKIN_DEPENDS rosbag rosbag_snapshot_msgs roscpp rosgraph_msgs std_srvs topic_tools
Expand Down
6 changes: 3 additions & 3 deletions rosbag_snapshot/include/rosbag_snapshot/snapshotter.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <boost/atomic.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/shared_mutex.hpp>
#include <boost/regex.hpp>
#include <ros/ros.h>
#include <ros/time.h>
#include <rosbag_snapshot_msgs/TriggerSnapshot.h>
Expand All @@ -52,7 +53,6 @@
#include <utility>
#include <vector>
#include <memory>
#include <regex>

namespace rosbag_snapshot
{
Expand Down Expand Up @@ -95,15 +95,15 @@ class ROSBAG_DECL SnapshotterTopicPattern
public:
SnapshotterTopicPattern(const std::string &pattern, const SnapshotterTopicOptions &topic_options);

const std::regex& get_pattern() const;
const boost::regex& get_pattern() const;
const SnapshotterTopicOptions& get_topic_options() const;

// Return true if pattern matches the given topic name exactly.
bool matches(const std::string &topic) const;

private:
// Maximum difference in time from newest and oldest message in buffer before older messages are removed
std::regex pattern_;
boost::regex pattern_;
SnapshotterTopicOptions topic_options_;
};
typedef std::shared_ptr<SnapshotterTopicPattern> SnapshotterTopicPatternPtr;
Expand Down
6 changes: 3 additions & 3 deletions rosbag_snapshot/src/snapshotter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ bool SnapshotterOptions::addPattern(std::string const& pattern, ros::Duration du
patterns_.emplace_back(std::make_shared<SnapshotterTopicPattern>(pattern, ops));
return true;
}
catch (std::regex_error& e)
catch (boost::regex_error& e)
{
ROS_ERROR("Invalid topic pattern '%s': %s", pattern.c_str(), e.what());
return false;
Expand Down Expand Up @@ -132,7 +132,7 @@ SnapshotterTopicPattern::SnapshotterTopicPattern(const std::string &pattern,
{
}

const std::regex& SnapshotterTopicPattern::get_pattern() const
const boost::regex& SnapshotterTopicPattern::get_pattern() const
{
return pattern_;
}
Expand All @@ -144,7 +144,7 @@ const SnapshotterTopicOptions& SnapshotterTopicPattern::get_topic_options() cons

bool SnapshotterTopicPattern::matches(const std::string &topic) const
{
return std::regex_match(topic, pattern_);
return boost::regex_match(topic, pattern_);
}

SnapshotterClientOptions::SnapshotterClientOptions() : action_(SnapshotterClientOptions::TRIGGER_WRITE)
Expand Down

0 comments on commit ba5ded1

Please sign in to comment.