irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

irods_string_tokenize.cpp
Go to the documentation of this file.
1 // =-=-=-=-=-=-=-
2 // stl includes
3 #include <string>
4 #include <vector>
5 
6 namespace irods {
7 // =-=-=-=-=-=-=-
8 // helper fcn to break up string into tokens for easy handling
10  const std::string& _str,
11  const std::string& _delim,
12  std::vector< std::string >& _tok ) {
13 
14  // =-=-=-=-=-=-=-
15  // Skip delimiters at beginning.
16  std::string::size_type last_pos = _str.find_first_not_of( _delim, 0 );
17 
18  // =-=-=-=-=-=-=-
19  // Find first "non-delimiter".
20  std::string::size_type pos = _str.find_first_of( _delim, last_pos );
21 
22  // =-=-=-=-=-=-=-
23  // iterate over string
24  while ( std::string::npos != pos || std::string::npos != last_pos ) {
25  // =-=-=-=-=-=-=-
26  // Found a token, add it to the vector.
27  std::string tt = _str.substr( last_pos, pos - last_pos );
28 
29  if ( tt[0] == ' ' ) {
30  tt = tt.substr( 1 );
31  }
32 
33  _tok.push_back( tt );
34 
35  // =-=-=-=-=-=-=-
36  // Skip delimiters. Note the "not_of"
37  last_pos = _str.find_first_not_of( _delim, pos );
38 
39  // =-=-=-=-=-=-=-
40  // Find next "non-delimiter"
41  pos = _str.find_first_of( _delim, last_pos );
42 
43  } // while
44 
45  } // string_tokenize
46 
47 } // namespace irods
irods::string_tokenize
void string_tokenize(const std::string &, const std::string &, std::vector< std::string > &)
Definition: irods_string_tokenize.cpp:9
irods
Definition: apiHandler.hpp:35