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