Console: Added Module
[senf.git] / Console / Parse.cci
1 // $Id$
2 //
3 // Copyright (C) 2008 
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 /** \file
24     \brief Parse inline non-template implementation */
25
26 // We do NOT want to include the complete parser definition into every other compilation unit
27 // (disabled) #include "Parse.ih"
28
29 // Custom includes
30 #include "../Utils/senfassert.hh"
31
32 #define prefix_ inline
33 ///////////////////////////////cci.p///////////////////////////////////////
34
35 ///////////////////////////////////////////////////////////////////////////
36 // senf::console::ArgumentToken
37
38 prefix_ std::string const & senf::console::ArgumentToken::value()
39     const
40 {
41     return token_;
42 }
43
44 prefix_ senf::console::ArgumentToken::ArgumentToken(std::string token)
45     : token_ (token)
46 {}
47
48 ///////////////////////////////////////////////////////////////////////////
49 // senf::console::ParseCommandInfo
50
51 prefix_ std::string const & senf::console::ParseCommandInfo::commandPath()
52     const
53 {
54     return commandPath_;
55 }
56
57 prefix_ senf::console::ParseCommandInfo::size_type senf::console::ParseCommandInfo::arguments()
58     const
59 {
60     return arguments_.size();
61 }
62
63 prefix_ senf::console::ParseCommandInfo::argument_iterator
64 senf::console::ParseCommandInfo::begin_arguments()
65     const
66 {
67     return arguments_.begin();
68 }
69
70 prefix_ senf::console::ParseCommandInfo::argument_iterator
71 senf::console::ParseCommandInfo::end_arguments()
72     const
73 {
74     return arguments_.end();
75 }
76
77 prefix_ senf::console::ParseCommandInfo::size_type senf::console::ParseCommandInfo::tokens()
78     const
79 {
80     return tokens_.size();
81 }
82
83 prefix_ senf::console::ParseCommandInfo::token_iterator
84 senf::console::ParseCommandInfo::begin_tokens()
85     const
86 {
87     return tokens_.begin();
88 }
89
90 prefix_ senf::console::ParseCommandInfo::token_iterator
91 senf::console::ParseCommandInfo::end_tokens()
92     const
93 {
94     return tokens_.end();
95 }
96
97 ////////////////////////////////////////
98 // private members
99
100 prefix_ void senf::console::ParseCommandInfo::init()
101 {
102     commandPath_ = "";
103     tokens_.clear();
104     arguments_.clear();
105     tempArguments_.clear();
106 }
107
108 prefix_ void senf::console::ParseCommandInfo::setCommand(std::string const & commandPath)
109 {
110     commandPath_ = commandPath;
111 }
112
113 prefix_ void senf::console::ParseCommandInfo::startArgument()
114 {
115     tempArguments_.push_back( TempArgumentRange( tokens_.size(), tokens_.size() ) );
116 }
117
118 prefix_ void senf::console::ParseCommandInfo::endArgument()
119 {
120     tempArguments_.back().second = tokens_.size();
121 }
122
123 prefix_ void senf::console::ParseCommandInfo::addToken(ArgumentToken const & token)
124 {
125     tokens_.push_back(token);
126 }
127
128 ///////////////////////////////////////////////////////////////////////////
129 // senf::console::SingleCommandParser
130
131 prefix_ senf::console::SingleCommandParser::Impl & senf::console::SingleCommandParser::impl()
132 {
133     SENF_ASSERT(impl_);
134     return *impl_;
135 }
136
137 ///////////////////////////////cci.e///////////////////////////////////////
138 #undef prefix_
139
140 \f
141 // Local Variables:
142 // mode: c++
143 // fill-column: 100
144 // comment-column: 40
145 // c-file-style: "senf"
146 // indent-tabs-mode: nil
147 // ispell-local-dictionary: "american"
148 // compile-command: "scons -u test"
149 // End: