CPPMyth
Library to interoperate with MythTV server
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 <cppmyth_config.h>
26 #include <string>
27 
28 namespace 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 
46  private:
47  // prevent copy
48  URIParser(const URIParser&);
49  URIParser& operator=(const URIParser&);
50 
51  typedef struct
52  {
53  char *scheme;
54  char *host;
55  unsigned port;
56  char *user;
57  char *pass;
58  char *absolute;
59  char *relative;
60  char *fragment;
61  } URI_t;
62 
63  URI_t m_parts;
64  char *m_buffer;
65 
66  static void URIScan(char *uri, URI_t *parts);
67  };
68 
69 }
70 
71 #endif /* URIPARSER_H */