~choreonoid/choreonoid/debian

« back to all changes in this revision

Viewing changes to src/Base/ItemPath.cpp

  • Committer: Thomas Moulard
  • Date: 2012-10-23 12:43:24 UTC
  • Revision ID: git-v1:351cf736ad49bc7a9a7b9767dee760a013517a5d
Tags: upstream/1.1.0
ImportedĀ UpstreamĀ versionĀ 1.1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
   @author Shin'ichiro Nakaoka
 
3
*/
 
4
 
 
5
#include "ItemPath.h"
 
6
#include "Item.h"
 
7
#include "RootItem.h"
 
8
 
 
9
using namespace std;
 
10
using namespace boost;
 
11
using namespace cnoid;
 
12
 
 
13
 
 
14
ItemPath::ItemPath(const std::string& path) :
 
15
    path(path)
 
16
{
 
17
    Tokenizer pathElements(path, Separator("\\", "/", ""));
 
18
 
 
19
    pathBegin = pathElements.begin();
 
20
    pathEnd = pathElements.end();
 
21
 
 
22
    if(pathBegin != pathEnd && (*pathBegin).empty()){
 
23
        pathBegin++;
 
24
        isAbsolute_ = true;
 
25
    } else {
 
26
        isAbsolute_ = false;
 
27
    }
 
28
  
 
29
    pathLeaf = pathBegin;
 
30
 
 
31
    for(iterator it = pathBegin; it != pathEnd; ++it){
 
32
        pathLeaf = it;
 
33
    }
 
34
}
 
35
 
 
36
 
 
37
std::string ItemPath::folder()
 
38
{
 
39
    std::string path;
 
40
    iterator it = pathBegin;
 
41
    while(true){
 
42
        path.append(*it++);
 
43
        if(it == pathLeaf){
 
44
            break;
 
45
        }
 
46
        path.append("/");
 
47
    }
 
48
    return path;
 
49
}