aboutsummaryrefslogtreecommitdiff
path: root/brep/module.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-08-11 20:11:47 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-08-23 13:50:52 +0200
commit24903813d11813f8ff9ac906d23b21e6c33b981d (patch)
treeb4a7c1cc6dc4c2e7a1588573c86e2b20aa763a41 /brep/module.cxx
parenta7e766e1aa77fff846d8426658befd9a01fe2861 (diff)
Parse http request parameters using CLI
Diffstat (limited to 'brep/module.cxx')
-rw-r--r--brep/module.cxx60
1 files changed, 59 insertions, 1 deletions
diff --git a/brep/module.cxx b/brep/module.cxx
index ceadc23..c52d13a 100644
--- a/brep/module.cxx
+++ b/brep/module.cxx
@@ -25,6 +25,8 @@ using namespace placeholders; // For std::bind's _1, etc.
namespace brep
{
+ // module
+ //
void module::
handle (request& rq, response& rs, log& l)
{
@@ -111,7 +113,7 @@ namespace brep
const_cast<char**> (argv.data ()),
"conf");
- module_options o (s, cli::unknown_mode::skip, cli::unknown_mode::skip);
+ options::module o (s, cli::unknown_mode::skip, cli::unknown_mode::skip);
verb_ = o.verb ();
}
catch (const server_error& e)
@@ -228,4 +230,60 @@ namespace brep
}
}
}
+
+ // module::param_scanner
+ //
+ module::param_scanner::
+ param_scanner (const name_values& nv) noexcept
+ : name_values_ (nv),
+ i_ (nv.begin ()),
+ name_ (true)
+ {
+ }
+
+ bool module::param_scanner::
+ more ()
+ {
+ return i_ != name_values_.end ();
+ }
+
+ const char* module::param_scanner::
+ peek ()
+ {
+ if (i_ != name_values_.end ())
+ return name_ ? i_->name.c_str () : i_->value.c_str ();
+ else
+ throw cli::eos_reached ();
+ }
+
+ const char* module::param_scanner::
+ next ()
+ {
+ if (i_ != name_values_.end ())
+ {
+ const char* r (name_ ? i_->name.c_str () : i_->value.c_str ());
+
+ if (!name_)
+ ++i_;
+
+ name_ = !name_;
+ return r;
+ }
+ else
+ throw cli::eos_reached ();
+ }
+
+ void module::param_scanner::
+ skip ()
+ {
+ if (i_ != name_values_.end ())
+ {
+ if (!name_)
+ ++i_;
+
+ name_ = !name_;
+ }
+ else
+ throw cli::eos_reached ();
+ }
}