ADTF
filename.h
Go to the documentation of this file.
1 
7 #ifndef _FILENAME_CLASS_HEADER_
8 #define _FILENAME_CLASS_HEADER_
9 
10 
11 namespace A_UTILS_NS
12 {
13 
58 class DOEXPORT cFilename : public cString
59 {
61 
62  public:
64  static constexpr const tChar WINDOWS_SLASH = '\\';
66  static constexpr const tChar UNIX_SLASH = '/';
67 
69  static constexpr const tChar* const WINDOWS_DOUBLE_SLASH = "\\\\";
71  static constexpr const tChar* const UNIX_DOUBLE_SLASH = "//";
72 #ifdef WIN32
74  static constexpr const tChar NATIVE_SLASH = WINDOWS_SLASH;
76  static constexpr const tChar ALTERNATIVE_SLASH = UNIX_SLASH;
77 
79  static constexpr const tChar* const NATIVE_DOUBLE_SLASH = WINDOWS_DOUBLE_SLASH;
81  static constexpr const tChar* const ALTERNATIVE_DOUBLE_SLASH = UNIX_DOUBLE_SLASH;
82 #else
84  static constexpr const tChar NATIVE_SLASH = UNIX_SLASH;
86  static constexpr const tChar ALTERNATIVE_SLASH = WINDOWS_SLASH;
87 
89  static constexpr const tChar* const NATIVE_DOUBLE_SLASH = UNIX_DOUBLE_SLASH;
91  static constexpr const tChar* const ALTERNATIVE_DOUBLE_SLASH = WINDOWS_DOUBLE_SLASH;
92 #endif // WIN32
93  static const cFilename Empty;
94 
101 
110  cFilename(const cFilename& oFilename);
111 
116  cFilename& operator=(const cFilename& i_oOther);
117 
126  cFilename(const cString& strString);
127 
136  cFilename(const tChar* pString);
137 
145  cFilename(char cChar);
146 
151  cFilename(cFilename&& i_oOther);
152 
163  virtual ~cFilename();
164 
174 
183  cFilename& operator=(const tChar* pString);
184 
193  cFilename& operator=(const cString& sString);
194 
204 
215 
224  cString GetName() const;
225 
236 
246 
255  cString GetDrive() const;
256 
265 
274  cFilename& SetExtension(const cString& strExtension);
275 
283 
291 
299 
307 
315 
325  cFilename CreateRelativePath(const cFilename &strParent) const;
326 
337  cFilename CreateAbsolutePath(const cFilename &strParent) const;
338 
348  tBool IsRelative() const;
349 
359  tBool IsAbsolute() const;
360 
371  cFilename& AppendPath(const cFilename& strPath);
372 
382 
392 
404  static cFilename JoinPath(const cFilename& strPath1, const cFilename& strPath2);
405 
416  static tBool IsSlash(tChar c);
417 
418 };
419 
424 class DOEXPORT cFilepath : public cFilename
425 {
426 public:
427  template<typename... T> cFilepath(T... args) : cFilename(args...)
428  {
429  }
430  cFilepath(const cFilepath& oFilepath) : cFilename(oFilepath)
431  {
432  }
433  cFilepath& operator=(cFilepath&& oFilepath)
434  {
435  cFilename::operator=(oFilepath); return *this;
436  }
437  cFilepath& operator=(const cFilepath& oFilepath)
438  {
439  cFilename::operator=(oFilepath); return *this;
440  }
441 };
442 
443 using DOEXPORT cFilenameList = std::list<cFilename>;
444 using DOEXPORT cFilepathList = std::list<cFilepath>;
445 
446 } // namespace A_UTILS_NS
447 
448 #endif // _FILENAME_CLASS_HEADER_
char tChar
The tChar defines the type for platform character set (platform and compiler dependent type).
void tVoid
The tVoid is always the definition for the void (non-type).
bool tBool
The tBool defines the type for the Values tTrue and tFalse (platform and compiler dependent).
File name class.
Definition: filename.h:59
cString GetDrive() const
This function extracts the drive name of a filename (e.g.
cFilename()
Constructor that initializes an empty cFilename object.
cFilename CreateRelativePath(const cFilename &strParent) const
This function creates a relative path for this file regarding the given parent (Only works with nativ...
cFilename & operator=(const cFilename &i_oOther)
Copy assignment operator.
tBool IsAbsolute() const
This function checks the filename if it is absolute.
cFilename & operator=(cFilename &&i_oOther)
Implements move assignment.
cFilename & MakeForwardSlashes()
This function changes all backslashes to forward slashes.
cFilename(const cString &strString)
Constructor that initializes the filename with an existing cString object.
cFilename & AppendPath(const cFilename &strPath)
Append a path string to current string.
cFilename & AppendTrailingSlash()
This function appends a trailing slash to the filename if there isn't one, yet.
cFilename(cFilename &&i_oOther)
Implements move construction.
static tBool IsSlash(tChar c)
This function checks if a character is a slash.
cFilename & operator=(tChar cChar)
assigns a given string
cFilename & MakeBackwardSlashes()
This function changes all forward slashes to backslashes.
cFilename & SetExtension(const cString &strExtension)
This function changes the extension of a filename.
tBool IsRelative() const
This function checks the filename if it is relative.
cFilename & RemoveTrailingSlash()
This function removes a trailing slash from the filename if there is one.
cFilename GetRoot() const
This function extract the root component of a filename (without double point).
cFilename(const cFilename &oFilename)
Constructor that initializes the object with an existing cFilename object.
cString GetName() const
This function extracts the name component of a filename.
tVoid SplitPath(cStringList &List) const
Split path into a string list.
cFilename & operator=(const tChar *pString)
assigns a given string
cFilename GetPath() const
This function extract the path of the parent folder and/or the root component of a file/folder.
cFilename(const tChar *pString)
Constructor that initializes the filename with a null-terminated string.
virtual ~cFilename()
Destructor.
tChar GetDriveLetter() const
cFilename & operator=(const cString &sString)
assigns a given string
cFilename CreateAbsolutePath(const cFilename &strParent) const
This function creates an absolute path for this file regarding the given parent (Only works with nati...
cString GetNameWithoutExtension() const
This function extract the name component of a filename.
static cFilename JoinPath(const cFilename &strPath1, const cFilename &strPath2)
This function joins two subpaths (strPath1 and strPath2) to a new one.
cFilename(char cChar)
Constructor that initializes the filename with a single character.
cFilename & MakeNativeSlashes()
This function changes all slashes to OS specific slashes.
cString GetExtension() const
This function extract the extension of a filename.
cFilename & CleanPath()
This function resolves relative components ("." or "..") within an absolute path.
File Path type.
Definition: filename.h:425
#define A_UTILS_D(__pclassname_)
Helper macro for d-pattern definitions.
Definition: d_ptr.h:270
ADTF A_UTIL Namespace - Within adtf this is used as adtf::util or adtf_util.
Definition: d_ptr.h:11