#include "labels.hh"
#include "tlib.hh"
#include "boxes.hh"
#include "signals.hh"
#include "compatibility.hh"
Go to the source code of this file.
Functions | |
Tree | pathRoot () |
bool | isPathRoot (Tree t) |
Tree | pathParent () |
bool | isPathParent (Tree t) |
Tree | pathCurrent () |
bool | isPathCurrent (Tree t) |
static Tree | encodeName (char g, const string &name) |
analyze name for "H:name" | "V:name" etc | |
static Tree | label2path (const char *label) |
Analyzes a label and converts it as a path. | |
static Tree | concatPath (Tree relpath, Tree abspath) |
Concatenate the relative path to the absolute path Note that the relpath is top-down while the abspath is bottom-up. | |
static Tree | normalizeLabel (Tree label, Tree path) |
Tree | normalizePath (Tree path) |
Variables | |
Sym | PATHROOT = symbol ("/") |
Grammar for labels with pathnames ----------------------------------- <label> = <name> | <path> <name> <name> = [^/]+ <path> = <apath> | <rpath> <apath> = '/' | '/' <rpath> <rpath> = (<gname> '/')+ <gname> = ".." | "." | <gtype> <name> <gtype> = "h:" | "H:" | "v:" | V:" | "t:" | "T:". | |
Sym | PATHPARENT = symbol ("..") |
Sym | PATHCURRENT = symbol (".") |
Concatenate the relative path to the absolute path Note that the relpath is top-down while the abspath is bottom-up.
Definition at line 95 of file labels.cpp.
References cons(), hd(), isList(), isNil(), isPathCurrent(), isPathParent(), isPathRoot(), nil, and tl().
Referenced by normalizeLabel().
00096 { 00097 if (isList(relpath)) { 00098 Tree head = hd(relpath); 00099 if (isPathRoot(head)) { 00100 return concatPath(tl(relpath), nil); 00101 } else if (isPathParent(head)) { 00102 if (!isList(abspath)) { 00103 //cerr << "abspath : " << *abspath << endl; 00104 return concatPath(tl(relpath), hd(relpath)); 00105 } else { 00106 return concatPath(tl(relpath), tl(abspath)); 00107 } 00108 } else if (isPathCurrent(head)) { 00109 return concatPath(tl(relpath), abspath); 00110 } else { 00111 return concatPath(tl(relpath), cons(head,abspath)); 00112 } 00113 } else { 00114 assert(isNil(relpath)); 00115 return abspath; 00116 } 00117 }
static Tree encodeName | ( | char | g, | |
const string & | name | |||
) | [static] |
analyze name for "H:name" | "V:name" etc
Definition at line 37 of file labels.cpp.
References cons(), and tree().
Referenced by label2path().
00038 { 00039 switch (g) { 00040 case 'v': 00041 case 'V': return cons(tree(0), tree(name)); 00042 00043 case 'h': 00044 case 'H': return cons(tree(1), tree(name)); 00045 00046 case 't': 00047 case 'T': return cons(tree(2), tree(name)); 00048 00049 default : return cons(tree(0), tree(name)); 00050 } 00051 }
bool isPathCurrent | ( | Tree | t | ) |
Definition at line 29 of file labels.cpp.
References isTree().
Referenced by concatPath().
00029 { return isTree(t, PATHCURRENT); }
bool isPathParent | ( | Tree | t | ) |
Definition at line 25 of file labels.cpp.
References isTree().
Referenced by concatPath().
00025 { return isTree(t, PATHPARENT); }
bool isPathRoot | ( | Tree | t | ) |
Definition at line 21 of file labels.cpp.
References isTree().
Referenced by concatPath().
static Tree label2path | ( | const char * | label | ) | [static] |
Analyzes a label and converts it as a path.
Definition at line 58 of file labels.cpp.
References cons(), encodeName(), nil, pathParent(), pathRoot(), and tree().
Referenced by normalizeLabel().
00059 { 00060 if (label[0] == 0) { 00061 return cons(tree(""), nil); 00062 00063 } else if (label[0] == '/') { 00064 return cons(pathRoot(), label2path(&label[1])); 00065 00066 } else if ((label[0] == '.') && (label[1] == '/')) { 00067 return label2path(&label[2]); 00068 00069 } else if ((label[0] == '.') && (label[1] == '.') && (label[2] == '/')) { 00070 return cons(pathParent(), label2path(&label[3])); 00071 00072 } else if (label[1] == ':') { 00073 char g = label[0]; 00074 string s; 00075 int i = 2; 00076 while ((label[i] != 0) && (label[i] != '/')) { 00077 s.push_back(label[i]); 00078 i++; 00079 } 00080 if (label[i] == '/') i++; 00081 return cons(encodeName(g,s), label2path(&label[i])); 00082 00083 } else { 00084 return cons(tree(label),nil); 00085 } 00086 }
Definition at line 120 of file labels.cpp.
References concatPath(), cons(), isList(), isSym(), label2path(), name(), and CTree::node().
Referenced by normalizePath().
00121 { 00122 // we suppose label = "../label" ou "name/label" ou "name" 00123 //cout << "Normalize Label " << *label << " with path " << *path << endl; 00124 if (isList(label)) { 00125 return cons(label, path); 00126 } else { 00127 Sym s; 00128 assert (isSym(label->node(),&s)); 00129 return concatPath(label2path(name(s)),path); 00130 } 00131 }
Definition at line 133 of file labels.cpp.
References hd(), isNil(), normalizeLabel(), normalizePath(), and tl().
Referenced by normalizePath(), and propagate().
00134 { 00135 //cout << "Normalize Path [[" << *path << "]]" << endl; 00136 Tree npath; 00137 if (isNil(path)) { 00138 npath = path; 00139 } else { 00140 npath = normalizeLabel(hd(path), normalizePath(tl(path))); 00141 } 00142 //cout << " -> [[" << *npath << "]]" << endl; 00143 return npath; 00144 }
Tree pathCurrent | ( | ) |
Definition at line 28 of file labels.cpp.
References tree().
00028 { return tree(PATHCURRENT); }
Tree pathParent | ( | ) |
Definition at line 24 of file labels.cpp.
References tree().
Referenced by label2path().
00024 { return tree(PATHPARENT); }
Tree pathRoot | ( | ) |
Definition at line 20 of file labels.cpp.
References tree().
Referenced by label2path().
Sym PATHCURRENT = symbol (".") |
Definition at line 27 of file labels.cpp.
Sym PATHPARENT = symbol ("..") |
Definition at line 23 of file labels.cpp.
Grammar for labels with pathnames ----------------------------------- <label> = <name> | <path> <name> <name> = [^/]+ <path> = <apath> | <rpath> <apath> = '/' | '/' <rpath> <rpath> = (<gname> '/')+ <gname> = ".." | "." | <gtype> <name> <gtype> = "h:" | "H:" | "v:" | V:" | "t:" | "T:".
Definition at line 19 of file labels.cpp.