COOLFluiD  Release kernel
COOLFluiD is a Collaborative Simulation Environment (CSE) focused on complex MultiPhysics simulations.
Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
URI Class Reference

#include <URI.hpp>

Classes

class  Scheme
 

Public Member Functions

 URI ()
 Empty constructor. More...
 
 URI (const URI &path)
 
 URI (const std::string &s)
 
 URI (const char *c)
 
 URI (const std::string &s, URI::Scheme::Type p)
 
bool operator== (const URI &right) const
 comparison operator More...
 
bool operator!= (const URI &right) const
 
URIoperator= (const URI &p)
 assignement operator with URI More...
 
URIoperator/= (const URI &rhs)
 concatenation and assignement operator with URI More...
 
URIoperator/= (const std::string &s)
 concatenation and assignement operator with std::string More...
 
URIoperator/= (const char *c)
 concatenation and assignement operator with C string More...
 
URI operator/ (const URI &p) const
 concatenation operator with URI More...
 
bool is_absolute () const
 
bool is_relative () const
 
bool is_complete () const
 
bool empty () const
 
std::string string () const
 
URI base_path () const
 
std::string name () const
 
Scheme::Type scheme () const
 
void scheme (Scheme::Type)
 
std::string path () const
 
void path (const std::string &path)
 
std::string extension () const
 Extension of a filename. More...
 
std::string base_name () const
 Filename without extension. More...
 

Static Public Member Functions

static bool is_valid_element (const std::string &str)
 check that the passed string is a valid path element More...
 
static const std::string separator ()
 separator for path tokens More...
 
static void split_path (const std::string &path, URI::Scheme::Type &protocol, std::string &real_path)
 

Private Member Functions

void cleanup ()
 Cleans up the stored string, i.e. remove multiple / in sequence, ... More...
 

Private Attributes

std::string m_path
 path string More...
 
Scheme::Type m_scheme
 Current URI protocol. More...
 

Friends

std::ostream & operator<< (std::ostream &os, const URI::Scheme::Type &in)
 
std::istream & operator>> (std::istream &is, URI::Scheme::Type &in)
 
std::ostream & operator<< (std::ostream &out, const URI &path)
 
std::istream & operator>> (std::istream &in, URI &path)
 

Detailed Description

Uniform Resource Identifier (see http://en.wikipedia.org/wiki/Uniform_Resource_Identifier) Used to describe a component path (cpath://), a file path (file://, or a URL (http://, https://)

Author
Willem Deconinck

Definition at line 39 of file URI.hpp.

Constructor & Destructor Documentation

URI ( )

Empty constructor.

Definition at line 89 of file URI.cpp.

URI ( const URI path)

Copy constructor from other path object

Parameters
pathobject

Definition at line 95 of file URI.cpp.

URI ( const std::string &  s)

Constructor from string object

Parameters
sstring with path

Definition at line 100 of file URI.cpp.

URI ( const char *  c)

Constructor from const char*

Parameters
cC string with path

Definition at line 108 of file URI.cpp.

URI ( const std::string &  s,
URI::Scheme::Type  p 
)

Constructor from string object and separate protocol

Precondition
assumes that string does not have a protocol, just the path
Parameters
sstring with path
pscheme type e.g. (HTTP,CPATH,FILE)
Todo:
check path

Definition at line 117 of file URI.cpp.

Member Function Documentation

std::string base_name ( ) const

Filename without extension.

Definition at line 300 of file URI.cpp.

URI base_path ( ) const
Returns
the base path

Definition at line 199 of file URI.cpp.

void cleanup ( )
private

Cleans up the stored string, i.e. remove multiple / in sequence, ...

Definition at line 306 of file URI.cpp.

bool empty ( ) const
inline
Returns
if the path is empty

Definition at line 137 of file URI.hpp.

std::string extension ( ) const

Extension of a filename.

Definition at line 294 of file URI.cpp.

bool is_absolute ( ) const

Check if path is absolute. Should start with "//"

Returns
true if the path is absolute

Definition at line 194 of file URI.cpp.

bool is_complete ( ) const

check this path is complete

Postcondition
true if does not contain ".." or "."

Definition at line 174 of file URI.cpp.

bool is_relative ( ) const

Check is path is relative. Should not start with "//"

Returns
true if the path is a relative path

Definition at line 189 of file URI.cpp.

bool is_valid_element ( const std::string &  str)
static

check that the passed string is a valid path element

Definition at line 181 of file URI.cpp.

std::string name ( ) const
Returns
the name of the object, without the path

Definition at line 221 of file URI.cpp.

bool operator!= ( const URI right) const

Definition at line 131 of file URI.cpp.

URI operator/ ( const URI p) const

concatenation operator with URI

Definition at line 159 of file URI.cpp.

URI & operator/= ( const URI rhs)

concatenation and assignement operator with URI

Definition at line 137 of file URI.cpp.

URI & operator/= ( const std::string &  s)

concatenation and assignement operator with std::string

Definition at line 145 of file URI.cpp.

URI & operator/= ( const char *  c)

concatenation and assignement operator with C string

Definition at line 153 of file URI.cpp.

URI & operator= ( const URI p)

assignement operator with URI

Definition at line 166 of file URI.cpp.

bool operator== ( const URI right) const

comparison operator

Definition at line 126 of file URI.cpp.

std::string path ( ) const

Gives the URI path, which is the URI without the scheme (protocol)

Returns
Returns the URI path

Definition at line 253 of file URI.cpp.

void path ( const std::string &  path)

Changes the URI path

Postcondition
path() will return the supplied path

Definition at line 242 of file URI.cpp.

URI::Scheme::Type scheme ( ) const

Gives the protocol (if any).

Returns
Returns the protocol. May return URI::Protocol::INVALID if no protocol has been specified.

Definition at line 248 of file URI.cpp.

void scheme ( Scheme::Type  sch)

Changes the protocol to the supplied scheme

Postcondition
scheme() will return the supplied protocol

Definition at line 237 of file URI.cpp.

const std::string separator ( )
static

separator for path tokens

Definition at line 232 of file URI.cpp.

void split_path ( const std::string &  path,
URI::Scheme::Type protocol,
std::string &  real_path 
)
static

Splits a given path into the URI protocol and the real path.

Parameters
pathPath to split.
protocolVariable where to store the found protocol. The value is set to URI::Protocol::INVALID if no protocol found.
real_pathVariable where to store the path.
Exceptions
ProtocolErrorIf a an unknown protocol is found.

Definition at line 267 of file URI.cpp.

std::string string ( ) const
Returns
the full URI as a string

Definition at line 258 of file URI.cpp.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const URI::Scheme::Type in 
)
friend

Definition at line 59 of file URI.cpp.

std::ostream& operator<< ( std::ostream &  out,
const URI path 
)
friend

Overloading of the stream operator "<<" for the output. No "\n"ine introduced.

Parameters
[in]outthe out stream
[in]paththe path to output
Returns
the out stream

Definition at line 73 of file URI.cpp.

std::istream& operator>> ( std::istream &  is,
URI::Scheme::Type in 
)
friend

Definition at line 65 of file URI.cpp.

std::istream& operator>> ( std::istream &  in,
URI path 
)
friend

Overloading of the stream operator ">>" for the input

Parameters
[in]inthe in stream
[out]paththe path to read
Returns
the in stream

Definition at line 79 of file URI.cpp.

Member Data Documentation

std::string m_path
private

path string

Definition at line 198 of file URI.hpp.

Scheme::Type m_scheme
private

Current URI protocol.

Definition at line 200 of file URI.hpp.


The documentation for this class was generated from the following files:
Send comments to:
COOLFluiD Web Admin