Apply style changes to *.t
[www-quvi.git] / i / Quvi.i
blob19502e7aedc91b8cdc656a8ce19eaabf75848af3
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 static 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(static_cast<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;
81 %} /* %inline */
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 Media {
97 public:
98 Media();
99 public:
100 %immutable;
101 std::string thumbnail_url;
102 std::string content_type;
103 std::string file_suffix;
104 std::string start_time;
105 std::string page_title;
106 double content_length;
107 std::string page_url;
108 std::string host;
109 std::string url;
110 double duration;
111 std::string id;
114 /* Query::_init throws std::runtime_error if quvi_init fails. */
115 %exception {
117 { $action }
118 catch (const std::runtime_error& e)
119 { SWIG_exception(SWIG_RuntimeError, e.what()); }
122 %apply std::string &OUTPUT { std::string &domain, std::string &formats };
124 class Query {
125 public:
126 Query();
127 virtual ~Query();
128 public:
129 void next_website(std::string &domain, std::string &formats);
130 std::string formats(const std::string&);
131 int supported(const std::string&);
132 Media parse(const std::string&);
133 void set_opts(const Options&);
134 public:
135 %immutable;
136 std::string errmsg;
137 long quvi_code;
138 long resp_code;
139 int ok;
142 %exception;