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 &base) const
Path absolute () const
Pathappend (const Path &path)
Pathassign (const char *path)
 Assigns the given path.
Pathassign (const Path &path)
 Assigns a string containing a path.
Pathassign (const std::string &path, Style style)
 Assigns a string containing a path in native format.
Pathassign (const std::string &path)
 Swaps the path with another one.
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 (const Path &base)
PathmakeAbsolute ()
 Makes the path refer to its parent.
PathmakeDirectory ()
PathmakeFile ()
PathmakeParent ()
Pathoperator= (const char *path)
 Assigns a string containing a path in native format.
Pathoperator= (const std::string &path)
 Assignment operator.
Pathoperator= (const Path &path)
 Destroys the Path.
const std::string & operator[] (int n) const
Path parent () const
 Clears all components.
Pathparse (const std::string &path, Style style)
 Same as assign().
Pathparse (const std::string &path)
 Returns a string containing the path in the given format.
PathparseDirectory (const std::string &path, Style style)
PathparseDirectory (const std::string &path)
 Path (const Path &parent, const Path &relative)
 Path (const Path &parent, const char *fileName)
 Path (const Path &parent, const std::string &fileName)
 Copy constructor.
 Path (const Path &path)
 Creates a path from a string.
 Path (const std::string &path, Style style)
 Creates a path from a string.
 Path (const std::string &path)
 Creates a path from a string.
 Path (const char *path, Style style)
 Creates a path from a string.
 Path (const char *path)
 Creates an empty absolute or relative path.
 Path (bool absolute)
 Creates an empty relative path.
 Path ()
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 (Style style) const
 Returns a string containing the path in native format.
std::string toString () const
 Assigns a string containing a path.
bool tryParse (const std::string &path, Style style)
bool tryParse (const std::string &path)
 Assigns a string containing a path.
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 (const std::string &pathList, const std::string &name, Path &path)
static bool find (StringVec::const_iterator it, StringVec::const_iterator end, const std::string &name, Path &path)
static Path forDirectory (const std::string &path, Style style)
 Creates a path referring to a directory.
static Path forDirectory (const std::string &path)
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

Poco::Path::Path (  ) 

Definition at line 44 of file Path.cpp.

Poco::Path::Path ( bool  absolute  ) 

Creates an empty relative path.

Definition at line 49 of file Path.cpp.

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

Creates an empty absolute or relative path.

Definition at line 66 of file Path.cpp.

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

Creates a path from a string.

Definition at line 73 of file Path.cpp.

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

Creates a path from a string.

Definition at line 54 of file Path.cpp.

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

Creates a path from a string.

Definition at line 60 of file Path.cpp.

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

Creates a path from a string.

Definition at line 80 of file Path.cpp.

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

Copy constructor.

Definition at line 91 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 104 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 117 of file Path.cpp.

Poco::Path::~Path (  ) 

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 129 of file Path.cpp.


Member Function Documentation

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 365 of file Path.cpp.

Path Poco::Path::absolute (  )  const

Returns a path referring to the path's directory.

Definition at line 354 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 409 of file Path.cpp.

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

Assigns the given path.

Definition at line 218 of file Path.cpp.

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

Assigns a string containing a path.

Definition at line 164 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 192 of file Path.cpp.

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

Swaps the path with another one.

Definition at line 179 of file Path.cpp.

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

Definition at line 896 of file Path.cpp.

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

Definition at line 947 of file Path.cpp.

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

Definition at line 919 of file Path.cpp.

void Poco::Path::clear (  ) 

Returns the file version. VMS only.

Definition at line 555 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 566 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 449 of file Path.cpp.

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

Returns the name of the null device.

Definition at line 590 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 621 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 602 of file Path.cpp.

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.

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.

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

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

Definition at line 524 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 545 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 572 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 596 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 335 of file Path.cpp.

Path & Poco::Path::makeAbsolute (  ) 

Makes the path refer to its parent.

Definition at line 329 of file Path.cpp.

Path & Poco::Path::makeDirectory (  ) 

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

Definition at line 302 of file Path.cpp.

Path & Poco::Path::makeFile (  ) 

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 315 of file Path.cpp.

Path & Poco::Path::makeParent (  ) 

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

Definition at line 383 of file Path.cpp.

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

Returns the temporary directory.

Definition at line 584 of file Path.cpp.

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

Assigns a string containing a path in native format.

Definition at line 146 of file Path.cpp.

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

Assignment operator.

Definition at line 140 of file Path.cpp.

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

Destroys the Path.

Definition at line 134 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 460 of file Path.cpp.

Path Poco::Path::parent (  )  const

Clears all components.

Definition at line 376 of file Path.cpp.

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::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::parseDirectory ( const std::string &  path,
Style  style 
)

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

Definition at line 295 of file Path.cpp.

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 288 of file Path.cpp.

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

Definition at line 841 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 628 of file Path.cpp.

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

Definition at line 721 of file Path.cpp.

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

Definition at line 675 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.

void Poco::Path::popDirectory (  ) 

Adds a directory to the directory list.

Definition at line 498 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 471 of file Path.cpp.

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

Appends the given path.

Definition at line 419 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 512 of file Path.cpp.

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

Returns the node name.

Definition at line 442 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 534 of file Path.cpp.

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

Removes the last directory from the directory list.

Definition at line 506 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 435 of file Path.cpp.

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

Assigns a string containing a path in native format.

Definition at line 153 of file Path.cpp.

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

Returns the user's home directory.

Definition at line 578 of file Path.cpp.

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

Returns a string containing the path in native format.

Definition at line 236 of file Path.cpp.

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

Assigns a string containing a path.

Definition at line 224 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 986 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 272 of file Path.cpp.

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

Assigns a string containing a path.

Definition at line 256 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:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines


pluginlib
Author(s): Tully Foote and Eitan Marder-Eppstein
autogenerated on Fri Jan 11 11:39:02 2013