split.h
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2020 Intel Corporation. All Rights Reserved.
3 
4 #pragma once
5 
6 #include <string>
7 #include <vector>
8 #include <sstream>
9 
10 namespace utilities {
11 namespace string {
12 
13 
14 // Split input text to vector of strings according to input delimiter
15 // - Input: string to be split
16 // - delimiter
17 // - Output: a vector of strings
18 // Example:
19 // Input:
20 // Text: This is the first line\nThis is the second line\nThis is the last line
21 // Delimiter : '\n'
22 // Output:
23 // [0] this is the first line
24 // [1] this is the second line
25 // [2] this is the last line
26 inline std::vector< std::string > split( const std::string & str , char delimiter)
27 {
28  auto result = std::vector< std::string >{};
29  auto ss = std::stringstream{ str };
30 
31  for( std::string line; std::getline( ss, line, delimiter); )
32  result.push_back( line );
33 
34  return result;
35 }
36 
37 } // namespace string
38 } // namespace utilities
GLsizei const GLchar *const * string
std::vector< std::string > split(const std::string &str, char delimiter)
Definition: split.h:26
GLuint64EXT * result
Definition: glext.h:10921


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:41