USRP Hardware Driver and USRP Manual  Version: 4.7.0.0
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
Definition: exception.hpp:131
Definition: build_info.hpp:12
#define UHD_API
Definition: config.h:87
UHD_API std::pair< std::string, std::string > split(const std::string &str, const std::string &delim)
Definition: string.hpp:24