add Makefile.PL ExtUtils to Changes
[www-quvi.git] / Quvi.i
blob5076da72f5364ccd7cb1fc7423d87daac7eb5206
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;
58 class Options {
59 public:
60 Options ();
61 public:
62 std::string user_agent;
63 std::string http_proxy;
64 bool verbose_libcurl;
65 std::string format;
66 bool verify;
69 class Link {
70 public:
71 Link ();
72 public:
73 %immutable;
74 std::string content_type;
75 std::string file_suffix;
76 double length_bytes;
77 std::string url;
80 class Video {
81 public:
82 Video ();
83 public:
84 %immutable;
85 std::string title;
86 std::string host;
87 std::string url;
88 std::string id;
89 Link link;
90 bool ok;
93 /* Query::_init throws std::runtime_error if quvi_init fails. */
94 %exception {
95 try
96 { $action }
97 catch (const std::runtime_error& e)
98 { SWIG_exception (SWIG_RuntimeError, e.what ()); }
101 %apply std::string &OUTPUT { std::string &domain, std::string &formats };
103 class Query {
104 public:
105 Query ();
106 virtual ~Query ();
107 public:
108 Video parse (const std::string&, const Options&);
109 int next_website (std::string &domain, std::string &formats);
110 public:
111 %immutable;
112 std::string last_error;
113 long quvi_code;
114 long resp_code;
117 %exception;