File: wvurl.h

package info (click to toggle)
wvstreams 4.0.2-4
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 6,420 kB
  • ctags: 6,518
  • sloc: cpp: 52,544; sh: 5,770; ansic: 810; makefile: 461; tcl: 114; perl: 18
file content (65 lines) | stat: -rw-r--r-- 1,547 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/* -*- Mode: C++ -*-
 * Worldvisions Weaver Software:
 *   Copyright (C) 1997-2002 Net Integration Technologies, Inc.
 *
 * WvURL is a simple URL-parsing class with built-in (though still somewhat
 * inconvenient) DNS resolution.
 */ 
#ifndef __WVURL_H
#define __WVURL_H

#include "wvstring.h"
#include "wvresolver.h"

class WvIPPortAddr;

class WvUrl
{
public:
    WvUrl(WvStringParm url);
    WvUrl(const WvUrl &url);
    ~WvUrl();
    
    bool isok() const
        { return port != 0 && (resolving || addr != NULL); }
    WvStringParm errstr() const
        { return err; }
    bool resolve(); // dns-resolve the hostname (returns true if done)

    operator WvString () const;
    
    // not actually defined - this just prevents accidental copying
    const WvUrl &operator= (const WvUrl &);
    
    WvStringParm getproto() const
        { return proto; }
    
    // this one is ONLY valid if resolve() returns true!
    const WvIPPortAddr getaddr() const
        { return addr ? *addr : WvIPPortAddr(); }
    
    WvStringParm getfile() const
        { return file; }
    WvStringParm gethost() const
        { return hostname; }
    int getport() const
        { return port; }
    WvStringParm getuser() const
        { return user; }
    WvStringParm getpassword() const
        { return password; }

protected:
    WvString proto, hostname, user, password;
    int port;
    bool resolving;
    WvResolver dns;
    WvIPPortAddr *addr;
    WvString file, err;
};


// backwards compatibility
typedef WvUrl WvURL;

#endif // __WVURL_H