~ubuntu-branches/ubuntu/trusty/cclive/trusty-proposed

« back to all changes in this revision

Viewing changes to lib/quvicpp/include/quvicpp/quvicpp.h

  • Committer: Bazaar Package Importer
  • Author(s): Alejandro Garrido Mota
  • Date: 2011-03-07 14:37:59 UTC
  • mfrom: (1.1.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20110307143759-abieei4gsctde1zo
Tags: 0.7.3.1-1
* New upstream release (Closes: #608393, #588795) 
* Remove patch: The changes was included by upstream author.
* Remove two white lines in d/rules 
* d/copyright: Update Copyright years to 2009,2011 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* 
2
 
* Copyright (C) 2010 Toni Gundogdu.
3
 
*
4
 
* This program is free software: you can redistribute it and/or modify
5
 
* it under the terms of the GNU General Public License as published by
6
 
* the Free Software Foundation, either version 3 of the License, or
7
 
* (at your option) any later version.
8
 
*
9
 
* This program 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
12
 
* GNU General Public License for more details.
13
 
*
14
 
* You should have received a copy of the GNU General Public License
15
 
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
 
*/
17
 
 
18
 
#ifndef quvicpp_h
19
 
#define quvicpp_h
20
 
 
21
 
#include <string>
22
 
#include <vector>
23
 
#include <map>
24
 
 
25
 
#include <quvi/quvi.h>
26
 
 
27
 
namespace quvicpp {
28
 
 
29
 
class options;
30
 
class query;
31
 
class video;
32
 
class link;
33
 
class error;
34
 
 
35
 
typedef std::string url;
36
 
 
37
 
// Version.
38
 
 
39
 
std::string version      ();
40
 
std::string version_long ();
41
 
 
42
 
// To string.
43
 
 
44
 
std::string support_to_s (const std::map<std::string,std::string>&);
45
 
 
46
 
// Options.
47
 
 
48
 
class options {
49
 
    friend class query;
50
 
    friend class error;
51
 
public:
52
 
    options();
53
 
    options(const options&);
54
 
    options& operator=(const options&);
55
 
    virtual ~options();
56
 
public:
57
 
    void format     (const std::string&);
58
 
    void verify     (bool);
59
 
    void statusfunc (quvi_callback_status);
60
 
    void writefunc  (quvi_callback_write);
61
 
private:
62
 
    void _swap (const options&);
63
 
private:
64
 
    quvi_callback_status _statusfunc;
65
 
    quvi_callback_write  _writefunc;
66
 
    std::string          _format;
67
 
    bool                 _verify;
68
 
};
69
 
 
70
 
// Query.
71
 
 
72
 
class query {
73
 
public:
74
 
    query();
75
 
    query(const query&);
76
 
    query& operator=(const query&);
77
 
    virtual ~query();
78
 
public:
79
 
    video parse (const url&, const options&) const;
80
 
    std::map<std::string,std::string> support () const;
81
 
    void* curlHandle () const;
82
 
private:
83
 
    void _init ();
84
 
    void _close();
85
 
private:
86
 
    quvi_t _quvi;
87
 
    void*  _curl;
88
 
};
89
 
 
90
 
// Link.
91
 
 
92
 
class link {
93
 
public:
94
 
    link();
95
 
    link(quvi_video_t);
96
 
    link(const link&);
97
 
    link& operator=(const link&);
98
 
    virtual ~link();
99
 
public:
100
 
    const   std::string& content_type   () const;
101
 
    const   std::string& suffix         () const;
102
 
    const   std::string& url            () const;
103
 
    double  length                      () const;
104
 
    bool    ok                          () const;
105
 
private:
106
 
    void _swap (const link&);
107
 
private:
108
 
    std::string _contentType;
109
 
    std::string _suffix;
110
 
    std::string _url;
111
 
    double _length;
112
 
};
113
 
 
114
 
// Video.
115
 
 
116
 
class video {
117
 
    friend std::ostream& operator<<(std::ostream&, const video&);
118
 
public:
119
 
    video();
120
 
    video(quvi_video_t);
121
 
    video(const video&);
122
 
    video& operator=(const video&);
123
 
    virtual ~video();
124
 
public:
125
 
    const std::string& title    () const;
126
 
    const std::string& host     () const;
127
 
    const std::string& url      () const;
128
 
    const std::string& id       () const;
129
 
    const std::string& format   () const;
130
 
    long  http_code             () const;
131
 
    link               next_link();
132
 
    std::string        to_s     ();
133
 
    void print                  (std::ostream&);
134
 
private:
135
 
    void _swap (const video&);
136
 
private:
137
 
    std::vector<link>::const_iterator _current_link;
138
 
    std::vector<link> _links;
139
 
    std::string _format;
140
 
    std::string _title;
141
 
    std::string _host;
142
 
    std::string _url;
143
 
    std::string _id;
144
 
    long _http_code;
145
 
};
146
 
 
147
 
// Error.
148
 
 
149
 
class error {
150
 
public:
151
 
    error (quvi_t, QUVIcode);
152
 
    error (const error&);
153
 
    error& operator=(const error&);
154
 
    virtual ~error();
155
 
public:
156
 
    const std::string& what() const;
157
 
    long response_code () const;
158
 
    QUVIcode quvi_code () const;
159
 
private:
160
 
    void _swap (const error&);
161
 
private:
162
 
    QUVIcode _quvi_code;
163
 
    std::string _what;
164
 
    long _resp_code;
165
 
};
166
 
 
167
 
} // End namespace.
168
 
 
169
 
#endif
170
 
 
171