Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

ParsedCommand.cci

Go to the documentation of this file.
00001 // $Id: ParsedCommand.cci 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2008
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00026 #include "ParsedCommand.ih"
00027 
00028 // Custom includes
00029 
00030 #define prefix_ inline
00031 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00032 
00033 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00034 // senf::console::detail::ArgumentInfoBase
00035 
00036 prefix_ senf::console::detail::ArgumentInfoBase::ArgumentInfoBase(std::string const & type_,
00037                                                                   bool singleToken_)
00038     : type (type_), name (), hasDefault (false), singleToken (singleToken_)
00039 {}
00040 
00041 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00042 // senf::console::ParsedCommandOverloadBase
00043 
00044 prefix_ senf::console::ParsedCommandOverloadBase::ParsedCommandOverloadBase()
00045 {}
00046 
00047 prefix_ senf::console::detail::ArgumentInfoBase &
00048 senf::console::ParsedCommandOverloadBase::arg(unsigned n)
00049     const
00050 {
00051     BOOST_ASSERT(n < parameters_.size());
00052     return * parameters_[n];
00053 }
00054 
00055 prefix_ void senf::console::ParsedCommandOverloadBase::doc(std::string const & d)
00056 {
00057     doc_ = d;
00058 }
00059 
00060 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00061 // senf::console::ParsedCommandAttributorBase
00062 
00063 prefix_ senf::console::OverloadedCommandNode &
00064 senf::console::ParsedCommandAttributorBase::create(DirectoryNode & dir,
00065                                                    std::string const & name)
00066     const
00067 {
00068     OverloadedCommandNode & node (OverloadedCommandNode::insertOverload(dir, name, overload_));
00069     if (doc_) node.doc(*doc_);
00070     if (shortdoc_) node.shortdoc(*shortdoc_);
00071     return node;
00072 }
00073 
00074 prefix_ senf::console::ParsedCommandAttributorBase::
00075 ParsedCommandAttributorBase(ParsedCommandOverloadBase::ptr overload, unsigned index)
00076   : overload_ (overload), index_ (index)
00077 {}
00078 
00079 prefix_ senf::console::ParsedCommandAttributorBase::
00080 ParsedCommandAttributorBase(ParsedCommandAttributorBase const & other, unsigned index)
00081     : overload_ (other.overload_), index_ (index), doc_ (other.doc_), shortdoc_ (other.shortdoc_)
00082 {}
00083 
00084 prefix_ senf::console::ParsedCommandOverloadBase &
00085 senf::console::ParsedCommandAttributorBase::overload()
00086     const
00087 {
00088     return *overload_;
00089 }
00090 
00091 prefix_ void senf::console::ParsedCommandAttributorBase::argName(std::string const & name)
00092 {
00093     overload().arg(index_).name = name;
00094 }
00095 
00096 prefix_ void senf::console::ParsedCommandAttributorBase::argDoc(std::string const & doc)
00097 {
00098     overload().arg(index_).doc = doc;
00099 }
00100 
00101 prefix_ void senf::console::ParsedCommandAttributorBase::typeName(std::string const & doc)
00102 {
00103     overload().arg(index_).type = doc;
00104 }
00105 
00106 prefix_ void senf::console::ParsedCommandAttributorBase::defaultDoc(std::string const & doc)
00107 {
00108     overload().arg(index_).defaultDoc = doc;
00109 }
00110 
00111 prefix_ void senf::console::ParsedCommandAttributorBase::overloadDoc(std::string const & doc)
00112 {
00113     overload().doc(doc);
00114 }
00115 
00116 prefix_ void senf::console::ParsedCommandAttributorBase::nodeDoc(std::string const & doc)
00117 {
00118     doc_ = doc;
00119 }
00120 
00121 prefix_ void senf::console::ParsedCommandAttributorBase::shortDoc(std::string const & doc)
00122 {
00123     shortdoc_ = doc;
00124 }
00125 
00126 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00127 #undef prefix_
00128 
00129 
00130 // Local Variables:
00131 // mode: c++
00132 // fill-column: 100
00133 // comment-column: 40
00134 // c-file-style: "senf"
00135 // indent-tabs-mode: nil
00136 // ispell-local-dictionary: "american"
00137 // compile-command: "scons -u test"
00138 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research