Isis 3 Programmer Reference
FileName.h
Go to the documentation of this file.
1 #ifndef FileName_h
2 #define FileName_h
3 
26 #include <QSharedData>
27 
28 class QDate;
29 class QDir;
30 class QString;
31 
32 template<typename A, typename B> struct QPair;
33 
34 namespace Isis {
116  class FileName {
117  public:
118  // Constructors
119  FileName();
120  FileName(const char *fileName);
121  FileName(const QString &fileName);
122 
123  // Copy Constructor, creates a copy of a FileName object.
124  FileName(const FileName &other);
125 
126  // Destroys the FileName Object
127  ~FileName();
128 
129  // Methods
130  QString originalPath() const;
131  QString path() const;
132  QString attributes() const;
133  QString baseName() const;
134  QString name() const;
135  QString extension() const;
136 
137 
151  QString expanded() const;
152 
153 
165  QString original() const;
166 
167  FileName addExtension(const QString &extension) const;
168  FileName removeExtension() const;
169  FileName setExtension(const QString &extension) const;
170 
171  bool isVersioned() const;
172  bool isNumericallyVersioned() const;
173  bool isDateVersioned() const;
174 
175  FileName highestVersion() const;
176  FileName newVersion() const;
177 
178  bool fileExists() const;
179  QDir dir() const;
180  static FileName createTempFile(FileName templateFileName = "$TEMPORARY/temp");
181 
182 
196  QString toString() const;
197  FileName &operator=(const FileName &rhs);
198  bool operator==(const FileName &rhs);
199  bool operator!=(const FileName &rhs);
200 
201 
202  private:
203  FileName version(long versionNumber) const;
204  FileName version(QDate versionDate) const;
205  QDate highestVersionDate() const;
206  long highestVersionNum() const;
207  void validateVersioningState() const;
208  QString fileNameQDatePattern() const;
210 
211  private:
219  class Data : public QSharedData {
220  public:
221 
222  // Constructors
223  Data();
224 
225  // Copy Constructor, creates a copy of a Data object.
226  Data(const Data &other);
227 
228  // Destroys the Data Object
229  ~Data();
230 
231  // Methods
232  QString original(bool includeAttributes) const;
233  void setOriginal(const QString &originalStr);
234  QString expanded(bool includeAttributes) const;
235 
236  private:
237  // Holds the original file name.
238  QString *m_originalFileNameString;
239 
240 
241  // Holds the expanded file name.
242  QString *m_expandedFileNameString;
243  };
244 
245  // @see QSharedDataPointer
246  QSharedDataPointer<Data> m_d;
247  };
248 };
249 
250 #endif
QString path() const
Returns the path of the file name.
Definition: FileName.cpp:119
File name manipulation and expansion.
Definition: FileName.h:116
Data()
Data constructor, creates a new Data object.
Definition: FileName.cpp:792
FileName newVersion() const
Updates the file name to be the latest version.
Definition: FileName.cpp:364
~Data()
Destroys the Data object.
Definition: FileName.cpp:816
FileName addExtension(const QString &extension) const
Adds a new extension to the file name.
Definition: FileName.cpp:241
QString name() const
Returns the name of the file excluding the path and the attributes in the file name.
Definition: FileName.cpp:178
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:594
bool isDateVersioned() const
Checks if the file name is versioned by date.
Definition: FileName.cpp:319
QString originalPath() const
Returns the path of the original file name.
Definition: FileName.cpp:100
QString original(bool includeAttributes) const
Returns the original file name, stored in m_originalFileNameString.
Definition: FileName.cpp:833
QString fileNameQDatePattern() const
This changes the files format.
Definition: FileName.cpp:743
QString expanded(bool includeAttributes) const
Returns the expanded file name, stored in m_expandedFileNameString.
Definition: FileName.cpp:928
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition: FileName.cpp:212
QString original() const
Returns the full file name including the file path.
Definition: FileName.cpp:228
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:656
QDir dir() const
Returns the path of the file&#39;s parent directory as a QDir object.
Definition: FileName.cpp:481
This is the reference-counted data for FileName.
Definition: FileName.h:219
FileName & operator=(const FileName &rhs)
Clears the current contents of the FileName object and reinitializes it with the argument.
Definition: FileName.cpp:543
void validateVersioningState() const
This verifies the class invariant when using versioning - that the FileName is in an acceptable state...
Definition: FileName.cpp:695
bool operator!=(const FileName &rhs)
Compares equality of two FileName objects.
Definition: FileName.cpp:584
QString baseName() const
Returns the name of the file without the path and without extensions.
Definition: FileName.cpp:161
QString toString() const
Returns a QString of the full file name including the file path, excluding the attributes with any Is...
Definition: FileName.cpp:531
FileName highestVersion() const
Searches the directory specified in the file name for the highest version of the file name...
Definition: FileName.cpp:329
~FileName()
Destroys the FileName object.
Definition: FileName.cpp:82
FileName setExtension(const QString &extension) const
Sets all current file extensions to a new extension in the file name.
Definition: FileName.cpp:281
FileName()
Constructs an empty FileName object.
Definition: FileName.cpp:47
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
bool operator==(const FileName &rhs)
Compares equality of two FileName objects.
Definition: FileName.cpp:556
QString extension() const
Returns the last extension of the file name.
Definition: FileName.cpp:194
bool isNumericallyVersioned() const
Checks if the file name is versioned numerically.
Definition: FileName.cpp:309
QString attributes() const
Returns a QString of the attributes in a filename, attributes are expected to be of type CubeAttribut...
Definition: FileName.cpp:137
QPair< QString, QString > splitNameAroundVersionNum() const
This returns a QPair of the text (before, after) a version number in a file.
Definition: FileName.cpp:773
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:414
bool fileExists() const
Returns true if the file exists; false otherwise.
Definition: FileName.cpp:465
static FileName createTempFile(FileName templateFileName="$TEMPORARY/temp")
Creates a temporary file and returns a FileName object created using the temporary file...
Definition: FileName.cpp:494
bool isVersioned() const
Checks to see if a file name is versioned by date or numerically.
Definition: FileName.cpp:297
void setOriginal(const QString &originalStr)
Sets the original file name, stored in m_originalFileNameString.
Definition: FileName.cpp:854
FileName removeExtension() const
Removes all extensions in the file name.
Definition: FileName.cpp:262