// -*- C++ -*- // // This file was generated by CLI, a command line interface // compiler for C++. // // Begin prologue. // #include // // End prologue. #include #include #include #include #include #include #include #include #include namespace openssl { namespace cli { // unknown_option // unknown_option:: ~unknown_option () noexcept { } void unknown_option:: print (::std::ostream& os) const { os << "unknown option '" << option ().c_str () << "'"; } const char* unknown_option:: what () const noexcept { return "unknown option"; } // unknown_argument // unknown_argument:: ~unknown_argument () noexcept { } void unknown_argument:: print (::std::ostream& os) const { os << "unknown argument '" << argument ().c_str () << "'"; } const char* unknown_argument:: what () const noexcept { return "unknown argument"; } // missing_value // missing_value:: ~missing_value () noexcept { } void missing_value:: print (::std::ostream& os) const { os << "missing value for option '" << option ().c_str () << "'"; } const char* missing_value:: what () const noexcept { return "missing option value"; } // invalid_value // invalid_value:: ~invalid_value () noexcept { } void invalid_value:: print (::std::ostream& os) const { os << "invalid value '" << value ().c_str () << "' for option '" << option ().c_str () << "'"; if (!message ().empty ()) os << ": " << message ().c_str (); } const char* invalid_value:: what () const noexcept { return "invalid option value"; } // eos_reached // void eos_reached:: print (::std::ostream& os) const { os << what (); } const char* eos_reached:: what () const noexcept { return "end of argument stream reached"; } // scanner // scanner:: ~scanner () { } // argv_scanner // bool argv_scanner:: more () { return i_ < argc_; } const char* argv_scanner:: peek () { if (i_ < argc_) return argv_[i_]; else throw eos_reached (); } const char* argv_scanner:: next () { if (i_ < argc_) { const char* r (argv_[i_]); if (erase_) { for (int i (i_ + 1); i < argc_; ++i) argv_[i - 1] = argv_[i]; --argc_; argv_[argc_] = 0; } else ++i_; ++start_position_; return r; } else throw eos_reached (); } void argv_scanner:: skip () { if (i_ < argc_) { ++i_; ++start_position_; } else throw eos_reached (); } std::size_t argv_scanner:: position () { return start_position_; } template struct parser { static void parse (X& x, bool& xs, scanner& s) { using namespace std; const char* o (s.next ()); if (s.more ()) { string v (s.next ()); istringstream is (v); if (!(is >> x && is.peek () == istringstream::traits_type::eof ())) throw invalid_value (o, v); } else throw missing_value (o); xs = true; } }; template <> struct parser { static void parse (bool& x, bool& xs, scanner& s) { const char* o (s.next ()); if (s.more ()) { const char* v (s.next ()); if (std::strcmp (v, "1") == 0 || std::strcmp (v, "true") == 0 || std::strcmp (v, "TRUE") == 0 || std::strcmp (v, "True") == 0) x = true; else if (std::strcmp (v, "0") == 0 || std::strcmp (v, "false") == 0 || std::strcmp (v, "FALSE") == 0 || std::strcmp (v, "False") == 0) x = false; else throw invalid_value (o, v); } else throw missing_value (o); xs = true; } }; template <> struct parser { static void parse (std::string& x, bool& xs, scanner& s) { const char* o (s.next ()); if (s.more ()) x = s.next (); else throw missing_value (o); xs = true; } }; template struct parser > { static void parse (std::pair& x, bool& xs, scanner& s) { x.second = s.position (); parser::parse (x.first, xs, s); } }; template struct parser > { static void parse (std::vector& c, bool& xs, scanner& s) { X x; bool dummy; parser::parse (x, dummy, s); c.push_back (x); xs = true; } }; template struct parser > { static void parse (std::set& c, bool& xs, scanner& s) { X x; bool dummy; parser::parse (x, dummy, s); c.insert (x); xs = true; } }; template struct parser > { static void parse (std::map& m, bool& xs, scanner& s) { const char* o (s.next ()); if (s.more ()) { std::size_t pos (s.position ()); std::string ov (s.next ()); std::string::size_type p = ov.find ('='); K k = K (); V v = V (); std::string kstr (ov, 0, p); std::string vstr (ov, (p != std::string::npos ? p + 1 : ov.size ())); int ac (2); char* av[] = { const_cast (o), 0 }; bool dummy; if (!kstr.empty ()) { av[1] = const_cast (kstr.c_str ()); argv_scanner s (0, ac, av, false, pos); parser::parse (k, dummy, s); } if (!vstr.empty ()) { av[1] = const_cast (vstr.c_str ()); argv_scanner s (0, ac, av, false, pos); parser::parse (v, dummy, s); } m[k] = v; } else throw missing_value (o); xs = true; } }; template struct parser > { static void parse (std::multimap& m, bool& xs, scanner& s) { const char* o (s.next ()); if (s.more ()) { std::size_t pos (s.position ()); std::string ov (s.next ()); std::string::size_type p = ov.find ('='); K k = K (); V v = V (); std::string kstr (ov, 0, p); std::string vstr (ov, (p != std::string::npos ? p + 1 : ov.size ())); int ac (2); char* av[] = { const_cast (o), 0 }; bool dummy; if (!kstr.empty ()) { av[1] = const_cast (kstr.c_str ()); argv_scanner s (0, ac, av, false, pos); parser::parse (k, dummy, s); } if (!vstr.empty ()) { av[1] = const_cast (vstr.c_str ()); argv_scanner s (0, ac, av, false, pos); parser::parse (v, dummy, s); } m.insert (typename std::multimap::value_type (k, v)); } else throw missing_value (o); xs = true; } }; template void thunk (X& x, scanner& s) { parser::parse (x.*M, s); } template void thunk (X& x, scanner& s) { s.next (); x.*M = true; } template void thunk (X& x, scanner& s) { parser::parse (x.*M, x.*S, s); } } } #include namespace openssl { } // Begin epilogue. // // // End epilogue.