Isis 3 Programmer Reference
FileName.h
1 #ifndef FileName_h
2 #define FileName_h
3 
8 /* SPDX-License-Identifier: CC0-1.0 */
9 
10 #include <QSharedData>
11 
12 class QDate;
13 class QDir;
14 class QString;
15 
16 template<typename A, typename B> struct QPair;
17 
18 namespace Isis {
100  class FileName {
101  public:
102  // Constructors
103  FileName();
104  FileName(const char *fileName);
105  FileName(const QString &fileName);
106 
107  // Copy Constructor, creates a copy of a FileName object.
108  FileName(const FileName &other);
109 
110  // Destroys the FileName Object
111  ~FileName();
112 
113  // Methods
114  QString originalPath() const;
115  QString path() const;
116  QString attributes() const;
117  QString baseName() const;
118  QString name() const;
119  QString extension() const;
120 
121 
135  QString expanded() const;
136 
137 
149  QString original() const;
150 
151  FileName addExtension(const QString &extension) const;
152  FileName removeExtension() const;
153  FileName setExtension(const QString &extension) const;
154 
155  bool isVersioned() const;
156  bool isNumericallyVersioned() const;
157  bool isDateVersioned() const;
158 
159  FileName highestVersion() const;
160  FileName newVersion() const;
161 
162  bool fileExists() const;
163  QDir dir() const;
164  static FileName createTempFile(FileName templateFileName = "$TEMPORARY/temp");
165 
166 
180  QString toString() const;
181  FileName &operator=(const FileName &rhs);
182  bool operator==(const FileName &rhs);
183  bool operator!=(const FileName &rhs);
184 
185 
186  private:
187  FileName version(long versionNumber) const;
188  FileName version(QDate versionDate) const;
189  QDate highestVersionDate() const;
190  long highestVersionNum() const;
191  void validateVersioningState() const;
192  QString fileNameQDatePattern() const;
194 
195  private:
203  class Data : public QSharedData {
204  public:
205 
206  // Constructors
207  Data();
208 
209  // Copy Constructor, creates a copy of a Data object.
210  Data(const Data &other);
211 
212  // Destroys the Data Object
213  ~Data();
214 
215  // Methods
216  QString original(bool includeAttributes) const;
217  void setOriginal(const QString &originalStr);
218  QString expanded(bool includeAttributes) const;
219 
220  private:
221  // Holds the original file name.
222  QString *m_originalFileNameString;
223 
224 
225  // Holds the expanded file name.
226  QString *m_expandedFileNameString;
227  };
228 
229  // @see QSharedDataPointer
230  QSharedDataPointer<Data> m_d;
231  };
232 };
233 
234 #endif
Isis::FileName::originalPath
QString originalPath() const
Returns the path of the original file name.
Definition: FileName.cpp:84
Isis::FileName::fileNameQDatePattern
QString fileNameQDatePattern() const
This changes the files format.
Definition: FileName.cpp:727
QSharedData
Isis::FileName::name
QString name() const
Returns the name of the file excluding the path and the attributes in the file name.
Definition: FileName.cpp:162
Isis::FileName
File name manipulation and expansion.
Definition: FileName.h:100
Isis::FileName::fileExists
bool fileExists() const
Returns true if the file exists; false otherwise.
Definition: FileName.cpp:449
Isis::FileName::isDateVersioned
bool isDateVersioned() const
Checks if the file name is versioned by date.
Definition: FileName.cpp:303
Isis::FileName::splitNameAroundVersionNum
QPair< QString, QString > splitNameAroundVersionNum() const
This returns a QPair of the text (before, after) a version number in a file.
Definition: FileName.cpp:757
Isis::FileName::Data::~Data
~Data()
Destroys the Data object.
Definition: FileName.cpp:800
Isis::FileName::Data::original
QString original(bool includeAttributes) const
Returns the original file name, stored in m_originalFileNameString.
Definition: FileName.cpp:817
Isis::FileName::operator=
FileName & operator=(const FileName &rhs)
Clears the current contents of the FileName object and reinitializes it with the argument.
Definition: FileName.cpp:527
Isis::FileName::createTempFile
static FileName createTempFile(FileName templateFileName="$TEMPORARY/temp")
Creates a temporary file and returns a FileName object created using the temporary file.
Definition: FileName.cpp:478
Isis::FileName::newVersion
FileName newVersion() const
Updates the file name to be the latest version.
Definition: FileName.cpp:348
Isis::FileName::baseName
QString baseName() const
Returns the name of the file without the path and without extensions.
Definition: FileName.cpp:145
Isis::FileName::expanded
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition: FileName.cpp:196
Isis::FileName::Data::expanded
QString expanded(bool includeAttributes) const
Returns the expanded file name, stored in m_expandedFileNameString.
Definition: FileName.cpp:912
Isis::FileName::addExtension
FileName addExtension(const QString &extension) const
Adds a new extension to the file name.
Definition: FileName.cpp:225
Isis::FileName::dir
QDir dir() const
Returns the path of the file's parent directory as a QDir object.
Definition: FileName.cpp:465
Isis::FileName::FileName
FileName()
Constructs an empty FileName object.
Definition: FileName.cpp:31
Isis::FileName::highestVersionDate
QDate highestVersionDate() const
This looks through the directory of the file and checks for the highest version date of the file that...
Definition: FileName.cpp:578
Isis::FileName::operator!=
bool operator!=(const FileName &rhs)
Compares equality of two FileName objects.
Definition: FileName.cpp:568
Isis::FileName::toString
QString toString() const
Returns a QString of the full file name including the file path, excluding the attributes with any Is...
Definition: FileName.cpp:515
Isis::FileName::~FileName
~FileName()
Destroys the FileName object.
Definition: FileName.cpp:66
Isis::FileName::highestVersionNum
long highestVersionNum() const
This looks through the directory of the file and checks for the highest version number of the file th...
Definition: FileName.cpp:640
Isis::FileName::operator==
bool operator==(const FileName &rhs)
Compares equality of two FileName objects.
Definition: FileName.cpp:540
Isis::FileName::removeExtension
FileName removeExtension() const
Removes all extensions in the file name.
Definition: FileName.cpp:246
Isis::FileName::extension
QString extension() const
Returns the last extension of the file name.
Definition: FileName.cpp:178
Isis::FileName::isNumericallyVersioned
bool isNumericallyVersioned() const
Checks if the file name is versioned numerically.
Definition: FileName.cpp:293
QPair
This is free and unencumbered software released into the public domain.
Definition: CubeIoHandler.h:23
Isis::FileName::Data::Data
Data()
Data constructor, creates a new Data object.
Definition: FileName.cpp:776
Isis::FileName::isVersioned
bool isVersioned() const
Checks to see if a file name is versioned by date or numerically.
Definition: FileName.cpp:281
Isis::FileName::highestVersion
FileName highestVersion() const
Searches the directory specified in the file name for the highest version of the file name.
Definition: FileName.cpp:313
Isis::FileName::original
QString original() const
Returns the full file name including the file path.
Definition: FileName.cpp:212
Isis::FileName::Data
This is the reference-counted data for FileName.
Definition: FileName.h:203
Isis::FileName::setExtension
FileName setExtension(const QString &extension) const
Sets all current file extensions to a new extension in the file name.
Definition: FileName.cpp:265
Isis::FileName::Data::setOriginal
void setOriginal(const QString &originalStr)
Sets the original file name, stored in m_originalFileNameString.
Definition: FileName.cpp:838
Isis::FileName::path
QString path() const
Returns the path of the file name.
Definition: FileName.cpp:103
Isis::FileName::attributes
QString attributes() const
Returns a QString of the attributes in a filename, attributes are expected to be of type CubeAttribut...
Definition: FileName.cpp:121
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::FileName::validateVersioningState
void validateVersioningState() const
This verifies the class invariant when using versioning - that the FileName is in an acceptable state...
Definition: FileName.cpp:679
Isis::FileName::version
FileName version(long versionNumber) const
Returns a FileName object of the same file name but versioned numerically by the number passed in as ...
Definition: FileName.cpp:398