35 std::string pad (2*level,
' ');
38 for (; i != i_end; ++i) {
39 output << pad << i->first;
40 if (i->second->isDirectory()) {
42 dodump(output, level+1,static_cast<senf::console::DirectoryNode&>(*i->second));
44 else if (i->second->isLink())
45 output <<
"@ -> " << i->second->followLink().path() <<
'\n';
60 while (child != from.
children().end()) {
61 std::string
name (child->first);
76 path = node->name() +
"/" +
path;
77 node = node->parent();
79 return path.empty() ?
"/" :
path;
87 while (node && node != root.
thisptr()) {
89 path = node->name() +
"/" +
path;
92 node = node->parent();
94 if (path.empty() || path[0] !=
'/')
103 while (node->parent())
104 node = node->parent();
112 while (node && node != parent.
thisptr())
113 node = node->parent();
114 return node.get() != 0;
121 myParent->add( newName,
unlink());
127 prefix_ void senf::console::LinkNode::v_help(std::ostream & os)
133 prefix_ std::string senf::console::LinkNode::v_shorthelp()
136 return follow().shorthelp();
144 ChildMap::iterator i (children_.begin());
145 ChildMap::iterator
const i_end (children_.end());
146 for (; i != i_end; ++i)
147 i->second->parent_ = 0;
154 return remove(
name);
162 ChildMap::iterator i (children_.find(name));
163 if (i == children_.end())
174 BOOST_ASSERT( ! node->parent() );
175 if (node->name().empty()) {
176 node->name(
"unnamed");
179 if (children_.find(node->name()) != children_.end()) {
184 newName = node->name() +
"-" + boost::lexical_cast<std::string>(suffix);
185 }
while (children_.find(newName) != children_.end());
190 children_.insert(std::make_pair(node->name(),node));
191 node->parent_ =
this;
198 ChildMap::const_iterator i (children_.find(name));
199 if (i == children_.end())
204 prefix_ void senf::console::DirectoryNode::v_help(std::ostream & output)
207 output << doc_ <<
"\n";
210 prefix_ std::string senf::console::DirectoryNode::v_shorthelp()
213 if (! shortdoc_.empty())
215 return doc_.substr(0,doc_.find(
'\n'));
221 prefix_ void senf::console::SimpleCommandNode::v_help(std::ostream & output)
224 output << doc_ <<
"\n";
227 prefix_ std::string senf::console::SimpleCommandNode::v_shorthelp()
230 if (! shortdoc_.empty())
232 return doc_.substr(0,doc_.find(
'\n'));
235 prefix_ void senf::console::SimpleCommandNode::v_execute(boost::any & rv, std::ostream & os,
ptr thisptr()
Get smart pointer to node.
boost::shared_ptr< DirectoryNode > ptr
Config/console tree directory node.
bool active() const
true, if node is attached to the root() node
Single parsed console command.
void dump(std::ostream &os, DirectoryNode &dir=root())
Dump console directory structure.
std::string const & name() const
Node name.
NodeType & add(std::string const &name, boost::shared_ptr< NodeType > node)
Add node to tree.
boost::shared_ptr< GenericNode const > cptr
GenericNode & getLink(std::string const &name) const
Get child node without dereferencing links.
void rename(std::string const &newName)
Rename node name in it's parent directory.
ChildMap::const_iterator child_iterator
void moveChildren(DirectoryNode &from, DirectoryNode &to)
DirectoryNode & root()
Get console root node.
boost::shared_ptr< DirectoryNode > parent() const
Parent node.
ChildrenRange children() const
Return iterator range over all children.
unspecified_keyword_type name
Argument name.
Config/console node tree base-class.
GenericNode::ptr remove(std::string const &name)
Remove node name from the tree.
boost::shared_ptr< GenericNode > ptr
Exception: Unknown node name.
ptr unlink()
Remove node from it's parent directory.
std::string path() const
Node path.
bool isChildOf(DirectoryNode &parent) const
true, if node is a child of parent