-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from zerebubuth/changesets
Add support for changesets
- Loading branch information
Showing
50 changed files
with
1,746 additions
and
437 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#ifndef API06_CHANGESET_HANDLER_HPP | ||
#define API06_CHANGESET_HANDLER_HPP | ||
|
||
#include "cgimap/handler.hpp" | ||
#include "cgimap/osm_current_responder.hpp" | ||
#include "cgimap/request.hpp" | ||
#include <string> | ||
|
||
namespace api06 { | ||
|
||
class changeset_responder : public osm_current_responder { | ||
public: | ||
changeset_responder(mime::type, osm_changeset_id_t, bool, factory_ptr &); | ||
~changeset_responder(); | ||
|
||
private: | ||
osm_changeset_id_t id; | ||
bool include_discussion; | ||
}; | ||
|
||
class changeset_handler : public handler { | ||
public: | ||
changeset_handler(request &req, osm_changeset_id_t id); | ||
~changeset_handler(); | ||
|
||
std::string log_name() const; | ||
responder_ptr_t responder(factory_ptr &x) const; | ||
|
||
private: | ||
osm_changeset_id_t id; | ||
bool include_discussion; | ||
}; | ||
|
||
} // namespace api06 | ||
|
||
#endif /* API06_CHANGESET_HANDLER_HPP */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#ifndef BACKEND_APIDB_PQXX_STRING_TRAITS_HPP | ||
#define BACKEND_APIDB_PQXX_STRING_TRAITS_HPP | ||
|
||
#include "cgimap/types.hpp" | ||
#include "cgimap/infix_ostream_iterator.hpp" | ||
#include <vector> | ||
#include <set> | ||
#include <sstream> | ||
#include <algorithm> | ||
#include <pqxx/pqxx> | ||
|
||
namespace pqxx { | ||
|
||
/* | ||
* PQXX_ARRAY_STRING_TRAITS provides an instantiation of the string_traits | ||
* template from PQXX which is used to stringify arguments when sending them | ||
* to Postgres. Cgimap uses several different containers across different | ||
* integer types, all of which stringify to arrays in the same way. | ||
* | ||
* Note that it would be nicer to hide this in a .cpp, but it seems that the | ||
* implementation has to be available when used in the prepared statement | ||
* code. | ||
*/ | ||
#define PQXX_ARRAY_STRING_TRAITS(type) \ | ||
template <> struct string_traits<type> { \ | ||
static const char *name() { return #type; } \ | ||
static bool has_null() { return false; } \ | ||
static bool is_null(const type &) { return false; } \ | ||
static std::stringstream null() { \ | ||
internal::throw_null_conversion(name()); \ | ||
throw 0; /* need this to satisfy compiler escape detection */ \ | ||
} \ | ||
static void from_string(const char[], type &) {} \ | ||
static std::string to_string(const type &ids) { \ | ||
std::stringstream ostr; \ | ||
ostr << "{"; \ | ||
std::copy(ids.begin(), ids.end(), \ | ||
infix_ostream_iterator<type::value_type>(ostr, ",")); \ | ||
ostr << "}"; \ | ||
return ostr.str(); \ | ||
} \ | ||
} | ||
|
||
PQXX_ARRAY_STRING_TRAITS(std::vector<osm_nwr_id_t>); | ||
PQXX_ARRAY_STRING_TRAITS(std::set<osm_nwr_id_t>); | ||
PQXX_ARRAY_STRING_TRAITS(std::vector<tile_id_t>); | ||
PQXX_ARRAY_STRING_TRAITS(std::vector<osm_changeset_id_t>); | ||
PQXX_ARRAY_STRING_TRAITS(std::set<osm_changeset_id_t>); | ||
|
||
} // namespace pqxx | ||
|
||
#endif /* BACKEND_APIDB_PQXX_STRING_TRAITS_HPP */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.