NewFile.h

Classes

NewFile -- Do checks for a new (non-existent) file. (full description)

class NewFile

Interface

Public Members
NewFile(Bool deleteIfExists = True)
NewFile(const NewFile &other)
NewFile &operator=(const NewFile &other)
~NewFile()
Bool valueOK(const String &value, String &error) const

Description

Review Status

Date Reviewed:
yyyy/mm/dd

Etymology

Use this if you want a New File.

Synopsis

NewFile is a class checking if a new file already exists. If the file exists, then the user is asked via Choice::choice whether or not he or she wants to delete the file before using it.

Example

NewFile validFile; String newFileName("bigone"), error; Bool ok = validFile.valueOK(newFileName, error); if (!ok) { cout << error << endl; }

Motivation

Output file names are fairly common parameters, this consolidates the error checking and "remove if it already exists" logic.

To Do

Member Description

NewFile(Bool deleteIfExists = True)

Currently the deleteIfExists argument has no affect

NewFile(const NewFile &other)

Copy constructor (copy semantics)

NewFile &operator=(const NewFile &other)

Assignment (copy semantics)

~NewFile()

Destructor

Bool valueOK(const String &value, String &error) const

Indicates whether the specified string is a valid new file, invoking the choice GUI. If it returns False, an error message is returned.