From 426af2faedc6d4cd03e494dc3b29bbd54df5a27b Mon Sep 17 00:00:00 2001 From: randomdan Date: Thu, 1 Dec 2011 13:06:26 +0000 Subject: Allow specifying default CGI output options in the config file --- project2/cgi/cgiOutputOptions.cpp | 26 ++++++++++++++++++++++++++ project2/cgi/cgiOutputOptions.h | 28 ++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/project2/cgi/cgiOutputOptions.cpp b/project2/cgi/cgiOutputOptions.cpp index 6e22641..abda276 100644 --- a/project2/cgi/cgiOutputOptions.cpp +++ b/project2/cgi/cgiOutputOptions.cpp @@ -1,5 +1,12 @@ #include "cgiOutputOptions.h" +bool OutputOptions::core; +bool OutputOptions::session; +bool OutputOptions::timing; +bool OutputOptions::environment; +bool OutputOptions::url; +bool OutputOptions::parameters; + OutputOptions::OutputOptions(const xmlpp::Element * p) : Core(p, "core", false, true), Session(p, "session", false, true), @@ -10,10 +17,29 @@ OutputOptions::OutputOptions(const xmlpp::Element * p) : { } +OutputOptionsLoader::OutputOptionsLoader() : + opts("CGI default output options") +{ + opts.add_options() + ("cgi.output.core", po::value(&OutputOptions::core), "Core messages") + ("cgi.output.session", po::value(&OutputOptions::core), "Session values") + ("cgi.output.timing", po::value(&OutputOptions::core), "Timing") + ("cgi.output.environment", po::value(&OutputOptions::core), "Environment") + ("cgi.output.url", po::value(&OutputOptions::core), "URL breakdown") + ("cgi.output.parameters", po::value(&OutputOptions::core), "Parameters") + ; +} + OutputOptionsPtr OutputOptionsLoader::createFrom(const xmlpp::Element * e) const { return new OutputOptions(e); } +po::options_description * +OutputOptionsLoader::options() +{ + return &opts; +} + DECLARE_CUSTOM_COMPONENT_LOADER("outputoptions", OutputOptions, OutputOptionsLoader, OutputOptionsLoader) diff --git a/project2/cgi/cgiOutputOptions.h b/project2/cgi/cgiOutputOptions.h index 48579cd..540764e 100644 --- a/project2/cgi/cgiOutputOptions.h +++ b/project2/cgi/cgiOutputOptions.h @@ -1,9 +1,14 @@ -#include "intrusivePtrBase.h" +#ifndef OUTPUTOPTIONS_H +#define OUTPUTOPTIONS_H +#include "intrusivePtrBase.h" +#include #include "variables.h" + namespace xmlpp { class Element; } + class OutputOptions : public IntrusivePtrBase { public: OutputOptions(const xmlpp::Element *); @@ -14,9 +19,28 @@ class OutputOptions : public IntrusivePtrBase { const Variable Environment; const Variable URL; const Variable Parameters; + + private: + // defaults + friend class OutputOptionsLoader; + static bool core; + static bool session; + static bool timing; + static bool environment; + static bool url; + static bool parameters; }; typedef boost::intrusive_ptr OutputOptionsPtr; + +namespace po = boost::program_options; class OutputOptionsLoader : public ComponentLoader { public: - virtual OutputOptionsPtr createFrom(const xmlpp::Element * e) const; + OutputOptionsLoader(); + OutputOptionsPtr createFrom(const xmlpp::Element * e) const; + po::options_description * options(); + + private: + po::options_description opts; }; + +#endif -- cgit v1.2.3