Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Attributes
Poco::Path Class Reference

#include <Path.h>

List of all members.

Public Types

typedef std::vector< std::string > StringVec
enum  Style {
  PATH_UNIX, PATH_WINDOWS, PATH_VMS, PATH_NATIVE,
  PATH_GUESS
}

Public Member Functions

Path absolute () const
Path absolute (const Path &base) const
Pathappend (const Path &path)
Pathassign (const std::string &path)
 Swaps the path with another one.
Pathassign (const std::string &path, Style style)
 Assigns a string containing a path in native format.
Pathassign (const Path &path)
 Assigns a string containing a path.
Pathassign (const char *path)
 Assigns the given path.
void clear ()
 Returns the file version. VMS only.
int depth () const
 Returns the device name.
const std::string & directory (int n) const
 Returns the number of directories in the directory list.
std::string getBaseName () const
const std::string & getDevice () const
std::string getExtension () const
 Sets the filename extension.
const std::string & getFileName () const
 Sets the filename.
const std::string & getNode () const
bool isAbsolute () const
bool isDirectory () const
 Returns true iff the path is relative.
bool isFile () const
bool isRelative () const
 Returns true iff the path is absolute.
PathmakeAbsolute ()
 Makes the path refer to its parent.
PathmakeAbsolute (const Path &base)
PathmakeDirectory ()
PathmakeFile ()
PathmakeParent ()
Pathoperator= (const Path &path)
 Destroys the Path.
Pathoperator= (const std::string &path)
 Assignment operator.
Pathoperator= (const char *path)
 Assigns a string containing a path in native format.
const std::string & operator[] (int n) const
Path parent () const
 Clears all components.
Pathparse (const std::string &path)
 Returns a string containing the path in the given format.
Pathparse (const std::string &path, Style style)
 Same as assign().
PathparseDirectory (const std::string &path)
PathparseDirectory (const std::string &path, Style style)
 Path ()
 Path (bool absolute)
 Creates an empty relative path.
 Path (const char *path)
 Creates an empty absolute or relative path.
 Path (const char *path, Style style)
 Creates a path from a string.
 Path (const std::string &path)
 Creates a path from a string.
 Path (const std::string &path, Style style)
 Creates a path from a string.
 Path (const Path &path)
 Creates a path from a string.
 Path (const Path &parent, const std::string &fileName)
 Copy constructor.
 Path (const Path &parent, const char *fileName)
 Path (const Path &parent, const Path &relative)
void popDirectory ()
 Adds a directory to the directory list.
void pushDirectory (const std::string &dir)
Pathresolve (const Path &path)
 Appends the given path.
void setBaseName (const std::string &name)
 Returns the filename.
void setDevice (const std::string &device)
 Returns the node name.
void setExtension (const std::string &extension)
void setFileName (const std::string &name)
 Removes the last directory from the directory list.
void setNode (const std::string &node)
void swap (Path &path)
 Assigns a string containing a path in native format.
std::string toString () const
 Assigns a string containing a path.
std::string toString (Style style) const
 Returns a string containing the path in native format.
bool tryParse (const std::string &path)
 Assigns a string containing a path.
bool tryParse (const std::string &path, Style style)
const std::string & version () const
 Returns the filename extension.
 ~Path ()

Static Public Member Functions

static std::string current ()
static std::string expand (const std::string &path)
 Returns the name of the null device.
static bool find (StringVec::const_iterator it, StringVec::const_iterator end, const std::string &name, Path &path)
static bool find (const std::string &pathList, const std::string &name, Path &path)
static Path forDirectory (const std::string &path)
static Path forDirectory (const std::string &path, Style style)
 Creates a path referring to a directory.
static std::string home ()
 Returns the current working directory.
static void listRoots (std::vector< std::string > &roots)
static std::string null ()
 Returns the temporary directory.
static char pathSeparator ()
static char separator ()
 Creates a path referring to a directory.
static std::string temp ()
 Returns the user's home directory.
static std::string transcode (const std::string &path)

Protected Member Functions

std::string buildUnix () const
std::string buildVMS () const
std::string buildWindows () const
void parseGuess (const std::string &path)
void parseUnix (const std::string &path)
void parseVMS (const std::string &path)
void parseWindows (const std::string &path)

Private Attributes

bool _absolute
std::string _device
StringVec _dirs
std::string _name
std::string _node
std::string _version

Detailed Description

This class represents filesystem paths in a platform-independent manner. Unix, Windows and OpenVMS all use a different syntax for filesystem paths. This class can work with all three formats. A path is made up of an optional node name (only Windows and OpenVMS), an optional device name (also only Windows and OpenVMS), a list of directory names and an optional filename.

Definition at line 50 of file Path.h.


Member Typedef Documentation

typedef std::vector<std::string> Poco::Path::StringVec

Definition at line 72 of file Path.h.


Member Enumeration Documentation

Enumerator:
PATH_UNIX 
PATH_WINDOWS 

Unix-style path.

PATH_VMS 

Windows-style path.

PATH_NATIVE 

VMS-style path.

PATH_GUESS 

The current platform's native style.

Guess the style by examining the path

Definition at line 63 of file Path.h.


Constructor & Destructor Documentation

Definition at line 62 of file Path.cpp.

Poco::Path::Path ( bool  absolute)

Creates an empty relative path.

Definition at line 67 of file Path.cpp.

Poco::Path::Path ( const char *  path)

Creates an empty absolute or relative path.

Definition at line 84 of file Path.cpp.

Poco::Path::Path ( const char *  path,
Style  style 
)

Creates a path from a string.

Definition at line 91 of file Path.cpp.

Poco::Path::Path ( const std::string &  path)

Creates a path from a string.

Definition at line 72 of file Path.cpp.

Poco::Path::Path ( const std::string &  path,
Style  style 
)

Creates a path from a string.

Definition at line 78 of file Path.cpp.

Poco::Path::Path ( const Path path)

Creates a path from a string.

Definition at line 98 of file Path.cpp.

Poco::Path::Path ( const Path parent,
const std::string &  fileName 
)

Copy constructor.

Definition at line 109 of file Path.cpp.

Poco::Path::Path ( const Path parent,
const char *  fileName 
)

Creates a path from a parent path and a filename. The parent path is expected to reference a directory.

Definition at line 122 of file Path.cpp.

Poco::Path::Path ( const Path parent,
const Path relative 
)

Creates a path from a parent path and a filename. The parent path is expected to reference a directory.

Definition at line 135 of file Path.cpp.

Creates a path from a parent path and a relative path. The parent path is expected to reference a directory. The relative path is appended to the parent path.

Definition at line 147 of file Path.cpp.


Member Function Documentation

Returns a path referring to the path's directory.

Definition at line 372 of file Path.cpp.

Path Poco::Path::absolute ( const Path base) const

Returns an absolute variant of the path, taking the current working directory as base.

Definition at line 383 of file Path.cpp.

Path & Poco::Path::append ( const Path path)

Makes the path absolute if it is relative. The given path is taken as base.

Definition at line 427 of file Path.cpp.

Path & Poco::Path::assign ( const std::string &  path)

Swaps the path with another one.

Definition at line 197 of file Path.cpp.

Path & Poco::Path::assign ( const std::string &  path,
Style  style 
)

Assigns a string containing a path in native format.

Definition at line 210 of file Path.cpp.

Path & Poco::Path::assign ( const Path path)

Assigns a string containing a path.

Definition at line 182 of file Path.cpp.

Path & Poco::Path::assign ( const char *  path)

Assigns the given path.

Definition at line 236 of file Path.cpp.

std::string Poco::Path::buildUnix ( ) const [protected]

Definition at line 914 of file Path.cpp.

std::string Poco::Path::buildVMS ( ) const [protected]

Definition at line 965 of file Path.cpp.

std::string Poco::Path::buildWindows ( ) const [protected]

Definition at line 937 of file Path.cpp.

Returns the file version. VMS only.

Definition at line 573 of file Path.cpp.

std::string Poco::Path::current ( ) [static]

Returns the platform's path separator, which separates single paths in a list of paths.

On Unix systems, this is the colon ':'. On Windows systems, this is the semicolon ';'. On OpenVMS systems, this is the comma ','.

Definition at line 584 of file Path.cpp.

int Poco::Path::depth ( ) const [inline]

Returns the device name.

Definition at line 433 of file Path.h.

const std::string & Poco::Path::directory ( int  n) const

Returns the number of directories in the directory list.

Definition at line 467 of file Path.cpp.

std::string Poco::Path::expand ( const std::string &  path) [static]

Returns the name of the null device.

Definition at line 608 of file Path.cpp.

bool Poco::Path::find ( StringVec::const_iterator  it,
StringVec::const_iterator  end,
const std::string &  name,
Path path 
) [static]

Fills the vector with all filesystem roots available on the system. On Unix, there is exactly one root, "/". On Windows, the roots are the drive letters. On OpenVMS, the roots are the mounted disks.

Definition at line 620 of file Path.cpp.

bool Poco::Path::find ( const std::string &  pathList,
const std::string &  name,
Path path 
) [static]

Searches the file with the given name in the locations (paths) specified by it and end. A relative path may be given in name.

If the file is found in one of the locations, the complete path of the file is stored in the path given as argument and true is returned. Otherwise false is returned and the path argument remains unchanged.

Definition at line 639 of file Path.cpp.

Path Poco::Path::forDirectory ( const std::string &  path) [inline, static]

Returns an absolute variant of the path, taking the given path as base.

Definition at line 445 of file Path.h.

Path Poco::Path::forDirectory ( const std::string &  path,
Style  style 
) [inline, static]

Creates a path referring to a directory.

Definition at line 452 of file Path.h.

std::string Poco::Path::getBaseName ( ) const

Sets the basename part of the filename and does not change the extension.

Definition at line 542 of file Path.cpp.

const std::string & Poco::Path::getDevice ( ) const [inline]

Sets the device name. Setting a non-empty device automatically makes the path an absolute one.

Definition at line 421 of file Path.h.

std::string Poco::Path::getExtension ( ) const

Sets the filename extension.

Definition at line 563 of file Path.cpp.

const std::string & Poco::Path::getFileName ( ) const [inline]

Sets the filename.

Definition at line 427 of file Path.h.

const std::string & Poco::Path::getNode ( ) const [inline]

Sets the node name. Setting a non-empty node automatically makes the path an absolute one.

Definition at line 415 of file Path.h.

std::string Poco::Path::home ( ) [static]

Returns the current working directory.

Definition at line 590 of file Path.cpp.

bool Poco::Path::isAbsolute ( ) const [inline]

Resolves the given path agains the current one.

If the given path is absolute, it replaces the current one. Otherwise, the relative path is appended to the current path.

Definition at line 379 of file Path.h.

bool Poco::Path::isDirectory ( ) const [inline]

Returns true iff the path is relative.

Definition at line 391 of file Path.h.

bool Poco::Path::isFile ( ) const [inline]

Returns true iff the path references a directory (the filename part is empty).

Definition at line 397 of file Path.h.

bool Poco::Path::isRelative ( ) const [inline]

Returns true iff the path is absolute.

Definition at line 385 of file Path.h.

void Poco::Path::listRoots ( std::vector< std::string > &  roots) [static]

Expands all environment variables contained in the path.

On Unix, a tilde as first character in the path is replaced with the path to user's home directory.

Definition at line 614 of file Path.cpp.

Makes the path refer to its parent.

Definition at line 347 of file Path.cpp.

Path & Poco::Path::makeAbsolute ( const Path base)

Makes the path absolute if it is relative. The current working directory is taken as base directory.

Definition at line 353 of file Path.cpp.

The resulting path always refers to a directory and the filename part is empty.

Definition at line 320 of file Path.cpp.

If the path contains a filename, the filename is appended to the directory list and cleared. Thus the resulting path always refers to a directory.

Definition at line 333 of file Path.cpp.

If the path contains no filename, the last directory becomes the filename.

Definition at line 401 of file Path.cpp.

std::string Poco::Path::null ( ) [static]

Returns the temporary directory.

Definition at line 602 of file Path.cpp.

Path & Poco::Path::operator= ( const Path path)

Destroys the Path.

Definition at line 152 of file Path.cpp.

Path & Poco::Path::operator= ( const std::string &  path)

Assignment operator.

Definition at line 158 of file Path.cpp.

Path & Poco::Path::operator= ( const char *  path)

Assigns a string containing a path in native format.

Definition at line 164 of file Path.cpp.

const std::string & Poco::Path::operator[] ( int  n) const

Returns the n'th directory in the directory list. If n == depth(), returns the filename.

Definition at line 478 of file Path.cpp.

Clears all components.

Definition at line 394 of file Path.cpp.

Path & Poco::Path::parse ( const std::string &  path) [inline]

Returns a string containing the path in the given format.

Definition at line 403 of file Path.h.

Path & Poco::Path::parse ( const std::string &  path,
Style  style 
) [inline]

Same as assign().

Definition at line 409 of file Path.h.

Path & Poco::Path::parseDirectory ( const std::string &  path)

Tries to interpret the given string as a path, according to the given style. If the path is syntactically valid, assigns the path and returns true. Otherwise leaves the object unchanged and returns false.

Definition at line 306 of file Path.cpp.

Path & Poco::Path::parseDirectory ( const std::string &  path,
Style  style 
)

The resulting path always refers to a directory and the filename part is empty.

Definition at line 313 of file Path.cpp.

void Poco::Path::parseGuess ( const std::string &  path) [protected]

Definition at line 859 of file Path.cpp.

void Poco::Path::parseUnix ( const std::string &  path) [protected]

On Windows, if POCO has been compiled with Windows UTF-8 support (POCO_WIN32_UTF8), this function converts a string (usually containing a path) encoded in UTF-8 into a string encoded in the current Windows code page.

This function should be used for every string passed as a file name to a string stream or fopen().

On all other platforms, or if POCO has not been compiled with Windows UTF-8 support, this function returns the string unchanged.

Definition at line 646 of file Path.cpp.

void Poco::Path::parseVMS ( const std::string &  path) [protected]

Definition at line 739 of file Path.cpp.

void Poco::Path::parseWindows ( const std::string &  path) [protected]

Definition at line 693 of file Path.cpp.

char Poco::Path::pathSeparator ( ) [inline, static]

Returns the platform's path name separator, which separates the components (names) in a path.

On Unix systems, this is the slash '/'. On Windows systems, this is the backslash '\'. On OpenVMS systems, this is the period '.'.

Definition at line 471 of file Path.h.

Adds a directory to the directory list.

Definition at line 516 of file Path.cpp.

void Poco::Path::pushDirectory ( const std::string &  dir)

Returns the n'th directory in the directory list. If n == depth(), returns the filename.

Definition at line 489 of file Path.cpp.

Path & Poco::Path::resolve ( const Path path)

Appends the given path.

Definition at line 437 of file Path.cpp.

char Poco::Path::separator ( ) [inline, static]

Creates a path referring to a directory.

Definition at line 459 of file Path.h.

void Poco::Path::setBaseName ( const std::string &  name)

Returns the filename.

Definition at line 530 of file Path.cpp.

void Poco::Path::setDevice ( const std::string &  device)

Returns the node name.

Definition at line 460 of file Path.cpp.

void Poco::Path::setExtension ( const std::string &  extension)

Returns the basename (the filename sans extension) of the path.

Definition at line 552 of file Path.cpp.

void Poco::Path::setFileName ( const std::string &  name)

Removes the last directory from the directory list.

Definition at line 524 of file Path.cpp.

void Poco::Path::setNode ( const std::string &  node)

Returns true iff the path references a file (the filename part is not empty).

Definition at line 453 of file Path.cpp.

void Poco::Path::swap ( Path path)

Assigns a string containing a path in native format.

Definition at line 171 of file Path.cpp.

std::string Poco::Path::temp ( ) [static]

Returns the user's home directory.

Definition at line 596 of file Path.cpp.

std::string Poco::Path::toString ( ) const

Assigns a string containing a path.

Definition at line 242 of file Path.cpp.

std::string Poco::Path::toString ( Style  style) const

Returns a string containing the path in native format.

Definition at line 254 of file Path.cpp.

std::string Poco::Path::transcode ( const std::string &  path) [static]

Searches the file with the given name in the locations (paths) specified in pathList. The paths in pathList must be delimited by the platform's path separator (see pathSeparator()). A relative path may be given in name.

If the file is found in one of the locations, the complete path of the file is stored in the path given as argument and true is returned. Otherwise false is returned and the path argument remains unchanged.

Definition at line 1004 of file Path.cpp.

bool Poco::Path::tryParse ( const std::string &  path)

Assigns a string containing a path.

Definition at line 274 of file Path.cpp.

bool Poco::Path::tryParse ( const std::string &  path,
Style  style 
)

Tries to interpret the given string as a path in native format. If the path is syntactically valid, assigns the path and returns true. Otherwise leaves the object unchanged and returns false.

Definition at line 290 of file Path.cpp.

const std::string & Poco::Path::version ( ) const [inline]

Returns the filename extension.

Definition at line 439 of file Path.h.


Member Data Documentation

bool Poco::Path::_absolute [private]

Definition at line 372 of file Path.h.

std::string Poco::Path::_device [private]

Definition at line 368 of file Path.h.

Definition at line 371 of file Path.h.

std::string Poco::Path::_name [private]

Definition at line 369 of file Path.h.

std::string Poco::Path::_node [private]

Definition at line 367 of file Path.h.

std::string Poco::Path::_version [private]

Definition at line 370 of file Path.h.


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


pluginlib
Author(s): Tully Foote and Eitan Marder-Eppstein
autogenerated on Sat Dec 28 2013 17:20:20