MUQ  0.4.3
PathTools.cpp
Go to the documentation of this file.
2 
3 #include <iostream>
4 #include <assert.h>
5 
6 std::string muq::Utilities::GetParentPath(std::string const& base)
7 {
8  int lastInd = base.length()-1;
9  if(base[lastInd]=='/')
10  lastInd--;
11 
12  int pos = base.find_last_of('/',lastInd);
13 
14  return base.substr(0,pos);
15 }
16 
17 
18 
19 std::pair<std::string, std::string> muq::Utilities::SplitString(std::string const& path)
20 {
21  assert(path.length()>1);
22  int i;
23  for(i=1; i<path.length(); ++i)
24  {
25  if(path[i]=='/')
26  break;
27  }
28  std::string nextNode = path.substr(0,i);
29  std::string remainingPath = path.substr(i,path.length()-i);
30 
31  return make_pair(nextNode,remainingPath);
32 }
std::pair< std::string, std::string > SplitString(std::string const &path)
Splits a string on the first forward slash.
Definition: PathTools.cpp:19
std::string GetParentPath(std::string const &base)
Definition: PathTools.cpp:6