From 288762fb65c1cb8f2b7ae4ada38f3f5daba6fe87 Mon Sep 17 00:00:00 2001 From: Toni Gundogdu Date: Tue, 26 Jul 2011 15:01:32 +0300 Subject: [PATCH] Use int instead of bool type The use of bool type created unexpected results in some configurations. --- Media.cxx | 6 ++-- Options.cxx | 23 ++++++++------ Quvi.h | 16 +++++----- i/Quvi.i | 104 ++++++++++++++++++++++++++++++------------------------------ 4 files changed, 76 insertions(+), 73 deletions(-) diff --git a/Media.cxx b/Media.cxx index 4daa6e0..a2dd179 100644 --- a/Media.cxx +++ b/Media.cxx @@ -22,12 +22,12 @@ #include "Quvi.h" Media::Media() - : ok(false) + : ok(0) { } Media::Media(quvi_media_t m) - : ok(true) + : ok(1) { #define _wrap(id,dst,type) \ do { type t; quvi_getprop(m,id,&t); dst=t; } while (0) @@ -42,7 +42,7 @@ Media::Media(quvi_media_t m) } Media::Media(const Media& v) - :ok(false) + : ok(0) { _swap(v); } diff --git a/Options.cxx b/Options.cxx index cf5c274..504dff9 100644 --- a/Options.cxx +++ b/Options.cxx @@ -21,25 +21,28 @@ #include "Quvi.h" +#define _init \ +: user_agent(""), \ + http_proxy(""), \ + verbose_libcurl(0), \ + format("default"), \ + category(QUVIPROTO_HTTP), \ + resolve(1), \ + verify(1) + Options::Options() - : verbose_libcurl(false), - format("default"), - verify(true), - resolve(true), - category(QUVIPROTO_HTTP) +_init { } Options::Options(const Options& o) - : verbose_libcurl(false), - format("default"), - verify(true), - resolve(true), - category(QUVIPROTO_HTTP) +_init { _swap (o); } +#undef _init + Options& Options::operator=(const Options& o) { diff --git a/Quvi.h b/Quvi.h index 20a495b..79b9589 100644 --- a/Quvi.h +++ b/Quvi.h @@ -39,11 +39,11 @@ private: public: std::string user_agent; std::string http_proxy; - bool verbose_libcurl; + int verbose_libcurl; std::string format; - bool verify; - bool resolve; long category; + int resolve; + int verify; }; class Url @@ -74,13 +74,13 @@ public: private: void _swap(const Media&); public: + std::string start_time; + std::string page_url; std::string title; std::string host; - std::string page_url; std::string id; Url url; - bool ok; - std::string start_time; + int ok; }; class Query @@ -92,8 +92,8 @@ public: virtual ~Query(); public: Media parse(const std::string&, const Options&); - int next_website(std::string&, std::string&); - int supported(const std::string&); + int next_website(std::string&, std::string&); + int supported(const std::string&); private: void _init(); void _close(); diff --git a/i/Quvi.i b/i/Quvi.i index 515f96e..fd17be9 100644 --- a/i/Quvi.i +++ b/i/Quvi.i @@ -32,14 +32,14 @@ char *_VERSION = VERSION; typedef enum { - libquviVersion = QUVI_VERSION, - libquviVersionLong = QUVI_VERSION_LONG, - ModuleVersion + libquviVersion = QUVI_VERSION, + libquviVersionLong = QUVI_VERSION_LONG, + ModuleVersion } quviVersion; static char* version (quviVersion n=ModuleVersion) { - if (n == ModuleVersion) return _VERSION; - return quvi_version ((QUVIversion)n); + if (n == ModuleVersion) return _VERSION; + return quvi_version ((QUVIversion)n); } /* @@ -54,20 +54,20 @@ static char* version (quviVersion n=ModuleVersion) { * defined in which is included by the wrapper. */ typedef enum { -OK = 0x00, -Mem, -BadHandle, -InvArg, -CurlInit, -Last, -AbortedByCallback, -LuaInit, -NoLuaWebsite, -NoLuaUtil, -NoSupport =0x41, -CallbackError, -IconvError, /* QUVI_ICONV */ -LuaError, /* QUVI_LUA */ + OK = 0x00, + Mem, + BadHandle, + InvArg, + CurlInit, + Last, + AbortedByCallback, + LuaInit, + NoLuaWebsite, + NoLuaUtil, + NoSupport =0x41, + CallbackError, + IconvError, /* QUVI_ICONV */ + LuaError, /* QUVI_LUA */ } quviCode; typedef enum { @@ -82,65 +82,65 @@ ProtoAll = (ProtoHttp|ProtoMms|ProtoRtsp|ProtoRtmp) class Options { public: - Options(); + Options(); public: - std::string user_agent; - std::string http_proxy; - bool verbose_libcurl; - std::string format; - bool verify; - bool resolve; - long category; + std::string user_agent; + std::string http_proxy; + int verbose_libcurl; + std::string format; + long category; + int resolve; + int verify; }; class Url { public: - Url(); + Url(); public: %immutable; - std::string content_type; - std::string file_suffix; - double length_bytes; - std::string url; + std::string content_type; + std::string file_suffix; + double length_bytes; + std::string url; }; class Media { public: - Media(); + Media(); public: %immutable; - std::string title; - std::string host; - std::string page_url; - std::string id; - Url url; - bool ok; - std::string start_time; + std::string start_time; + std::string page_url; + std::string title; + std::string host; + std::string id; + Url url; + int ok; }; /* Query::_init throws std::runtime_error if quvi_init fails. */ %exception { - try - { $action } - catch (const std::runtime_error& e) - { SWIG_exception(SWIG_RuntimeError, e.what()); } + try + { $action } + catch (const std::runtime_error& e) + { SWIG_exception(SWIG_RuntimeError, e.what()); } } %apply std::string &OUTPUT { std::string &domain, std::string &formats }; class Query { public: - Query(); - virtual ~Query(); + Query(); + virtual ~Query(); public: - Media parse(const std::string&, const Options&); - int next_website(std::string &domain, std::string &formats); - int supported(const std::string&); + Media parse(const std::string&, const Options&); + int next_website(std::string &domain, std::string &formats); + int supported(const std::string&); public: %immutable; - std::string last_error; - long quvi_code; - long resp_code; + std::string last_error; + long quvi_code; + long resp_code; }; %exception; -- 2.11.4.GIT