Move Quvi.h to i/
[www-quvi.git] / i / Quvi.i
blobfd17be9f0f5960cce86fad83060672db10655436
1 /* WWW::Quvi
2 * Copyright (C) 2010,2011 Toni Gundogdu <legatvs@gmail.com>
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
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 GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301 USA
20 %module "WWW::Quvi"
22 %include "std_string.i"
23 %include "exception.i"
24 %include "typemaps.i"
27 #include "Quvi.h"
30 %inline %{
32 char *_VERSION = VERSION;
34 typedef enum {
35 libquviVersion = QUVI_VERSION,
36 libquviVersionLong = QUVI_VERSION_LONG,
37 ModuleVersion
38 } quviVersion;
40 static char* version (quviVersion n=ModuleVersion) {
41 if (n == ModuleVersion) return _VERSION;
42 return quvi_version ((QUVIversion)n);
46 * A manual copy of QUVIcode. If there's a better way to do this,
47 * I'd like to know it too. This will need to be maintained manually
48 * if there are any changes to the QUVIcode enum list in quvi.h file.
50 * The reason we don't simply "%include <quvi/quvi.h>" and
51 * get the constants is because that would clutter the wrapper.
53 * We have renamed the constants to avoid any conflicts with those
54 * defined in <quvi/quvi.h> which is included by the wrapper.
56 typedef enum {
57 OK = 0x00,
58 Mem,
59 BadHandle,
60 InvArg,
61 CurlInit,
62 Last,
63 AbortedByCallback,
64 LuaInit,
65 NoLuaWebsite,
66 NoLuaUtil,
67 NoSupport =0x41,
68 CallbackError,
69 IconvError, /* QUVI_ICONV */
70 LuaError, /* QUVI_LUA */
71 } quviCode;
73 typedef enum {
74 ProtoHttp = 0x1,
75 ProtoMms = 0x2,
76 ProtoRtsp = 0x4,
77 ProtoRtmp = 0x8,
78 ProtoAll = (ProtoHttp|ProtoMms|ProtoRtsp|ProtoRtmp)
79 } quviCategory;
83 class Options {
84 public:
85 Options();
86 public:
87 std::string user_agent;
88 std::string http_proxy;
89 int verbose_libcurl;
90 std::string format;
91 long category;
92 int resolve;
93 int verify;
96 class Url {
97 public:
98 Url();
99 public:
100 %immutable;
101 std::string content_type;
102 std::string file_suffix;
103 double length_bytes;
104 std::string url;
107 class Media {
108 public:
109 Media();
110 public:
111 %immutable;
112 std::string start_time;
113 std::string page_url;
114 std::string title;
115 std::string host;
116 std::string id;
117 Url url;
118 int ok;
121 /* Query::_init throws std::runtime_error if quvi_init fails. */
122 %exception {
124 { $action }
125 catch (const std::runtime_error& e)
126 { SWIG_exception(SWIG_RuntimeError, e.what()); }
129 %apply std::string &OUTPUT { std::string &domain, std::string &formats };
131 class Query {
132 public:
133 Query();
134 virtual ~Query();
135 public:
136 Media parse(const std::string&, const Options&);
137 int next_website(std::string &domain, std::string &formats);
138 int supported(const std::string&);
139 public:
140 %immutable;
141 std::string last_error;
142 long quvi_code;
143 long resp_code;
146 %exception;