diff --git a/modules/common/math/BUILD b/modules/common/math/BUILD index 65b59458b786120a49c07c4ff1e88b0dc0ed4a5e..37817d035752fd304d7f4f777295c31443f629bd 100644 --- a/modules/common/math/BUILD +++ b/modules/common/math/BUILD @@ -49,6 +49,7 @@ cc_library( ], deps = [ "//modules/common:log", + "//modules/common/util:string_util", ], ) @@ -165,6 +166,7 @@ cc_library( deps = [ "//modules/common:log", "//modules/common/math:matrix_operations", + "//modules/common/util:string_util", "@eigen//:eigen", ], ) diff --git a/modules/common/math/aabox2d.cc b/modules/common/math/aabox2d.cc index c70c5320c019fb193ff40d63fcae3f58b881dadd..486c53e3344edac792a59fed99cd99f528f9e6ce 100644 --- a/modules/common/math/aabox2d.cc +++ b/modules/common/math/aabox2d.cc @@ -18,9 +18,9 @@ #include #include -#include #include "modules/common/log.h" +#include "modules/common/util/string_util.h" #include "modules/common/math/math_utils.h" @@ -146,11 +146,9 @@ void AABox2d::MergeFrom(const Vec2d &other_point) { } std::string AABox2d::DebugString() const { - std::ostringstream sout; - sout << "aabox2d ( center = " << center_.DebugString() - << " length = " << length_ << " width = " << width_ << " )"; - sout.flush(); - return sout.str(); + return util::StrCat( + "aabox2d ( center = ", center_.DebugString(), + " length = ", length_, " width = ", width_, " )"); } } // namespace math diff --git a/modules/common/math/box2d.cc b/modules/common/math/box2d.cc index cd59db22396c1db035dff6089b30e759d508e881..87f867f6b127d9e4641657df774ac17bfdbd3c18 100644 --- a/modules/common/math/box2d.cc +++ b/modules/common/math/box2d.cc @@ -18,10 +18,10 @@ #include #include -#include #include #include "modules/common/log.h" +#include "modules/common/util/string_util.h" #include "modules/common/math/math_utils.h" #include "modules/common/math/polygon2d.h" @@ -303,12 +303,10 @@ void Box2d::RotateFromCenter(const double rotate_angle) { void Box2d::Shift(const Vec2d &shift_vec) { center_ += shift_vec; } std::string Box2d::DebugString() const { - std::ostringstream sout; - sout << "box2d ( center = " << center_.DebugString() - << " heading = " << heading_ << " length = " << length_ - << " width = " << width_ << " )"; - sout.flush(); - return sout.str(); + return util::StrCat( + "box2d ( center = ", center_.DebugString(), + " heading = ", heading_, " length = ", length_, + " width = ", width_, " )"); } } // namespace math diff --git a/modules/common/math/kalman_filter.h b/modules/common/math/kalman_filter.h index 068281a7b8f8873bdbd46d36bc84fb0b112087d2..361a3f207d80246bc17d78c8740be8226e9bc8f8 100644 --- a/modules/common/math/kalman_filter.h +++ b/modules/common/math/kalman_filter.h @@ -22,13 +22,13 @@ #ifndef MODULES_COMMON_MATH_KALMAN_FILTER_H_ #define MODULES_COMMON_MATH_KALMAN_FILTER_H_ -#include #include #include "Eigen/Dense" #include "modules/common/log.h" #include "modules/common/math/matrix_operations.h" +#include "modules/common/util/string_util.h" /** * @namespace apollo::common::math @@ -266,15 +266,14 @@ inline void KalmanFilter::Correct( template inline std::string KalmanFilter::DebugString() const { Eigen::IOFormat clean_fmt(4, 0, ", ", " ", "[", "]"); - std::ostringstream strs; - strs << "F = " << F_.format(clean_fmt) << "\n"; - strs << "B = " << B_.format(clean_fmt) << "\n"; - strs << "H = " << H_.format(clean_fmt) << "\n"; - strs << "Q = " << Q_.format(clean_fmt) << "\n"; - strs << "R = " << R_.format(clean_fmt) << "\n"; - strs << "x = " << x_.format(clean_fmt) << "\n"; - strs << "P = " << P_.format(clean_fmt) << "\n"; - return strs.str(); + return util::StrCat( + "F = ", F_.format(clean_fmt), "\n" + "B = ", B_.format(clean_fmt), "\n" + "H = ", H_.format(clean_fmt), "\n" + "Q = ", Q_.format(clean_fmt), "\n" + "R = ", R_.format(clean_fmt), "\n" + "x = ", x_.format(clean_fmt), "\n" + "P = ", P_.format(clean_fmt), "\n"); } } // namespace math diff --git a/modules/common/math/line_segment2d.cc b/modules/common/math/line_segment2d.cc index a1ccaaedb7349bd8fb83dc491916ef165ba9f1fa..10b6b37a4619e410023c2d4279dcfcb3c09ae110 100644 --- a/modules/common/math/line_segment2d.cc +++ b/modules/common/math/line_segment2d.cc @@ -18,10 +18,10 @@ #include #include -#include #include #include "modules/common/log.h" +#include "modules/common/util/string_util.h" #include "modules/common/math/math_utils.h" @@ -214,11 +214,8 @@ double LineSegment2d::GetPerpendicularFoot(const Vec2d &point, } std::string LineSegment2d::DebugString() const { - std::ostringstream sout; - sout << "segment2d ( start = " << start_.DebugString() - << " end = " << end_.DebugString() << " )"; - sout.flush(); - return sout.str(); + return util::StrCat("segment2d ( start = ", start_.DebugString(), + " end = ", end_.DebugString(), " )"); } } // namespace math diff --git a/modules/common/math/vec2d.cc b/modules/common/math/vec2d.cc index 9f71b8633661f1b182a10ba0c96fcac94b47e20a..f0fad1d8dde61e04bd8ff834dc5e07efbbefc2bc 100644 --- a/modules/common/math/vec2d.cc +++ b/modules/common/math/vec2d.cc @@ -17,8 +17,9 @@ #include "modules/common/math/vec2d.h" #include -#include + #include "modules/common/log.h" +#include "modules/common/util/string_util.h" namespace apollo { namespace common { @@ -110,10 +111,7 @@ bool Vec2d::operator==(const Vec2d &other) const { Vec2d operator*(const double ratio, const Vec2d &vec) { return vec * ratio; } std::string Vec2d::DebugString() const { - std::ostringstream sout; - sout << "vec2d ( x = " << x_ << " y = " << y_ << " )"; - sout.flush(); - return sout.str(); + return util::StrCat("vec2d ( x = ", x_, " y = ", y_, " )"); } } // namespace math diff --git a/modules/common/util/BUILD b/modules/common/util/BUILD index bb27685879e9ab801a0ab23b0cd71e34eefd50e9..6ca71e284db2ef136e29bb4cfc07401c59cc1663 100644 --- a/modules/common/util/BUILD +++ b/modules/common/util/BUILD @@ -26,14 +26,24 @@ cc_library( hdrs = ["lru_cache.h"], ) +cc_library( + name = "string_util", + srcs = [ + "string_util.cc", + ], + hdrs = [ + "string_util.h", + ], +) + cc_test( - name = "util_test", + name = "string_util_test", size = "small", srcs = [ - "util_test.cc", + "string_util_test.cc", ], deps = [ - ":util", + ":string_util", "@gtest//:main", ], ) diff --git a/modules/common/util/file.h b/modules/common/util/file.h index bf34b8a2aa3511f54cd704a1103a87556f91e59a..3de2433d84a5d5ca7cc1f5ff96742562cb2e41e0 100644 --- a/modules/common/util/file.h +++ b/modules/common/util/file.h @@ -32,7 +32,7 @@ #include "google/protobuf/io/zero_copy_stream_impl.h" #include "google/protobuf/text_format.h" #include "modules/common/log.h" -#include "modules/common/util/util.h" +#include "modules/common/util/string_util.h" /** * @namespace apollo::common::util diff --git a/modules/common/util/string_util.cc b/modules/common/util/string_util.cc new file mode 100644 index 0000000000000000000000000000000000000000..151e23965c588c8e936484d598a5dfef89f2928b --- /dev/null +++ b/modules/common/util/string_util.cc @@ -0,0 +1,30 @@ +/****************************************************************************** + * Copyright 2017 The Apollo Authors. All Rights Reserved. + * + * 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 "modules/common/util/string_util.h" + +namespace apollo { +namespace common { +namespace util { + +bool EndWith(const std::string& original, const std::string& pattern) { + return original.length() >= pattern.length() && + original.substr(original.length() - pattern.length()) == pattern; +} + +} // namespace util +} // namespace common +} // namespace apollo diff --git a/modules/common/util/string_util.h b/modules/common/util/string_util.h new file mode 100644 index 0000000000000000000000000000000000000000..a3ddc18fc688fab3d199482808011a11af660737 --- /dev/null +++ b/modules/common/util/string_util.h @@ -0,0 +1,62 @@ +/****************************************************************************** + * Copyright 2017 The Apollo Authors. All Rights Reserved. + * + * 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. + *****************************************************************************/ + +/** + * @file + * @brief Some string util functions. + */ + +#ifndef MODULES_COMMON_STRING_UTIL_H_ +#define MODULES_COMMON_STRING_UTIL_H_ + +#include +#include + +/** + * @namespace apollo::common::util + * @brief apollo::common::util + */ +namespace apollo { +namespace common { +namespace util { + +/** + * @brief Check if a string ends with a pattern. + * @param original The original string. To see if it ends with some + * specified pattern. + * @param pattern The target pattern. To see if the original string ends + * with it. + * @return Whether the original string ends with the specified pattern. + */ +bool EndWith(const std::string& original, const std::string& pattern); + +/** + * @brief Concat parameters to a string, e.g.: StrCat("age = ", 32) + * @return String of concated parameters. + */ +template +std::string StrCat(const T& ...args) { + std::ostringstream oss; + // Expand args and pass to oss. + std::initializer_list{(oss << args, ' ') ... }; + return oss.str(); +} + +} // namespace util +} // namespace common +} // namespace apollo + +#endif // MODULES_COMMON_STRING_UTIL_H_ diff --git a/modules/common/util/util_test.cc b/modules/common/util/string_util_test.cc similarity index 96% rename from modules/common/util/util_test.cc rename to modules/common/util/string_util_test.cc index 453b47c810508faf5d34fe0209746acfc6597bb2..298dc7957fd9a90984bae4db2ac57cbdf6c82abc 100644 --- a/modules/common/util/util_test.cc +++ b/modules/common/util/string_util_test.cc @@ -14,7 +14,8 @@ * limitations under the License. *****************************************************************************/ -#include "modules/common/util/util.h" +#include "modules/common/util/string_util.h" + #include "gtest/gtest.h" namespace apollo { diff --git a/modules/common/util/util.cc b/modules/common/util/util.cc index b9408917f7ade23dd94dd4cd22c9598e96927efd..a5a75c42408124d20028547b5bae8bbc9f5fb3e6 100644 --- a/modules/common/util/util.cc +++ b/modules/common/util/util.cc @@ -24,11 +24,6 @@ namespace util { using SLPoint = apollo::common::SLPoint; -bool EndWith(const std::string& original, const std::string& pattern) { - return original.length() >= pattern.length() && - original.substr(original.length() - pattern.length()) == pattern; -} - SLPoint MakeSLPoint(const double s, const double l) { SLPoint sl; sl.set_s(s); diff --git a/modules/common/util/util.h b/modules/common/util/util.h index 8dd855996936f5e3f1633c0aa0b99f916a92cb84..8d330e2a9b6d346ad62185b969c4169db53e3be7 100644 --- a/modules/common/util/util.h +++ b/modules/common/util/util.h @@ -23,8 +23,6 @@ #define MODULES_COMMON_UTIL_H_ #include -#include -#include #include #include "modules/common/proto/path_point.pb.h" @@ -37,28 +35,6 @@ namespace apollo { namespace common { namespace util { -/** - * @brief Check if a string ends with a pattern. - * @param original The original string. To see if it ends with some - * specified pattern. - * @param pattern The target pattern. To see if the original string ends - * with it. - * @return Whether the original string ends with the specified pattern. - */ -bool EndWith(const std::string& original, const std::string& pattern); - -/** - * @brief Concat parameters to a string, e.g.: StrCat("age = ", 32) - * @return String of concated parameters. - */ -template -std::string StrCat(const T& ...args) { - std::ostringstream oss; - // Expand args and pass to oss. - std::initializer_list{(oss << args, ' ') ... }; - return oss.str(); -} - /** * @brief create a SL point * @param s the s value diff --git a/modules/control/controller/lat_controller.cc b/modules/control/controller/lat_controller.cc index e50d30b1905f6639ade2cd7f62df5b5beb7f63b8..cabe79b67fb111ad81e3502016c239bd2d973746 100644 --- a/modules/control/controller/lat_controller.cc +++ b/modules/control/controller/lat_controller.cc @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -30,6 +29,7 @@ #include "modules/common/math/linear_quadratic_regulator.h" #include "modules/common/math/math_utils.h" #include "modules/common/time/time.h" +#include "modules/common/util/string_util.h" #include "modules/control/common/control_gflags.h" namespace apollo { @@ -119,24 +119,27 @@ bool LatController::LoadControlConf(const ControlConf *control_conf) { void LatController::ProcessLogs(const SimpleLateralDebug *debug, const canbus::Chassis *chassis) { - std::stringstream log_stream; - log_stream << debug->lateral_error() << "," << debug->ref_heading() << "," - << VehicleState::instance()->heading() << "," - << debug->heading_error() << "," << debug->heading_error_rate() - << "," << debug->lateral_error_rate() << "," << debug->curvature() - << "," << debug->steer_angle() << "," - << debug->steer_angle_feedforward() << "," - << debug->steer_angle_lateral_contribution() << "," - << debug->steer_angle_lateral_rate_contribution() << "," - << debug->steer_angle_heading_contribution() << "," - << debug->steer_angle_heading_rate_contribution() << "," - << debug->steer_angle_feedback() << "," - << chassis->steering_percentage() << "," - << VehicleState::instance()->linear_velocity(); + const std::string log_str = apollo::common::util::StrCat( + debug->lateral_error(), ",", + debug->ref_heading(), ",", + VehicleState::instance()->heading(), ",", + debug->heading_error(), ",", + debug->heading_error_rate(), ",", + debug->lateral_error_rate(), ",", + debug->curvature(), ",", + debug->steer_angle(), ",", + debug->steer_angle_feedforward(), ",", + debug->steer_angle_lateral_contribution(), ",", + debug->steer_angle_lateral_rate_contribution(), ",", + debug->steer_angle_heading_contribution(), ",", + debug->steer_angle_heading_rate_contribution(), ",", + debug->steer_angle_feedback(), ",", + chassis->steering_percentage(), ",", + VehicleState::instance()->linear_velocity()); if (FLAGS_enable_csv_debug) { - steer_log_file_ << log_stream.str() << std::endl; + steer_log_file_ << log_str << std::endl; } - AINFO << "Steer_Control_Detail: " << log_stream.str(); + AINFO << "Steer_Control_Detail: " << log_str; } void LatController::LogInitParameters() { diff --git a/modules/dreamview/backend/websocket/BUILD b/modules/dreamview/backend/websocket/BUILD index 060627f488da72b8d47a17b06cce6df7001682dc..503058229a04a55632738a956f1d05c00f9675d4 100644 --- a/modules/dreamview/backend/websocket/BUILD +++ b/modules/dreamview/backend/websocket/BUILD @@ -12,6 +12,7 @@ cc_library( ], deps = [ "//modules/common:log", + "//modules/common/util:string_util", "//third_party/json", "@civetweb//:civetweb++", ], diff --git a/modules/dreamview/backend/websocket/websocket.cc b/modules/dreamview/backend/websocket/websocket.cc index dfc45d1629a2ad8f8a6fbd543a2a6289278b2721..f476468b886e53c31d067ed240878d8afcbacbfa 100644 --- a/modules/dreamview/backend/websocket/websocket.cc +++ b/modules/dreamview/backend/websocket/websocket.cc @@ -15,10 +15,10 @@ limitations under the License. #include "modules/dreamview/backend/websocket/websocket.h" -#include #include #include "modules/common/log.h" +#include "modules/common/util/string_util.h" namespace apollo { namespace dreamview { @@ -74,13 +74,10 @@ bool WebSocketHandler::SendData(const std::string &data, Connection *conn) { } else if (ret < 0) { msg = "Send Error"; } else { - std::ostringstream os; - os << "Expect to send " << data.size() << " bytes. But sent " << ret - << " bytes"; - msg = os.str(); + msg = apollo::common::util::StrCat( + "Expect to send ", data.size(), " bytes. But sent ", ret, " bytes"); } - AWARN << "Failed to send data via websocket connection. Reason: " - << msg; + AWARN << "Failed to send data via websocket connection. Reason: " << msg; return false; } diff --git a/modules/map/pnc_map/path.cc b/modules/map/pnc_map/path.cc index 6c118920af3e8198c5a9ea5e75b60d1e934b8a14..3f547134bd00690bd2826579db30394dfe1bfafc 100644 --- a/modules/map/pnc_map/path.cc +++ b/modules/map/pnc_map/path.cc @@ -25,6 +25,7 @@ #include "modules/common/math/math_utils.h" #include "modules/common/math/polygon2d.h" #include "modules/common/math/vec2d.h" +#include "modules/common/util/string_util.h" namespace apollo { namespace hdmap { @@ -60,21 +61,17 @@ std::string LaneWaypoint::debug_string() const { if (lane == nullptr) { return "(lane is null)"; } - std::ostringstream sout; - sout << "id = " << lane->id().id() << " s = " << s; - sout.flush(); - return sout.str(); + return apollo::common::util::StrCat("id = ", lane->id().id(), " s = ", s); } std::string LaneSegment::debug_string() const { if (lane == nullptr) { return "(lane is null)"; } - std::ostringstream sout; - sout << "id = " << lane->id().id() << " start_s = " << start_s - << " end_s = " << end_s; - sout.flush(); - return sout.str(); + return apollo::common::util::StrCat( + "id = ", lane->id().id(), " " + "start_s = ", start_s, " " + "end_s = ", end_s); } std::string MapPathPoint::debug_string() const { @@ -121,10 +118,7 @@ std::string Path::debug_string() const { } std::string PathOverlap::debug_string() const { - std::ostringstream sout; - sout << object_id << " " << start_s << " " << end_s; - sout.flush(); - return sout.str(); + return apollo::common::util::StrCat(object_id, " ", start_s, " ", end_s); } Path::Path(std::vector path_points) diff --git a/modules/monitor/hwmonitor/hw/esdcan/esdcan_checker.cc b/modules/monitor/hwmonitor/hw/esdcan/esdcan_checker.cc index a1a7e1057c275287bbe13ab831c978ee364cde69..f52303d78ca0626c02baa7b6cf34ebedaf488418 100644 --- a/modules/monitor/hwmonitor/hw/esdcan/esdcan_checker.cc +++ b/modules/monitor/hwmonitor/hw/esdcan/esdcan_checker.cc @@ -16,10 +16,10 @@ #include "modules/monitor/hwmonitor/hw/esdcan/esdcan_checker.h" -#include #include #include +#include "modules/common/util/string_util.h" #include "modules/monitor/hwmonitor/hw/esdcan/esdcan_err_str.h" #include "modules/monitor/hwmonitor/hw/hw_log_module.h" @@ -30,9 +30,7 @@ namespace hw { const char EsdCanChecker::ESD_CAN_NAME[] = "ESD_CAN"; EsdCanChecker::EsdCanChecker(int id) : can_id_(id) { - std::ostringstream os; - os << ESD_CAN_NAME << "-" << id; - name_ = os.str(); + name_ = apollo::common::util::StrCat(ESD_CAN_NAME, "-", id); } hw::Status EsdCanChecker::esdcan_result_to_hw_status(NTCAN_RESULT ntstatus) { diff --git a/modules/perception/obstacle/base/BUILD b/modules/perception/obstacle/base/BUILD index d3a38acafb5ad73fc166aded8825c2941eed9191..7b21366b87a86ff56084cb6682f71fafa1c08460 100644 --- a/modules/perception/obstacle/base/BUILD +++ b/modules/perception/obstacle/base/BUILD @@ -11,6 +11,7 @@ cc_library( "//modules/perception/common:perception_common", "//modules/perception/proto:perception_proto", "//modules/common:common", + "//modules/common/util:string_util", "@eigen//:eigen", ], ) diff --git a/modules/perception/obstacle/base/object.cc b/modules/perception/obstacle/base/object.cc index fde41aa3ad95b04afddd707f31f402f3e993b0e9..2ce50fb48fb86cdb6d40aae1c02e744afefc5808 100644 --- a/modules/perception/obstacle/base/object.cc +++ b/modules/perception/obstacle/base/object.cc @@ -15,15 +15,13 @@ *****************************************************************************/ #include "modules/perception/obstacle/base/object.h" -#include - #include "modules/common/macro.h" #include "modules/common/log.h" +#include "modules/common/util/string_util.h" namespace apollo { namespace perception { -using std::ostringstream; using std::string; using std::vector; using Eigen::Vector3d; @@ -95,18 +93,21 @@ void Object::clone(const Object& rhs) { } string Object::to_string() const { - ostringstream oss; - oss << "Object[id: " << id << ", track_id: " << track_id - << ", cloud_size: " << cloud->size() << ", direction: " - << direction.transpose() << ", center: " << center.transpose() - << " velocity: " << velocity.transpose() << ", width: " << width - << ", length: " << length << ", height: " << height - << ", polygon_size: " << polygon.size() - << ", type: " << type << ", is_background: " << is_background << "]"; - // << ", tracking_time: " << GLOG_TIMESTAMP(tracking_time) - // << ", latest_tracked_time: " << GLOG_TIMESTAMP(latest_tracked_time) << "]"; - - return oss.str(); + return apollo::common::util::StrCat( + "Object[id: ", id, ", " + "track_id: ", track_id, ", " + "cloud_size: ", cloud->size(), ", " + "direction: ", direction.transpose(), ", " + "center: ", center.transpose(), ", " + "velocity: ", velocity.transpose(), ", " + "width: ", width, ", " + "length: ", length, ", " + "height: ", height, ", " + "polygon_size: ", polygon.size(), ", " + "type: ", type, ", " + "is_background: ", is_background, "]"); + // "tracking_time: ", GLOG_TIMESTAMP(tracking_time) + // "latest_tracked_time: ", GLOG_TIMESTAMP(latest_tracked_time) } bool Object::serialize(PerceptionObstacle* pb_obj) const { diff --git a/modules/planning/common/speed/st_point.cc b/modules/planning/common/speed/st_point.cc index ded98f548d927b5e5430afb62690518d7f1a6e95..20972cd8a4b87521630c7f0ed52640284786fda1 100644 --- a/modules/planning/common/speed/st_point.cc +++ b/modules/planning/common/speed/st_point.cc @@ -21,7 +21,8 @@ #include "modules/planning/common/speed/st_point.h" #include -#include + +#include "modules/common/util/string_util.h" namespace apollo { namespace planning { @@ -37,10 +38,9 @@ void STPoint::set_s(const double s) { return set_y(s); } void STPoint::set_t(const double t) { return set_x(t); } std::string STPoint::DebugString() const { - std::ostringstream sout; - sout << "{ \"s\" : " << std::setprecision(6) << s() - << ", \"t\" : " << std::setprecision(6) << t() << " }"; - return sout.str(); + return apollo::common::util::StrCat( + "{ \"s\" : ", std::setprecision(6), s(), ", " + "\"t\" : ", std::setprecision(6), t(), " }"); } } // namespace planning diff --git a/modules/planning/reference_line/reference_point.cc b/modules/planning/reference_line/reference_point.cc index 74f510699540ad1192454bdf3b74ddcaf9b7ae6c..c5614a948cfcc61a6fcd69a0ca763520268b21c0 100644 --- a/modules/planning/reference_line/reference_point.cc +++ b/modules/planning/reference_line/reference_point.cc @@ -21,6 +21,7 @@ #include #include +#include "modules/common/util/string_util.h" #include "modules/planning/reference_line/reference_point.h" namespace apollo { @@ -77,12 +78,14 @@ double ReferencePoint::lower_bound() const { return lower_bound_; } double ReferencePoint::upper_bound() const { return upper_bound_; } const std::string ReferencePoint::DebugString() const { - std::stringstream ss; - ss << "{x: " << std::fixed << x() << ", y: " << y() << ", theta: " << heading() - << ", kappa: " << kappa() << ", dkappa: " << dkappa() - << ", upper_bound: " << upper_bound() << ", lower_bound: " << lower_bound() - << "}"; - return ss.str(); + return apollo::common::util::StrCat( + "{x: ", std::fixed, x(), ", " + "y: ", y(), ", " + "theta: ", heading(), ", " + "kappa: ", kappa(), ", " + "dkappa: ", dkappa(), ", " + "upper_bound: ", upper_bound(), ", " + "lower_bound: ", lower_bound(), "}"); } } // namespace planning