iFun Engine API  1.0.0-b3630
Great Technology for Great Games
 All Classes Files Functions Variables Typedefs Macros
curl.h
Go to the documentation of this file.
1 // Copyright (C) 2013-2015 iFunFactory Inc. All Rights Reserved.
2 //
3 // This work is confidential and proprietary to iFunFactory Inc. and
4 // must not be used, disclosed, copied, or distributed without the prior
5 // consent of iFunFactory Inc.
6 
9 #ifndef INCLUDE_FUNAPI_NETWORK_CURL_H_
10 #define INCLUDE_FUNAPI_NETWORK_CURL_H_
11 
12 #include <curl/curl.h>
13 
14 #include <funapi/types.h>
15 
16 
17 namespace fun {
18 
19 // Hidden implementation detail.
20 namespace impl {
21 class Curl;
22 } // namespace impl
23 
24 
25 
27 class Curl : public boost::enable_shared_from_this<Curl>,
28  private boost::noncopyable {
29  public:
30  DECLARE_CLASS_PTR(Curl);
31 
33  typedef boost::function<void(CURLcode)> Callback;
34 
36  Curl();
37 
39  ~Curl();
40 
44  CURL *handle();
45 
48  bool IsReady() const;
49 
53  CURLcode StartSync(const string &url);
54 
61  void StartAsync(const string &url, const Callback &cb);
62 
65  CURLcode GetResultCode() const;
66 
68  // @return string
69  string GetResult() const;
70 
72  void set_verbose(bool on);
73 
74  private:
75  Ptr<impl::Curl> impl_;
76 };
77 
78 } // namespace fun
79 
80 #endif // INCLUDE_FUNAPI_NETWORK_CURL_H_
void set_verbose(bool on)
Set verbosity.
Wrapepr class for libcurl.
Definition: curl.h:27
~Curl()
Destructor.
CURLcode StartSync(const string &url)
Kickstarts to fetch the url in a synchronous manner.
void StartAsync(const string &url, const Callback &cb)
Runs in an asynchronouse way.
CURL * handle()
Getter to access the native handle.
CURLcode GetResultCode() const
Returns the stored result code in CURLcode.
bool IsReady() const
Checks if the curl instance is ready to use.
boost::function< void(CURLcode)> Callback
Callback for asynchronous operations.
Definition: curl.h:33
string GetResult() const
Returns the stored result in the string format.
Curl()
Constructor.