3 * This source code is part of
7 * GROningen MAchine for Chemical Simulations
9 * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
10 * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
11 * Copyright (c) 2001-2009, The GROMACS development team,
12 * check out http://www.gromacs.org for more information.
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version 2
17 * of the License, or (at your option) any later version.
19 * If you want to redistribute modifications, please consider that
20 * scientific software is very special. Version control is crucial -
21 * bugs must be traceable. We will be happy to consider code for
22 * inclusion in the official distribution, but derived work must not
23 * be called official GROMACS. Details are found in the README & COPYING
24 * files - if they are missing, get the official version at www.gromacs.org.
26 * To help us fund GROMACS development, we humbly ask that you cite
27 * the papers on the package - you can find them in the top README file.
29 * For more info, check our website at http://www.gromacs.org
31 /*! \libinternal \file
33 * Declares gmx::HelpWriterContext.
35 * \author Teemu Murtola <teemu.murtola@cbr.su.se>
37 * \ingroup module_onlinehelp
39 #ifndef GMX_ONLINEHELP_HELPWRITERCONTEXT_H
40 #define GMX_ONLINEHELP_HELPWRITERCONTEXT_H
44 #include "../utility/common.h"
52 //! \libinternal Output format for help writing.
55 eHelpOutputFormat_Console, //!< Plain text directly on the console.
56 eHelpOutputFormat_NR //!< Used for the number of output formats.
60 /*! \libinternal \brief
61 * Context information for writing out help.
63 * The purpose of this class is to pass information about the output format to
64 * methods that write help, and to abstract away most of the details of
65 * different output formats.
66 * Additionally, it can keep other context information, although it currently
67 * does not. Such additional context information would be useful for
68 * formatting links/references to other help topics.
70 * TODO: This class will need additional work as part of Redmine issue #969.
73 * \ingroup module_onlinehelp
75 class HelpWriterContext
79 * Initializes a context with the given output file and format.
81 * \throws std::bad_alloc if out of memory.
83 HelpWriterContext(File *file, HelpOutputFormat format);
87 * Returns the active output format.
91 HelpOutputFormat outputFormat() const;
93 * Returns the raw output file for writing the help.
95 * Using this file directly should be avoided, as it requires one to
96 * have different code for each output format.
97 * Using other methods in this class should be preferred.
101 File &outputFile() const;
104 * Substitutes markup used in help text.
106 * \param[in] text Text to substitute.
107 * \returns \p text with markup substituted.
108 * \throws std::bad_alloc if out of memory.
110 std::string substituteMarkup(const std::string &text) const;
112 * Writes a title for the current help topic.
114 * \param[in] title Title to write.
115 * \throws std::bad_alloc if out of memory.
116 * \throws FileIOError on any I/O error.
118 void writeTitle(const std::string &title) const;
120 * Writes a formatted text block into the output.
122 * \param[in] text Text to format.
123 * \throws std::bad_alloc if out of memory.
124 * \throws FileIOError on any I/O error.
126 * In addition to substituteMarkup(), also does line wrapping for
129 * TODO: This function and substituteMarkup() should work more
132 void writeTextBlock(const std::string &text) const;
137 PrivateImplPointer<Impl> impl_;