Sort all includes in src/gromacs
[alexxy/gromacs.git] / src / gromacs / onlinehelp / helpwritercontext.h
index f28c904f7bcadfa5c0e521f5df4f48d80b3e83fc..8bbc2b63e8f6d0a3af17e936a2b25b4ab080517d 100644 (file)
@@ -1,10 +1,10 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2012,2013, by the GROMACS development team, led by
- * David van der Spoel, Berk Hess, Erik Lindahl, and including many
- * others, as listed in the AUTHORS file in the top-level source
- * directory and at http://www.gromacs.org.
+ * Copyright (c) 2012,2013,2014, by the GROMACS development team, led by
+ * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
+ * and including many others, as listed in the AUTHORS file in the
+ * top-level source directory and at http://www.gromacs.org.
  *
  * GROMACS is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -46,7 +46,7 @@
 #include <string>
 #include <vector>
 
-#include "../utility/common.h"
+#include "gromacs/utility/common.h"
 
 namespace gmx
 {
@@ -61,6 +61,7 @@ enum HelpOutputFormat
     eHelpOutputFormat_Console,  //!< Plain text directly on the console.
     eHelpOutputFormat_Man,      //!< Man page.
     eHelpOutputFormat_Html,     //!< Html output for online manual.
+    eHelpOutputFormat_Other,    //!< Used for extensions in other modules.
     eHelpOutputFormat_NR        //!< Used for the number of output formats.
 };
 //! \endcond
@@ -73,27 +74,37 @@ enum HelpOutputFormat
  * This is used when exporting all the help from the wrapper binary to avoid
  * repeatedly constructing the same data structure for each help item.
  *
+ * While the links are in principle independent of the output format, the
+ * constructor takes the output format to be able to preformat the links,
+ * avoiding repeated processing during markup substitution.  Could be hidden
+ * behind the scenes in HelpWriterContext, but that would complicate the
+ * implementation.
+ *
  * \ingroup module_onlinehelp
  */
 class HelpLinks
 {
     public:
-        //! Initializes an empty links collection.
-        HelpLinks();
+        /*! \brief
+         * Initializes an empty links collection for the given output format.
+         */
+        explicit HelpLinks(HelpOutputFormat format);
         ~HelpLinks();
 
         /*! \brief
          * Adds a link.
          *
-         * \param[in] linkName   Name of the link in input text.
-         * \param[in] targetName Hyperlink target.
+         * \param[in] linkName     Name of the link in input text.
+         * \param[in] targetName   Hyperlink target.
+         * \param[in] displayName  Text to show as the link.
          *
          * Any occurrence of \p linkName in the text passed to markup
          * substitution methods in HelpWriterContext is made into a hyperlink
          * to \p targetName if the markup format supports that.
          */
         void addLink(const std::string &linkName,
-                     const std::string &targetName);
+                     const std::string &targetName,
+                     const std::string &displayName);
 
     private:
         class Impl;
@@ -144,6 +155,21 @@ class HelpWriterContext
         HelpWriterContext(const HelpWriterContext &other);
         ~HelpWriterContext();
 
+        /*! \brief
+         * Adds a string replacement for markup subsitution.
+         *
+         * \param[in] search   Text to replace in input.
+         * \param[in] replace  Text that each occurrence of \p search is
+         *     replaced with.
+         * \throws std::bad_alloc if out of memory.
+         *
+         * \todo
+         * Improve semantics if the same \p search item is set multiple
+         * times.
+         */
+        void setReplacement(const std::string &search,
+                            const std::string &replace);
+
         /*! \brief
          * Returns the active output format.
          *
@@ -208,18 +234,29 @@ class HelpWriterContext
          */
         void writeTextBlock(const std::string &text) const;
         /*! \brief
-         * Writes a formatted text block into the output.
+         * Starts writing a list of options.
          *
-         * \param[in] settings Line wrapper settings.
-         * \param[in] text     Text to format.
-         * \throws    std::bad_alloc if out of memory.
-         * \throws    FileIOError on any I/O error.
+         * Prints any necessary headers for a list of options formatted with
+         * writeOptionItem().
+         */
+        void writeOptionListStart() const;
+        /*! \brief
+         * Writes an entry for a single option into the output.
          *
-         * Convenience function that calls substituteMarkupAndWrapToString()
-         * and writes the result directly to the output file.
+         * \param[in] name  Name of the option.
+         * \param[in] args  Placeholder for values and other information about
+         *     the option (placed after \p name).
+         * \param[in] description  Full description of the option.
+         */
+        void writeOptionItem(const std::string &name, const std::string &args,
+                             const std::string &description) const;
+        /*! \brief
+         * Finishes writing a list of options.
+         *
+         * Prints any necessary footers for a list of options formatted with
+         * writeOptionItem().
          */
-        void writeTextBlock(const TextLineWrapperSettings &settings,
-                            const std::string             &text) const;
+        void writeOptionListEnd() const;
 
     private:
         class Impl;