2009-12-04 Jeffrey Stedfast <fejj@novell.com>
[moon.git] / src / uri.h
blob31b185ecc55d1980f0fdb53cd63f7e9a2a2bc33c
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
2 /*
3 * uri.h:
5 * Contact:
6 * Moonlight List (moonlight-list@lists.ximian.com)
8 * Copyright 2007 Novell, Inc. (http://www.novell.com)
10 * See the LICENSE file included with the distribution for details.
13 #ifndef __URI_H__
14 #define __URI_H__
16 #include <glib.h>
18 enum UriToStringFlags {
19 UriHidePasswd = 1 << 0,
20 UriHideFragment = 1 << 1,
21 UriHideQuery = 1 << 2,
24 /* @IncludeInKinds */
25 /* @SkipValue */
26 /* @Namespace=System */
27 struct Uri {
28 public:
29 Uri ();
30 Uri (const Uri& uri);
32 ~Uri ();
34 /* @GenerateCBinding,GeneratePInvoke */
35 bool Parse (const char *uri, bool allow_trailing_sep = false);
36 void Combine (const char *relative_path);
37 void Combine (const Uri *relative_uri);
39 /* @GenerateCBinding,GeneratePInvoke */
40 void Free ();
42 char *ToString (UriToStringFlags flags) const;
43 char *ToString () const { return ToString ((UriToStringFlags) 0); }
45 static void Copy (const Uri *from, Uri *to);
47 bool operator== (const Uri &v) const;
49 /* @GenerateCBinding */
50 static bool Equals (const Uri *left, const Uri *right);
51 static bool IsNullOrEmpty (const Uri *uri);
52 static bool SameSiteOfOrigin (const Uri *left, const Uri *right);
54 /* @GenerateCBinding */
55 guint GetHashCode ();
57 bool IsScheme (const char *scheme) const;
58 bool IsAbsolute () const { return isAbsolute; }
60 bool IsInvalidPath () { return path && (path[0] == '\\' || (path[0] == '.' && path[1] == '\\')); }
61 bool IsUncPath () { return path && path[0] == '\\'; }
63 const char *GetScheme () const { return scheme; }
64 const char *GetHost () const { return host; }
65 int GetPort () const { return port; }
66 const char *GetUser () const { return user; }
67 const char *GetAuth () const { return auth; }
68 const char *GetPasswd () const { return passwd; }
69 const char *GetFragment () const { return fragment; }
70 const char *GetPath () const { return path; }
71 const char *GetQuery () const { return query; }
73 struct Param {
74 Param *next;
75 char *value;
76 char *name;
79 bool isAbsolute;
81 char *scheme;
82 char *user;
83 char *auth;
84 char *passwd;
85 char *host;
86 int port;
87 char *path;
88 Param *params;
89 char *query;
90 char *fragment;
92 char *originalString;
95 #endif /* __URI_H__ */