USRP Hardware Driver and USRP Manual  Version: 4.4.0.HEAD-0-g5fac246b
UHD and USRP Manual
string.hpp
Go to the documentation of this file.
1 //
2 // Copyright 2022 Ettus Research, a National Instruments Brand
3 //
4 // SPDX-License-Identifier: GPL-3.0-or-later
5 //
6 
7 #pragma once
8 
9 #include <uhd/config.hpp>
10 #include <uhd/exception.hpp>
11 
12 namespace uhd { namespace string {
13 
24 UHD_API std::pair<std::string, std::string> split(
25  const std::string& str, const std::string& delim)
26 {
27  auto delim_pos = str.find(delim);
28  if (delim_pos == std::string::npos) {
29  throw uhd::runtime_error(
30  "Delimiter \"" + delim + "\" not found in string \"" + str + "\"");
31  }
32  return std::make_pair(str.substr(0, delim_pos), str.substr(delim_pos + 1));
33 }
34 
35 }} // namespace uhd::string
config.hpp
UHD_API
#define UHD_API
Definition: config.h:87
uhd
Definition: build_info.hpp:12
uhd::runtime_error
Definition: exception.hpp:131
exception.hpp
uhd::string::split
UHD_API std::pair< std::string, std::string > split(const std::string &str, const std::string &delim)
Definition: string.hpp:24