GURL Class Reference
System independent URL representation.
More...
#include <GURL.h>
List of all members.
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] |
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.
void GURL::beautify_path |
( |
void |
|
) |
[protected] |
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.
Returns that part of CGI argument number num#, which is before the equal sign.
Definition at line 660 of file GURL.cpp.
Returns array of all known CGI names (part of CGI argument before the equal sign).
Definition at line 722 of file GURL.cpp.
Returns that part of CGI argument number num#, which is after the equal sign.
Definition at line 689 of file GURL.cpp.
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] |
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.
Returns that part of DjVu-related CGI argument number num#, which is before the equal sign.
Definition at line 668 of file GURL.cpp.
Returns array of names of DjVu-related CGI arguments (arguments following DJVUOPTS# option.
Definition at line 738 of file GURL.cpp.
Returns that part of DjVu-related CGI argument number num#, which is after the equal sign.
Definition at line 697 of file GURL.cpp.
Returns array of values of DjVu-related CGI arguments (arguments following DJVUOPTS# option.
Definition at line 762 of file GURL.cpp.
Escape special characters.
Definition at line 1064 of file GURL.cpp.
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.
Returns the extention part of name of document in this URL.
Definition at line 1010 of file GURL.cpp.
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 |
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.
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] |
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.
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.
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.
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] |
Returns the aboslute URL without the host part.
Definition at line 919 of file GURL.cpp.
Extracts the {protocol} part from the URL and returns it.
Definition at line 414 of file GURL.h.
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] |
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
The documentation for this class was generated from the following files: