summaryrefslogtreecommitdiffstats
path: root/Source/cmGeneratedFileStream.h
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2005-01-26 19:25:16 (GMT)
committerBrad King <brad.king@kitware.com>2005-01-26 19:25:16 (GMT)
commitaaac6f2c3ac9e9f95f0fdad7d77b4de21568ed52 (patch)
treecbe224acc7180d02629d171ab2e8b9dadabea84f /Source/cmGeneratedFileStream.h
parentf6cd83d6f3dfad07cedf82e96eb371fa264abef2 (diff)
downloadCMake-aaac6f2c3ac9e9f95f0fdad7d77b4de21568ed52.zip
CMake-aaac6f2c3ac9e9f95f0fdad7d77b4de21568ed52.tar.gz
CMake-aaac6f2c3ac9e9f95f0fdad7d77b4de21568ed52.tar.bz2
ENH: Added default constructor and Open method.
Diffstat (limited to 'Source/cmGeneratedFileStream.h')
-rw-r--r--Source/cmGeneratedFileStream.h25
1 files changed, 23 insertions, 2 deletions
diff --git a/Source/cmGeneratedFileStream.h b/Source/cmGeneratedFileStream.h
index 7430ef9..ff5f228 100644
--- a/Source/cmGeneratedFileStream.h
+++ b/Source/cmGeneratedFileStream.h
@@ -25,12 +25,19 @@
class cmGeneratedFileStreamBase
{
protected:
- // The constructor prepares the temporary output file.
+ // This constructor does not prepare the temporary file. The open
+ // method must be used.
+ cmGeneratedFileStreamBase();
+
+ // This constructor prepares the temporary output file.
cmGeneratedFileStreamBase(const char* name);
// The destructor renames the temporary output file to the real name.
~cmGeneratedFileStreamBase();
+ // Internal method to setup the instance for a given file name.
+ void Open(const char* name);
+
// Internal file replacement implementation.
int RenameFile(const char* oldname, const char* newname);
@@ -64,7 +71,13 @@ public:
typedef std::ofstream Stream;
/**
- * The constructor takes the name of the file to be generated. It
+ * This constructor prepares a default stream. The open method must
+ * be used before writing to the stream.
+ */
+ cmGeneratedFileStream();
+
+ /**
+ * This constructor takes the name of the file to be generated. It
* automatically generates a name for the temporary file. If the
* file cannot be opened an error message is produced unless the
* second argument is set to true.
@@ -79,6 +92,14 @@ public:
~cmGeneratedFileStream();
/**
+ * Open an output file by name. This should be used only with a
+ * default-constructed stream. It automatically generates a name
+ * for the temporary file. If the file cannot be opened an error
+ * message is produced unless the second argument is set to true.
+ */
+ cmGeneratedFileStream& Open(const char* name, bool quiet=false);
+
+ /**
* Set whether copy-if-different is done.
*/
void SetCopyIfDifferent(bool copy_if_different);