WvStreams
wvurl.h
1 /* -*- Mode: C++ -*-
2  * Worldvisions Weaver Software:
3  * Copyright (C) 1997-2002 Net Integration Technologies, Inc.
4  *
5  * WvURL is a simple URL-parsing class with built-in (though still somewhat
6  * inconvenient) DNS resolution.
7  */
8 #ifndef __WVURL_H
9 #define __WVURL_H
10 
11 #include "wvstring.h"
12 #include "wvresolver.h"
13 
14 class WvIPPortAddr;
15 
16 class WvUrl
17 {
18 public:
19  WvUrl(WvStringParm url);
20  WvUrl(const WvUrl &url);
21  ~WvUrl();
22 
23  bool isok() const
24  { return port != 0 && (resolving || addr != NULL); }
25  WvStringParm errstr() const
26  { return err; }
27  bool resolve(); // dns-resolve the hostname (returns true if done)
28 
29  operator WvString () const;
30 
31  // not actually defined - this just prevents accidental copying
32  const WvUrl &operator= (const WvUrl &);
33 
34  WvStringParm getproto() const
35  { return proto; }
36 
37  // this one is ONLY valid if resolve() returns true!
38  const WvIPPortAddr getaddr() const
39  { return addr ? *addr : WvIPPortAddr(); }
40 
41  WvStringParm getfile() const
42  { return file; }
43  WvStringParm gethost() const
44  { return hostname; }
45  int getport() const
46  { return port; }
47  WvStringParm getuser() const
48  { return user; }
49  WvStringParm getpassword() const
50  { return password; }
51 
52 protected:
53  WvString proto, hostname, user, password;
54  int port;
55  bool resolving;
56  WvResolver dns;
57  WvIPPortAddr *addr;
58  WvString file, err;
59 };
60 
61 
62 // backwards compatibility
63 typedef WvUrl WvURL;
64 
65 #endif // __WVURL_H
WvResolver
ASynchronous DNS resolver functions, so that we can do non-blocking lookups.
Definition: wvresolver.h:24
WvString
WvString is an implementation of a simple and efficient printable-string class.
Definition: wvstring.h:329
WvIPPortAddr
An IP+Port address also includes a port number, with the resulting form www.xxx.yyy....
Definition: wvaddr.h:393
WvUrl
Definition: wvurl.h:16