CPPMyth
Library to interoperate with MythTV server
Loading...
Searching...
No Matches
uriparser.h
1/*
2 * Copyright (C) 2014-2015 Jean-Luc Barriere
3 *
4 * This library is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published
6 * by the Free Software Foundation; either version 3, or (at your option)
7 * any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library; see the file COPYING. If not, write to
16 * the Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301 USA
18 * http://www.gnu.org/copyleft/gpl.html
19 *
20 */
21
22#ifndef URIPARSER_H
23#define URIPARSER_H
24
25#include "local_config.h"
26#include <string>
27
28namespace NSROOT
29{
30
31 class URIParser
32 {
33 public:
34 URIParser(const std::string& location);
35 ~URIParser();
36
37 const char *Scheme() const { return m_parts.scheme; }
38 const char *Host() const { return m_parts.host; }
39 unsigned Port() const { return m_parts.port; }
40 const char *User() const { return m_parts.user; }
41 const char *Pass() const { return m_parts.pass; }
42 bool IsRelative() const { return m_parts.relative ? true : false; }
43 const char *Path() const { return IsRelative() ? m_parts.relative : m_parts.absolute; }
44 const char *Fragment() const { return m_parts.fragment; }
45 const char *Params() const { return m_parts.params; }
46
47 private:
48 // prevent copy
49 URIParser(const URIParser&);
50 URIParser& operator=(const URIParser&);
51
52 typedef struct
53 {
54 char *scheme;
55 char *host;
56 unsigned port;
57 char *user;
58 char *pass;
59 char *absolute;
60 char *relative;
61 char *fragment;
62 char *params;
63 } URI_t;
64
65 URI_t m_parts;
66 char *m_buffer;
67
68 static void URIScan(char *uri, URI_t *parts);
69 };
70
71}
72
73#endif /* URIPARSER_H */