- //! Initializes the state with the given parameters.
- SharedState(File *file, HelpOutputFormat format,
- const HelpLinks *links)
- : file_(*file), format_(format), links_(links)
- {
- }
-
- //! Output file to which the help is written.
- File &file_;
- //! Output format for the help output.
- HelpOutputFormat format_;
- //! Links to use.
- const HelpLinks *links_;
+ public:
+ //! Initializes the state with the given parameters.
+ SharedState(File *file, HelpOutputFormat format,
+ const HelpLinks *links)
+ : file_(*file), format_(format), links_(links)
+ {
+ }
+
+ /*! \brief
+ * Returns a formatter for formatting options lists for console
+ * output.
+ *
+ * The formatter is lazily initialized on first access.
+ */
+ TextTableFormatter &consoleOptionsFormatter() const
+ {
+ GMX_RELEASE_ASSERT(format_ == eHelpOutputFormat_Console,
+ "Accessing console formatter for non-console output");
+ if (!consoleOptionsFormatter_)
+ {
+ consoleOptionsFormatter_.reset(new TextTableFormatter());
+ consoleOptionsFormatter_->setFirstColumnIndent(1);
+ consoleOptionsFormatter_->addColumn(NULL, 7, false);
+ consoleOptionsFormatter_->addColumn(NULL, 18, false);
+ consoleOptionsFormatter_->addColumn(NULL, 16, false);
+ consoleOptionsFormatter_->addColumn(NULL, 28, false);
+ }
+ return *consoleOptionsFormatter_;
+ }
+
+ //! Output file to which the help is written.
+ File &file_;
+ //! Output format for the help output.
+ HelpOutputFormat format_;
+ //! Links to use.
+ const HelpLinks *links_;
+
+ private:
+ //! Formatter for console output options.
+ mutable boost::scoped_ptr<TextTableFormatter> consoleOptionsFormatter_;