]> git.mxchange.org Git - simgear.git/blobdiff - simgear/io/HTTPRequest.hxx
cppbind.Ghost: clean up a bit
[simgear.git] / simgear / io / HTTPRequest.hxx
index 89a953bc6a64dd0514275c3414b3585b6fa337e7..ef101b3f3e9fb8b26e55b3ac49bcea1cb17bdbac 100644 (file)
@@ -8,6 +8,7 @@
 #include <simgear/structure/SGSharedPtr.hxx>
 #include <simgear/math/sg_types.hxx>
 
+#include <boost/bind.hpp>
 #include <boost/function.hpp>
 
 class SGPropertyNode;
@@ -53,6 +54,12 @@ public:
      */
     Request* done(const Callback& cb);
 
+    template<class C>
+    Request* done(C* instance, void (C::*mem_func)(Request*))
+    {
+      return done(boost::bind(mem_func, instance, _1));
+    }
+
     /**
      * Set the handler to be called when the request completes or aborts with an
      * error.
@@ -62,6 +69,12 @@ public:
      */
     Request* fail(const Callback& cb);
 
+    template<class C>
+    Request* fail(C* instance, void (C::*mem_func)(Request*))
+    {
+      return fail(boost::bind(mem_func, instance, _1));
+    }
+
     /**
      * Set the handler to be called when the request either successfully
      * completes or fails.
@@ -71,6 +84,12 @@ public:
      */
     Request* always(const Callback& cb);
 
+    template<class C>
+    Request* always(C* instance, void (C::*mem_func)(Request*))
+    {
+      return always(boost::bind(mem_func, instance, _1));
+    }
+
     /**
      * Set the data for the body of the request. The request is automatically
      * send using the POST method.
@@ -99,6 +118,8 @@ public:
     StringMap const& responseHeaders() const
         { return _responseHeaders; }
 
+    std::string responseMime() const;
+
     virtual int responseCode() const
         { return _responseStatus; }
         
@@ -177,6 +198,8 @@ protected:
     virtual void onFail();
     virtual void onAlways();
 
+    void setFailure(int code, const std::string& reason);
+
 private:
     friend class Client;
     friend class Connection;
@@ -186,7 +209,6 @@ private:
     Request& operator=(const Request&); // = delete;
 
     void processBodyBytes(const char* s, int n);
-    void setFailure(int code, const std::string& reason);
     void setReadyState(ReadyState state);
 
     std::string   _method;