source: subversion/applications/lib/libosm/Client.h @ 11684

Last change on this file since 11684 was 11684, checked in by nienhueser, 11 years ago

Less inline definitions. Start to document things (doxygen style)

File size: 2.1 KB
Line 
1#include <string>
2#include <curl/curl.h>
3
4namespace OSM
5{
6
7typedef struct
8{
9        char *data;
10        int nbytes;
11} Data;
12
13/**
14 * I/O. Handles reading from and writing to OSM servers
15 */
16class Client
17{
18public:
19        /**
20         * Constructor
21         * @param urlbase Server URL base (parameters are added automatically)
22         */
23        Client(const std::string& urlbase);
24
25        /**
26         * Change user/password used to login to the OSM server
27         * @param user Username for HTTP authentification
28         * @param pass Password for HTTP authentification
29         */
30        void setLoginDetails(const std::string& user, const std::string& pass);
31
32        /**
33         * Access data of the given type for the given bounding box
34         * @param apicall API string to identify wanted objects - e.g. "map" or "node" or "way" or "relation" or "*"
35         * @param west Longitude of the left (westernmost) side of the bounding box
36         * @param south Latitude of the bottom (southernmost) side of the bounding box
37         * @param east Longitude of the right (easternmost) side of the bounding box
38         * @param north Latitude of the top (northernmost) side of the bounding box
39         * @return Server output, OSM XML if all goes well
40         */
41        std::string grabOSM(const char *apicall, double west, double south,
42                        double east, double north);
43
44        /**
45         * Access data from the OSM server
46         * @param apicall Second part of the url. The URL used will be urlbase/apicall,
47         * where urlbase is the parameter set in the constructor
48         * @return Server output, OSM XML if all goes well
49         */
50        std::string grabOSM(const char *apicall);
51
52        /**
53         * Write data to the OSM server
54         * @param apicall Second part of the url. The URL used will be urlbase/apicall,
55         * where urlbase is the parameter set in the constructor
56         * @param data Data to post to the OSM server
57         * @return Server output
58         */
59        std::string putToOSM(char* apicall, char* data);
60
61private:
62        std::string urlbase, username, password;
63
64        std::string grab(const char *url);
65        std::string doGrab(CURL *curl, const char *url);
66        static size_t responseCallback(void *ptr, size_t size, size_t nmemb,
67                        void *d);
68        static size_t putCallback(void *bufptr, size_t size, size_t nitems,
69                        void *userp);
70};
71
72}
Note: See TracBrowser for help on using the repository browser.