The Micro C++ Library
micxx::Filename Class Reference

A Filename class represents a file or directory name within a filesystem. More...

#include <micxx.hxx>

Inherits micxx::traits::ToString.

List of all members.

Public Member Functions

 Filename ()
 Same as Filename(L".").
 Filename (const std::wstring &name, const Filename *parent=0)
 Create a new Filename from a filename aname and an optional parent.
 Filename (const std::string &name, const Filename *parent=0)
 Same as Filename(Strings::convert(name), parent).
 Filename (const std::string &name, const Filename &parent)
 Same as Filename(Strings::convert(name), &parent).
 Filename (const std::wstring &name, const Filename &parent)
 Same as Filename(name, &parent).
virtual ~Filename ()
 Delete the parent Filename (if not 0).
virtual void clear ()
 Resets the Filename to ".".
virtual bool exists () const
 Test whether the file or directory denoted by this Filename exist.
virtual const std::wstringgetAbsoluteName () const
 The absolute pathname string of this Filename.
virtual const std::wstringgetBasename () const
 The filename part of this Filename without any directory or path part and without any optional extension part.
virtual const std::wstringgetExtension () const
 The extension part of this Filename.
virtual const std::wstringgetName () const
 The filename part of this Filename without any directory or path part but with any optional extension part.
virtual Filename getParent () const
 The parent of this Filename denoting the directory or path part of this Filename.
virtual bool isAbsolute () const
 Test whether this Filename denotes an absolute pathname.
virtual bool isDirectory () const
 Test whether this Filename denotes a directory.
virtual void list (std::vector< std::wstring > &files) const
 if this filename represents a directory, it returns a list of all filenames from the directory (without any parent directory information).
virtual bool matches (const std::string &wildcard, bool caseless=true) const
 Test whether getName() match the wildcard expression wildcard.
virtual bool matches (const std::wstring &wildcard, bool caseless=true) const
 Same as matches(Strings::convert(wildcard), caseless).
virtual Filenameoperator= (const std::string &right)
 Overwrites this Filename object with right.
virtual Filenameoperator= (const std::wstring &right)
 Overwrites this Filename object with right.
virtual bool operator< (const Filename &right) const
virtual void setName (const std::string &name)
 Overwrites the name of this Filename object with name.
virtual void setName (const std::wstring &name)
 Overwrites the name of this Filename object with name.
virtual void setParent (const Filename &parent)
 Overwrites the parent of this Filename object with parent.
virtual void setParent (const std::string &parent)
 Overwrites the parent of this Filename object with parent.
virtual void setParent (const std::wstring &parent)
 Overwrites the parent of this Filename object with parent.
virtual bool startWith (const std::wstring &prefix, bool caseless=true) const
virtual std::string toString () const
 Return a string representation.

Static Public Attributes

static const wchar_t SEPARATOR_CHAR
 Depending on the platform either '/' or '\'.
static const std::wstring SEPARATOR
 Depending on the platform either "/" or "\".
static const wchar_t PATH_SEPARATOR_CHAR
 Depending on the platform either ':' or ';'.
static const std::wstring PATH_SEPARATOR
 Depending on the platform either ":" or ";".
static const std::wstring CURR_DIRECTORY
 Typically ".".
static const std::wstring PARENT_DIRECTORY
 Typically "..".

Detailed Description

A Filename class represents a file or directory name within a filesystem.

A specific Filename instance will always represent only the name of a file without any path information or only the last path entry of a directory. The path to the file, or the parent path to the directory will be represented by the parent property.

Note:
Although Filename is derived from Mutex, itself does no locking at all. If you intend to use Filename concurrently from different threads, you could use the inherited Mutex to synchronize access to the instance (depending on the scenario in which it is used).
Author:
Norbert Klose
Date:
December, 2006

Constructor & Destructor Documentation

micxx::Filename::Filename ( )

Same as Filename(L".").

micxx::Filename::Filename ( const std::wstring name,
const Filename parent = 0 
)

Create a new Filename from a filename aname and an optional parent.

Parameters:
nameThe filename name is first separated into a directory or path part and a filename part without any directory or path part. This last part is used as the filename for this Filename.
parentIf present, parent is used as the parent for the filename part of name. Otherwise, the parent is derived from the directory or path part of name.
micxx::Filename::Filename ( const std::string &  name,
const Filename parent = 0 
)
micxx::Filename::Filename ( const std::string &  name,
const Filename parent 
)
micxx::Filename::Filename ( const std::wstring name,
const Filename parent 
)
virtual micxx::Filename::~Filename ( ) [virtual]

Delete the parent Filename (if not 0).


Member Function Documentation

virtual void micxx::Filename::clear ( ) [virtual]

Resets the Filename to ".".

virtual bool micxx::Filename::exists ( ) const [virtual]

Test whether the file or directory denoted by this Filename exist.

virtual const std::wstring& micxx::Filename::getAbsoluteName ( ) const [virtual]

The absolute pathname string of this Filename.

virtual const std::wstring& micxx::Filename::getBasename ( ) const [inline, virtual]

The filename part of this Filename without any directory or path part and without any optional extension part.

    {
        return basename;
    }
virtual const std::wstring& micxx::Filename::getExtension ( ) const [inline, virtual]

The extension part of this Filename.

    {
        return extension;
    }
virtual const std::wstring& micxx::Filename::getName ( ) const [inline, virtual]

The filename part of this Filename without any directory or path part but with any optional extension part.

    {
        return name;
    }
virtual Filename micxx::Filename::getParent ( ) const [virtual]

The parent of this Filename denoting the directory or path part of this Filename.

virtual bool micxx::Filename::isAbsolute ( ) const [virtual]

Test whether this Filename denotes an absolute pathname.

If false, the absolute pathname is constructed using the absolute pathname for the current working directory as prefix.

virtual bool micxx::Filename::isDirectory ( ) const [virtual]

Test whether this Filename denotes a directory.

virtual void micxx::Filename::list ( std::vector< std::wstring > &  files) const [virtual]

if this filename represents a directory, it returns a list of all filenames from the directory (without any parent directory information).

virtual bool micxx::Filename::matches ( const std::string &  wildcard,
bool  caseless = true 
) const [virtual]

Test whether getName() match the wildcard expression wildcard.

virtual bool micxx::Filename::matches ( const std::wstring wildcard,
bool  caseless = true 
) const [virtual]
virtual bool micxx::Filename::operator< ( const Filename right) const [virtual]
virtual Filename& micxx::Filename::operator= ( const std::wstring right) [virtual]

Overwrites this Filename object with right.

virtual Filename& micxx::Filename::operator= ( const std::string &  right) [virtual]

Overwrites this Filename object with right.

virtual void micxx::Filename::setName ( const std::string &  name) [virtual]

Overwrites the name of this Filename object with name.

virtual void micxx::Filename::setName ( const std::wstring name) [virtual]

Overwrites the name of this Filename object with name.

virtual void micxx::Filename::setParent ( const Filename parent) [virtual]

Overwrites the parent of this Filename object with parent.

virtual void micxx::Filename::setParent ( const std::wstring parent) [virtual]

Overwrites the parent of this Filename object with parent.

virtual void micxx::Filename::setParent ( const std::string &  parent) [virtual]

Overwrites the parent of this Filename object with parent.

virtual bool micxx::Filename::startWith ( const std::wstring prefix,
bool  caseless = true 
) const [virtual]
virtual std::string micxx::Filename::toString ( ) const [virtual]

Return a string representation.

Reimplemented from micxx::traits::ToString.


Member Data Documentation

Typically ".".

Typically "..".

Depending on the platform either ":" or ";".

const wchar_t micxx::Filename::PATH_SEPARATOR_CHAR [static]

Depending on the platform either ':' or ';'.

Depending on the platform either "/" or "\".

const wchar_t micxx::Filename::SEPARATOR_CHAR [static]

Depending on the platform either '/' or '\'.


The documentation for this class was generated from the following file: