reformatting RequestHandler
This commit is contained in:
parent
584ba10726
commit
07231d3706
@ -41,9 +41,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <cstdio>
|
||||
#endif
|
||||
|
||||
|
||||
namespace boost {
|
||||
namespace filesystem {
|
||||
namespace boost
|
||||
{
|
||||
namespace filesystem
|
||||
{
|
||||
|
||||
// Validator for boost::filesystem::path, that verifies that the file
|
||||
// exists. The validate() function must be defined in the same namespace
|
||||
@ -67,37 +68,44 @@ namespace filesystem {
|
||||
// }
|
||||
// }
|
||||
|
||||
// adapted from: http://stackoverflow.com/questions/1746136/how-do-i-normalize-a-pathname-using-boostfilesystem
|
||||
inline boost::filesystem::path portable_canonical(
|
||||
const boost::filesystem::path & relative_path,
|
||||
// adapted from:
|
||||
// http://stackoverflow.com/questions/1746136/how-do-i-normalize-a-pathname-using-boostfilesystem
|
||||
inline boost::filesystem::path
|
||||
portable_canonical(const boost::filesystem::path &relative_path,
|
||||
const boost::filesystem::path ¤t_path = boost::filesystem::current_path())
|
||||
{
|
||||
const boost::filesystem::path absolute_path = boost::filesystem::absolute(
|
||||
relative_path,
|
||||
current_path
|
||||
);
|
||||
const boost::filesystem::path absolute_path =
|
||||
boost::filesystem::absolute(relative_path, current_path);
|
||||
|
||||
boost::filesystem::path canonical_path;
|
||||
for(
|
||||
boost::filesystem::path::const_iterator path_iterator = absolute_path.begin();
|
||||
path_iterator!=absolute_path.end();
|
||||
++path_iterator
|
||||
) {
|
||||
if( ".." == path_iterator->string() ) {
|
||||
for (auto path_iterator = absolute_path.begin(); path_iterator != absolute_path.end();
|
||||
++path_iterator)
|
||||
{
|
||||
if (".." == path_iterator->string())
|
||||
{
|
||||
// /a/b/.. is not necessarily /a if b is a symbolic link
|
||||
if( boost::filesystem::is_symlink(canonical_path) ) {
|
||||
if (boost::filesystem::is_symlink(canonical_path))
|
||||
{
|
||||
canonical_path /= *path_iterator;
|
||||
} else if( ".." == canonical_path.filename() ) {
|
||||
}
|
||||
else if (".." == canonical_path.filename())
|
||||
{
|
||||
// /a/b/../.. is not /a/b/.. under most circumstances
|
||||
// We can end up with ..s in our result because of symbolic links
|
||||
canonical_path /= *path_iterator;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise it should be safe to resolve the parent
|
||||
canonical_path = canonical_path.parent_path();
|
||||
}
|
||||
} else if( "." == path_iterator->string() ) {
|
||||
}
|
||||
else if ("." == path_iterator->string())
|
||||
{
|
||||
// Ignore
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Just cat other path entries
|
||||
canonical_path /= *path_iterator;
|
||||
}
|
||||
@ -109,16 +117,15 @@ inline boost::filesystem::path portable_canonical(
|
||||
|
||||
#if BOOST_FILESYSTEM_VERSION < 3
|
||||
|
||||
inline path temp_directory_path() {
|
||||
inline path temp_directory_path()
|
||||
{
|
||||
char *buffer;
|
||||
buffer = tmpnam(NULL);
|
||||
|
||||
return path(buffer);
|
||||
}
|
||||
|
||||
inline path unique_path(const path&) {
|
||||
return temp_directory_path();
|
||||
}
|
||||
inline path unique_path(const path &) { return temp_directory_path(); }
|
||||
|
||||
#endif
|
||||
}
|
||||
|
@ -36,11 +36,10 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
/* Get angle of line segment (A,C)->(C,B), atan2 magic, formerly cosine theorem*/
|
||||
template <class CoordinateT>
|
||||
inline static double GetAngleBetweenThreeFixedPointCoordinates (
|
||||
const CoordinateT & A,
|
||||
inline static double GetAngleBetweenThreeFixedPointCoordinates(const CoordinateT &A,
|
||||
const CoordinateT &C,
|
||||
const CoordinateT & B
|
||||
) {
|
||||
const CoordinateT &B)
|
||||
{
|
||||
const double v1x = (A.lon - C.lon) / COORDINATE_PRECISION;
|
||||
const double v1y = lat2y(A.lat / COORDINATE_PRECISION) - lat2y(C.lat / COORDINATE_PRECISION);
|
||||
const double v2x = (B.lon - C.lon) / COORDINATE_PRECISION;
|
||||
@ -52,5 +51,4 @@ inline static double GetAngleBetweenThreeFixedPointCoordinates (
|
||||
return angle;
|
||||
}
|
||||
|
||||
|
||||
#endif // COMPUTE_ANGLE_H
|
||||
|
@ -31,35 +31,38 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
template<typename T>
|
||||
inline void sort_unique_resize(std::vector<T> & vector) {
|
||||
template <typename T> inline void sort_unique_resize(std::vector<T> &vector)
|
||||
{
|
||||
std::sort(vector.begin(), vector.end());
|
||||
unsigned number_of_unique_elements = std::unique(vector.begin(), vector.end()) - vector.begin();
|
||||
vector.resize(number_of_unique_elements);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void sort_unique_resize_shrink_vector(std::vector<T> & vector) {
|
||||
template <typename T> inline void sort_unique_resize_shrink_vector(std::vector<T> &vector)
|
||||
{
|
||||
sort_unique_resize(vector);
|
||||
std::vector<T>().swap(vector);
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline void remove_consecutive_duplicates_from_vector(std::vector<T> & vector) {
|
||||
template <typename T> inline void remove_consecutive_duplicates_from_vector(std::vector<T> &vector)
|
||||
{
|
||||
unsigned number_of_unique_elements = std::unique(vector.begin(), vector.end()) - vector.begin();
|
||||
vector.resize(number_of_unique_elements);
|
||||
}
|
||||
|
||||
template <typename FwdIter, typename Func>
|
||||
Func for_each_pair( FwdIter iter_begin, FwdIter iter_end, Func func ) {
|
||||
if( iter_begin == iter_end ) {
|
||||
Func for_each_pair(FwdIter iter_begin, FwdIter iter_end, Func func)
|
||||
{
|
||||
if (iter_begin == iter_end)
|
||||
{
|
||||
return func;
|
||||
}
|
||||
|
||||
FwdIter iter_next = iter_begin;
|
||||
++iter_next;
|
||||
|
||||
for( ; iter_next != iter_end; ++iter_begin, ++iter_next ){
|
||||
for (; iter_next != iter_end; ++iter_begin, ++iter_next)
|
||||
{
|
||||
func(*iter_begin, *iter_next);
|
||||
}
|
||||
return func;
|
||||
|
Loading…
Reference in New Issue
Block a user