vul_url.h
Go to the documentation of this file.
1 // This is core/vul/vul_url.h
2 #ifndef vul_url_h_
3 #define vul_url_h_
4 //:
5 // \file
6 // \brief Static class methods to test and open streams via a URL
7 // \author Ian Scott
8 // Based on vil_stream_url by fsm
9 // \verbatim
10 // Modifications
11 // 8 Nov 2002 - Peter Vanroose - corrected HTTP client request syntax
12 // \endverbatim
13 
14 #include <istream>
15 #include <iostream>
16 #include <string>
17 #ifdef _MSC_VER
18 # include <vcl_msvc_warnings.h>
19 #endif
20 
21 //: Functions to test and open streams via a URL
22 // Currently supports file and HTTP only.
23 // HTTP support includes basic authentication, using the normal
24 // HTTP URL scheme, e.g. \c http://user4:mypassword@webserverthingy.org/file.txt
25 class vul_url
26 {
27  public:
28  //: open a URL
29  // If URL is "file://..." open as a file with given mode.
30  // If URL is "http://..." open using vul_http_open
31  // If URL is "ftp://..." attempt ftp
32  // Otherwise assume it is a filename and open with given mode
33  static std::istream* open(const char* url, std::ios::openmode mode=std::ios::in );
34 
35  //: Does that URL exist
36  // If the URL does not begin with a recognised scheme identifier, the function will
37  // treat the parameter as a local filename
38  static bool exists(const char* url);
39 
40  //: Is that a URL
41  // as opposed to an ordinary filename.
42  static bool is_url(const char* url);
43 
44  //: Is that a file
45  // i.e. is it a downloadable URL, or a file on disk that isn't a directory.
46  static bool is_file(const char* url);
47 
48  //: Encode a string of chars into base64 format
49  static std::string encode_base64(const std::string& in);
50 
51  //: Decode a string of chars from base64 format
52  static std::string decode_base64(const std::string& in);
53 };
54 
55 #endif // vul_url_h_
static std::string encode_base64(const std::string &in)
Encode a string of chars into base64 format.
Definition: vul_url.cxx:570
static bool is_file(const char *url)
Is that a file.
Definition: vul_url.cxx:521
static bool exists(const char *url)
Does that URL exist.
Definition: vul_url.cxx:465
static std::istream * open(const char *url, std::ios::openmode mode=std::ios::in)
open a URL.
Definition: vul_url.cxx:436
static bool is_url(const char *url)
Is that a URL.
Definition: vul_url.cxx:493
static std::string decode_base64(const std::string &in)
Decode a string of chars from base64 format.
Definition: vul_url.cxx:649
Functions to test and open streams via a URL.
Definition: vul_url.h:25