Rosetta
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
curl.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file utility/curl.hh
11 /// @brief Implements a OO interface to CURL wrapping and hiding the ugly C callbacks.
12 /// @author Mike Tyka (mike.tyka@gmail.com)
13 
14 #ifndef INCLUDED_utility_curl_hh
15 #define INCLUDED_utility_curl_hh
16 
17 #ifdef WITHCURL
18 
19 #include <curl/curl.h>
20 #include <string>
21 
22 
23 namespace utility {
24 
25 // must include -lcurl during linking if you're using -dwithcurl
26 
27 class CurlGet {
28  public:
29  CurlGet();
30  static int writer(char *data, std::size_t size, std::size_t nmemb, std::string *buffer);
31  private:
32  char *getErrorBuffer();
33  std::string * getbuffer();
34  public:
35  std::string get( const std::string &url );
36  private:
37  // Write any errors in here
38  char errorBuffer[CURL_ERROR_SIZE];
39  // Write all expected data in here
40  std::string buffer;
41 };
42 
43 
44 class CurlPost {
45  public:
46  CurlPost();
47  // This is the writer call back function used by curl
48  static int writer(char *data, std::size_t size, std::size_t nmemb, std::string *buffer);
49  private:
50  char *getErrorBuffer();
51  std::string * getreadbuffer();
52  std::string * getwritebuffer();
53  public:
54  std::string post( const std::string &url, const std::string &data, const std::string &fields );
55  private:
56  // Write any errors in here
57  char errorBuffer[CURL_ERROR_SIZE];
58  // Write all expected input and out data in here
59  std::string readbuffer;
60  std::string writebuffer;
61 };
62 
63 }
64 
65 #endif // WITHCURL
66 
67 #endif // INCLUDED_utility_curl_hh
dictionary size
Definition: amino_acids.py:44