namespace gmx
{
+class File;
+
+/*! \brief
+ * Parameters for creating a File object.
+ *
+ * This class (mostly) replaces the ability to return a File object from a
+ * function (since File is not copyable): returning a FileInitializer instead
+ * allows the caller to construct the File object.
+ *
+ * \inpublicapi
+ * \ingroup module_utility
+ */
+class FileInitializer
+{
+ public:
+ /*! \brief
+ * Creates the initializer with given parameters.
+ *
+ * The passed strings must remain valid until the initializer is used
+ * to construct a File object.
+ */
+ FileInitializer(const char *filename, const char *mode)
+ : filename_(filename), mode_(mode)
+ {
+ }
+
+ private:
+ const char *filename_;
+ const char *mode_;
+
+ /*! \brief
+ * Needed to allow access to the parameters without otherwise
+ * unnecessary accessors.
+ */
+ friend class File;
+};
+
/*! \brief
* Basic file object.
*
File(const char *filename, const char *mode);
//! \copydoc File(const char *, const char *)
File(const std::string &filename, const char *mode);
+ /*! \brief
+ * Creates a file object and opens a file.
+ *
+ * \param[in] initializer Parameters to open the file.
+ * \throws std::bad_alloc if out of memory.
+ * \throws FileIOError on any I/O error.
+ */
+ File(const FileInitializer &initializer);
/*! \brief
* Destroys the file object.
*