Add vim modelines
[www-quvi.git] / Quvi.i
blob91dd02d85cf3a6fd8f5348b9cdbdec9f40fccfbd
2 %module "WWW::Quvi"
4 %include "std_string.i"
5 %include "exception.i"
6 %include "typemaps.i"
8 %{
9 #include "Quvi.h"
12 %inline %{
14 char *_VERSION = VERSION;
16 typedef enum {
17 libquviVersion = QUVI_VERSION,
18 libquviVersionLong = QUVI_VERSION_LONG,
19 ModuleVersion
20 } quviVersion;
22 static char* version (quviVersion n=ModuleVersion) {
23 if (n == ModuleVersion) return _VERSION;
24 return quvi_version ((QUVIversion)n);
28 * A manual copy of QUVIcode. If there's a better way to do this,
29 * I'd like to know it too. This will need to be maintained manually
30 * if there are any changes to the QUVIcode enum list in quvi.h file.
32 * The reason we don't simply "%include <quvi/quvi.h>" and
33 * get the constants is because that would clutter the wrapper.
35 * We have renamed the constants to avoid any conflicts with those
36 * defined in <quvi/quvi.h> which is included by the wrapper.
38 typedef enum {
39 OK = 0x00,
40 Mem,
41 BadHandle,
42 InvArg,
43 CurlInit,
44 Last,
45 AbortedByCallback,
46 LuaInit,
47 NoLuaWebsite,
48 NoLuaUtil,
49 PcreError= 0x40, /* QUVI_PCRE */
50 NoSupport,
51 CurlError, /* QUVI_CURL */
52 IconvError, /* QUVI_ICONV */
53 LuaError, /* QUVI_LUA */
54 } quviCode;
56 typedef enum {
57 ProtoHttp = 0x1,
58 ProtoMms = 0x2,
59 ProtoRtsp = 0x4,
60 ProtoRtmp = 0x8,
61 ProtoAll = (ProtoHttp|ProtoMms|ProtoRtsp|ProtoRtmp)
62 } quviCategory;
66 class Options {
67 public:
68 Options ();
69 public:
70 std::string user_agent;
71 std::string http_proxy;
72 bool verbose_libcurl;
73 std::string format;
74 bool verify;
75 bool shortened;
76 long category;
79 class Link {
80 public:
81 Link ();
82 public:
83 %immutable;
84 std::string content_type;
85 std::string file_suffix;
86 double length_bytes;
87 std::string url;
90 class Video {
91 public:
92 Video ();
93 public:
94 %immutable;
95 std::string title;
96 std::string host;
97 std::string url;
98 std::string id;
99 Link link;
100 bool ok;
103 /* Query::_init throws std::runtime_error if quvi_init fails. */
104 %exception {
106 { $action }
107 catch (const std::runtime_error& e)
108 { SWIG_exception (SWIG_RuntimeError, e.what ()); }
111 %apply std::string &OUTPUT { std::string &domain, std::string &formats };
113 class Query {
114 public:
115 Query ();
116 virtual ~Query ();
117 public:
118 Video parse (const std::string&, const Options&);
119 int next_website (std::string &domain, std::string &formats);
120 public:
121 %immutable;
122 std::string last_error;
123 long quvi_code;
124 long resp_code;
127 %exception;