MCPcopy Create free account
hub / github.com/OpenHD/OpenHD / string_in_between

Method string_in_between

OpenHD/ohd_common/src/openhd_util.cpp:114–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114std::string OHDUtil::string_in_between(const std::string& start,
115 const std::string& end,
116 const std::string& value, bool debug) {
117 const std::regex base_regex(start + "(.*)" + end);
118 std::smatch base_match;
119 std::string matched;
120 if (std::regex_search(value, base_match, base_regex)) {
121 // The first sub_match is the whole string; the next
122 // sub_match is the first parenthesized expression.
123 if (base_match.size() == 2) {
124 matched = base_match[1].str();
125 }
126 }
127 if (debug) {
128 openhd::log::get_default()->debug("Given:[{}] Result:[{}]", value, matched);
129 }
130 return matched;
131}
132std::optional<int> OHDUtil::string_to_int(const std::string& s) {
133 try {
134 auto ret = std::stoi(s);

Callers

nothing calls this directly

Calls 2

sizeMethod · 0.80
debugMethod · 0.80

Tested by

no test coverage detected