• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kviewshell

GURL Class Reference

System independent URL representation. More...

#include <GURL.h>

Inheritance diagram for GURL:

Inheritance graph
[legend]

List of all members.


Classes

class  Filename
class  Native
class  UTF8

Public Member Functions

void add_djvu_cgi_argument (const GUTF8String &name, const char *value=0)
GURL base (void) const
int cgi_arguments (void) const
GUTF8String cgi_name (int num) const
DArray< GUTF8String > cgi_names (void) const
GUTF8String cgi_value (int num) const
DArray< GUTF8String > cgi_values (void) const
void clear_all_arguments (void)
void clear_cgi_arguments (void)
void clear_djvu_cgi_arguments (void)
void clear_hash_argument (void)
int cleardir (const int timeout=0) const
int deletefile (void) const
int djvu_cgi_arguments (void) const
GUTF8String djvu_cgi_name (int num) const
DArray< GUTF8String > djvu_cgi_names (void) const
GUTF8String djvu_cgi_value (int num) const
DArray< GUTF8String > djvu_cgi_values (void) const
GUTF8String extension (void) const
GUTF8String fname (void) const
GURL follow_symlinks (void) const
GUTF8String get_string (const bool nothrow=false) const
GUTF8String get_string (const GUTF8String &useragent) const
 GURL (const GURL &gurl)
 GURL (const GNativeString &xurl, const GURL &codebase)
 GURL (const GUTF8String &xurl, const GURL &codebase)
 GURL (const GNativeString &url_string)
 GURL (const GUTF8String &url_string)
 GURL (void)
GUTF8String hash_argument (void) const
bool is_dir (void) const
bool is_file (void) const
bool is_local_file_url (void) const
bool is_local_path (void) const
GList< GURL > listdir (void) const
int mkdir (void) const
GUTF8String name (void) const
GNativeString NativeFilename (void) const
 operator const char * (void) const
GURL & operator= (const GURL &url)
bool operator== (const GURL &gurl2) const
GUTF8String pathname (void) const
int renameto (const GURL &newurl) const
void set_hash_argument (const GUTF8String &arg)
GUTF8String UTF8Filename (void) const
virtual ~GURL (void)
GURL.h
Files #"GURL.h"# and #"GURL.cpp"# contain the implementation of the {GURL} class used to store URLs in a system independent format.

System independent URL representation.

Author:
Andrei Erofeev <eaf@geocities.com>
From: Leon Bottou, 1/31/2002 This has been heavily changed by Lizardtech. They decided to use URLs for everyting, including the most basic file access. The URL class now is a unholy mixture of code for syntactically parsing the urls (which is was) and file status code (only for local file: urls).

Version:
$Id: GURL.h,v 1.9 2003/11/07 22:08:21 leonb Exp $#


bool is_empty (void) const
bool is_valid (void) const
bool operator!= (const GURL &gurl2) const
GUTF8String protocol (void) const

Static Public Member Functions

static GUTF8String decode_reserved (const GUTF8String &url)
static GUTF8String encode_reserved (const GUTF8String &gs)
static GUTF8String expand_name (const GUTF8String &filename, const char *fromdirname=0)

Protected Member Functions

void beautify_path (void)
void convert_slashes (void)
void init (const bool nothrow=false)
void parse_cgi_args (void)
void store_cgi_args (void)
Constructors
Accept the string URL, check that it starts from file:/# or http:/# and convert to internal system independent representation.

 GURL (const char *url_string)

Static Protected Member Functions

static GUTF8String beautify_path (GUTF8String url)
static GUTF8String protocol (const GUTF8String &url)

Protected Attributes

DArray< GUTF8String > cgi_name_arr
DArray< GUTF8String > cgi_value_arr
GUTF8String url
bool validurl

Friends

unsigned int hash (const GURL &gurl)

Detailed Description

System independent URL representation.

This class is used in the library to store URLs in a system independent format. The idea to use a general class to hold URL arose after we realized, that DjVu had to be able to access files both from the WEB and from the local disk. While it is strange to talk about system independence of HTTP URLs, file names formats obviously differ from platform to platform. They may contain forward slashes, backward slashes, colons as separators, etc. There maybe more than one URL corresponding to the same file name. Compare file:/dir/file.djvu# and file://localhost/dir/file.djvu#.

To simplify a developer's life we have created this class, which contains inside a canonical representation of URLs.

File URLs are converted to internal format with the help of {GOS} class.

All other URLs are modified to contain only forward slashes.

Definition at line 117 of file GURL.h.


Constructor & Destructor Documentation

GURL::GURL ( const char *  url_string  )  [protected]

Definition at line 429 of file GURL.cpp.

GURL::GURL ( void   ) 

Definition at line 424 of file GURL.cpp.

GURL::GURL ( const GUTF8String &  url_string  ) 

Definition at line 434 of file GURL.cpp.

GURL::GURL ( const GNativeString &  url_string  ) 

Definition at line 439 of file GURL.cpp.

GURL::GURL ( const GUTF8String &  xurl,
const GURL &  codebase 
)

Definition at line 1201 of file GURL.cpp.

GURL::GURL ( const GNativeString &  xurl,
const GURL &  codebase 
)

Definition at line 1231 of file GURL.cpp.

GURL::GURL ( const GURL &  gurl  ) 

Copy constructor.

Definition at line 452 of file GURL.cpp.

virtual GURL::~GURL ( void   )  [inline, virtual]

The destructor.

Definition at line 149 of file GURL.h.


Member Function Documentation

void GURL::add_djvu_cgi_argument ( const GUTF8String &  name,
const char *  value = 0 
)

Appends the specified CGI argument.

Will insert "#DJVUOPTS#" if necessary

Definition at line 859 of file GURL.cpp.

GURL GURL::base ( void   )  const

Returns the URL corresponding to the directory containing the document with this URL.

The function basically takes the URL and clears everything after the last slash.

Definition at line 927 of file GURL.cpp.

GUTF8String GURL::beautify_path ( GUTF8String  url  )  [static, protected]

Definition at line 257 of file GURL.cpp.

void GURL::beautify_path ( void   )  [protected]

Definition at line 359 of file GURL.cpp.

int GURL::cgi_arguments ( void   )  const

Returns the total number of CGI arguments in the URL.

CGI arguments follow '#?#' sign and are separated by '#&#' signs

Definition at line 633 of file GURL.cpp.

GUTF8String GURL::cgi_name ( int  num  )  const

Returns that part of CGI argument number num#, which is before the equal sign.

Definition at line 660 of file GURL.cpp.

DArray< GUTF8String > GURL::cgi_names ( void   )  const

Returns array of all known CGI names (part of CGI argument before the equal sign).

Definition at line 722 of file GURL.cpp.

GUTF8String GURL::cgi_value ( int  num  )  const

Returns that part of CGI argument number num#, which is after the equal sign.

Definition at line 689 of file GURL.cpp.

DArray< GUTF8String > GURL::cgi_values ( void   )  const

Returns array of all known CGI names (part of CGI argument before the equal sign).

Definition at line 730 of file GURL.cpp.

void GURL::clear_all_arguments ( void   ) 

Erases everything after the first '#' or '?'.

Definition at line 784 of file GURL.cpp.

void GURL::clear_cgi_arguments ( void   ) 

Erases all CGI arguments (following the first '?').

Definition at line 819 of file GURL.cpp.

void GURL::clear_djvu_cgi_arguments ( void   ) 

Erases DjVu CGI arguments (following "#DJVUOPTS#").

Definition at line 839 of file GURL.cpp.

void GURL::clear_hash_argument ( void   ) 

Erases everything after the first '#'.

Definition at line 791 of file GURL.cpp.

int GURL::cleardir ( const int  timeout = 0  )  const

Recursively erases contents of directory.

The directory itself will not be removed.

Definition at line 1618 of file GURL.cpp.

void GURL::convert_slashes ( void   )  [protected]

Definition at line 232 of file GURL.cpp.

GUTF8String GURL::decode_reserved ( const GUTF8String &  url  )  [static]

Decodes reserved characters from the URL.

See also: {encode_reserved}().

Definition at line 1029 of file GURL.cpp.

int GURL::deletefile ( void   )  const

Deletes file or directory.

Directories are not deleted unless the directory is empty. Returns a negative number if an error occurs.

Definition at line 1551 of file GURL.cpp.

int GURL::djvu_cgi_arguments ( void   )  const

Returns the total number of DjVu-related CGI arguments (arguments following DJVUOPTS# in the URL).

Definition at line 641 of file GURL.cpp.

GUTF8String GURL::djvu_cgi_name ( int  num  )  const

Returns that part of DjVu-related CGI argument number num#, which is before the equal sign.

Definition at line 668 of file GURL.cpp.

DArray< GUTF8String > GURL::djvu_cgi_names ( void   )  const

Returns array of names of DjVu-related CGI arguments (arguments following DJVUOPTS# option.

Definition at line 738 of file GURL.cpp.

GUTF8String GURL::djvu_cgi_value ( int  num  )  const

Returns that part of DjVu-related CGI argument number num#, which is after the equal sign.

Definition at line 697 of file GURL.cpp.

DArray< GUTF8String > GURL::djvu_cgi_values ( void   )  const

Returns array of values of DjVu-related CGI arguments (arguments following DJVUOPTS# option.

Definition at line 762 of file GURL.cpp.

GUTF8String GURL::encode_reserved ( const GUTF8String &  gs  )  [static]

Escape special characters.

Definition at line 1064 of file GURL.cpp.

GUTF8String GURL::expand_name ( const GUTF8String &  filename,
const char *  fromdirname = 0 
) [static]

Returns fully qualified file names.

This functions constructs the fully qualified name of file or directory filename#. When provided, the optional argument fromdirname# is used as the current directory when interpreting relative specifications in filename#. Function expand_name# is very useful for logically concatenating file names. It knows which separators should be used for each operating system and it knows which syntactical rules apply.

Definition at line 1658 of file GURL.cpp.

GUTF8String GURL::extension ( void   )  const

Returns the extention part of name of document in this URL.

Definition at line 1010 of file GURL.cpp.

GUTF8String GURL::fname ( void   )  const

Returns the name part of this URL with escape sequences expanded.

For example, if the URL is http://www.lizardtech.com/file201.djvu# then this function will return file 1.djvu#. {name}() will return file201.djvu# at the same time.

Definition at line 1002 of file GURL.cpp.

GURL GURL::follow_symlinks ( void   )  const

Follows symbolic links.

Definition at line 1497 of file GURL.cpp.

GUTF8String GURL::get_string ( const bool  nothrow = false  )  const

Definition at line 1169 of file GURL.cpp.

GUTF8String GURL::get_string ( const GUTF8String &  useragent  )  const

Returns a string representing the URL.

This function normally returns a standard file URL as described in RFC 1738. Some versions of MSIE do not support this standard syntax. A brain damaged MSIE compatible syntax is generated when the optional argument useragent# contains string #"MSIE"# or #"Microsoft"#.

Definition at line 1180 of file GURL.cpp.

GUTF8String GURL::hash_argument ( void   )  const

Returns string after the first '#' with decoded escape sequences.

Definition at line 493 of file GURL.cpp.

void GURL::init ( const bool  nothrow = false  )  [protected]

Definition at line 365 of file GURL.cpp.

bool GURL::is_dir ( void   )  const

Test if this url is an existing directory.

Definition at line 1455 of file GURL.cpp.

bool GURL::is_empty ( void   )  const [inline]

Checks if this is an empty URL.

Definition at line 420 of file GURL.h.

bool GURL::is_file ( void   )  const

Test if this url is an existing file.

Definition at line 1378 of file GURL.cpp.

bool GURL::is_local_file_url ( void   )  const

Checks if the URL is local (starts from file:/#) or not.

Definition at line 897 of file GURL.cpp.

bool GURL::is_local_path ( void   )  const

Test if this url is an existing file, directory, or device.

Definition at line 1418 of file GURL.cpp.

bool GURL::is_valid ( void   )  const [inline]

Test if the URL is valid. If invalid, reinitialize.

Definition at line 428 of file GURL.h.

GList< GURL > GURL::listdir ( void   )  const

List the contents of a directory.

Definition at line 1575 of file GURL.cpp.

int GURL::mkdir ( void   )  const

Creates the specified directory.

Definition at line 1519 of file GURL.cpp.

GUTF8String GURL::name ( void   )  const

Returns the name part of this URL.

For example, if the URL is http://www.lizardtech.com/file201.djvu# then this function will return file201.djvu#. {fname}() will return file 1.djvu# at the same time.

Definition at line 980 of file GURL.cpp.

GNativeString GURL::NativeFilename ( void   )  const

Same but returns a native string.

Definition at line 1362 of file GURL.cpp.

GURL::operator const char * ( void   )  const [inline]

Returns Internal URL representation.

Definition at line 290 of file GURL.h.

bool GURL::operator!= ( const GURL &  gurl2  )  const [inline]

Returns TRUE if gurl1# and gurl2# are different.

Definition at line 408 of file GURL.h.

GURL & GURL::operator= ( const GURL &  url  ) 

Assignment operator.

Definition at line 466 of file GURL.cpp.

bool GURL::operator== ( const GURL &  gurl2  )  const

Returns TRUE if gurl1# and gurl2# are the same.

Definition at line 959 of file GURL.cpp.

void GURL::parse_cgi_args ( void   )  [protected]

Definition at line 542 of file GURL.cpp.

GUTF8String GURL::pathname ( void   )  const

Returns the aboslute URL without the host part.

Definition at line 919 of file GURL.cpp.

GUTF8String GURL::protocol ( void   )  const [inline]

Extracts the {protocol} part from the URL and returns it.

Definition at line 414 of file GURL.h.

GUTF8String GURL::protocol ( const GUTF8String &  url  )  [static, protected]

Definition at line 482 of file GURL.cpp.

int GURL::renameto ( const GURL &  newurl  )  const

Rename a file or directory.

Definition at line 1646 of file GURL.cpp.

void GURL::set_hash_argument ( const GUTF8String &  arg  ) 

Inserts the arg# after a separating hash into the URL.

The function encodes any illegal character in arg# using {GOS::encode_reserved}().

Definition at line 516 of file GURL.cpp.

void GURL::store_cgi_args ( void   )  [protected]

Definition at line 605 of file GURL.cpp.

GUTF8String GURL::UTF8Filename ( void   )  const

Returns a filename for a URL.

Argument url# must be a legal file URL. This function applies heuristic rules to convert the URL into a valid file name. It is guaranteed that this function can properly parse all URLs generated by filename_to_url#. The heuristics also work better when the file actually exists. The empty string is returned when this function cannot parse the URL or when the URL is not a file URL. URL formats are as described in RFC 1738 plus the following alternative formats for files on the local host:

file://<letter>:/<path> file://<letter>|/<path> file:/<path>

which are accepted because various browsers recognize them.

Definition at line 1273 of file GURL.cpp.


Friends And Related Function Documentation

unsigned int hash ( const GURL &  gurl  )  [friend]

Hashing function.

Returns:
hash suitable for usage in {GMap}

Definition at line 1944 of file GURL.cpp.


Member Data Documentation

DArray<GUTF8String> GURL::cgi_name_arr [protected]

Definition at line 157 of file GURL.h.

DArray<GUTF8String> GURL::cgi_value_arr [protected]

Definition at line 157 of file GURL.h.

GUTF8String GURL::url [protected]

Definition at line 156 of file GURL.h.

bool GURL::validurl [protected]

Definition at line 158 of file GURL.h.


The documentation for this class was generated from the following files:
  • GURL.h
  • GURL.cpp

kviewshell

Skip menu "kviewshell"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members

API Reference

Skip menu "API Reference"
  • kviewshell
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal