Medical Imaging Interaction Toolkit  2018.4.99-389bf124
Medical Imaging Interaction Toolkit
mitkSplitParameterToVector.cpp
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
14 
15 #include <sstream>
16 
17 std::vector<double> mitk::cl::splitDouble(std::string str, char delimiter) {
18  std::vector<double> internal;
19  std::stringstream ss(str); // Turn the string into a stream.
20  std::string tok;
21  double val;
22  while (std::getline(ss, tok, delimiter)) {
23  std::stringstream s2(tok);
24  s2 >> val;
25  internal.push_back(val);
26  }
27 
28  return internal;
29 }
30 
31 std::vector<int> mitk::cl::splitInt(std::string str, char delimiter) {
32  std::vector<int> internal;
33  std::stringstream ss(str); // Turn the string into a stream.
34  std::string tok;
35  int val;
36  while (std::getline(ss, tok, delimiter)) {
37  std::stringstream s2(tok);
38  s2 >> val;
39  internal.push_back(val);
40  }
41 
42  return internal;
43 }
44 
45 std::vector<std::string> mitk::cl::splitString(std::string str, char delimiter) {
46  std::vector<std::string> internal;
47  std::stringstream ss(str); // Turn the string into a stream.
48  std::string tok;
49  std::string val;
50  while (std::getline(ss, tok, delimiter)) {
51  std::stringstream s2(tok);
52  s2 >> val;
53  internal.push_back(val);
54  }
55 
56  return internal;
57 }
std::vector< int > MITKCLUTILITIES_EXPORT splitInt(std::string str, char delimiter)
std::vector< double > MITKCLUTILITIES_EXPORT splitDouble(std::string str, char delimiter)
std::vector< std::string > MITKCLUTILITIES_EXPORT splitString(std::string str, char delimiter)