move casts from/to string into static class
This commit is contained in:
@@ -28,10 +28,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#ifndef EXTRACTION_HELPER_FUNCTIONS_H
|
||||
#define EXTRACTION_HELPER_FUNCTIONS_H
|
||||
|
||||
#include "../Util/StringUtil.h"
|
||||
#include "../Util/cast.hpp"
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/algorithm/string_regex.hpp>
|
||||
#include <boost/spirit/include/qi.hpp>
|
||||
#include <boost/regex.hpp>
|
||||
|
||||
#include <limits>
|
||||
@@ -68,18 +69,18 @@ inline unsigned parseDuration(const std::string &s)
|
||||
{
|
||||
if (1 == result.size())
|
||||
{
|
||||
minutes = StringToUint(result[0]);
|
||||
minutes = cast::string_to_int(result[0]);
|
||||
}
|
||||
if (2 == result.size())
|
||||
{
|
||||
minutes = StringToUint(result[1]);
|
||||
hours = StringToUint(result[0]);
|
||||
minutes = cast::string_to_int(result[1]);
|
||||
hours = cast::string_to_int(result[0]);
|
||||
}
|
||||
if (3 == result.size())
|
||||
{
|
||||
seconds = StringToUint(result[2]);
|
||||
minutes = StringToUint(result[1]);
|
||||
hours = StringToUint(result[0]);
|
||||
seconds = cast::string_to_int(result[2]);
|
||||
minutes = cast::string_to_int(result[1]);
|
||||
hours = cast::string_to_int(result[0]);
|
||||
}
|
||||
return 10 * (3600 * hours + 60 * minutes + seconds);
|
||||
}
|
||||
|
||||
@@ -34,6 +34,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
#include "../DataStructures/ImportNode.h"
|
||||
#include "../DataStructures/InputReaderFactory.h"
|
||||
#include "../DataStructures/Restriction.h"
|
||||
#include "../Util/cast.hpp"
|
||||
#include "../Util/SimpleLogger.h"
|
||||
#include "../Util/StringUtil.h"
|
||||
#include "../typedefs.h"
|
||||
@@ -168,17 +169,17 @@ InputRestrictionContainer XMLParser::ReadXMLRestriction()
|
||||
if (xmlStrEqual(role, (const xmlChar *)"to") &&
|
||||
xmlStrEqual(type, (const xmlChar *)"way"))
|
||||
{
|
||||
restriction.toWay = StringToUint((const char *)ref);
|
||||
restriction.toWay = cast::string_to_uint((const char *)ref);
|
||||
}
|
||||
if (xmlStrEqual(role, (const xmlChar *)"from") &&
|
||||
xmlStrEqual(type, (const xmlChar *)"way"))
|
||||
{
|
||||
restriction.fromWay = StringToUint((const char *)ref);
|
||||
restriction.fromWay = cast::string_to_uint((const char *)ref);
|
||||
}
|
||||
if (xmlStrEqual(role, (const xmlChar *)"via") &&
|
||||
xmlStrEqual(type, (const xmlChar *)"node"))
|
||||
{
|
||||
restriction.restriction.viaNode = StringToUint((const char *)ref);
|
||||
restriction.restriction.viaNode = cast::string_to_uint((const char *)ref);
|
||||
}
|
||||
|
||||
if (nullptr != type)
|
||||
@@ -231,7 +232,7 @@ ExtractionWay XMLParser::ReadXMLWay()
|
||||
xmlStrEqual(child_name, (const xmlChar *)"way") == 1)
|
||||
{
|
||||
xmlChar *way_id = xmlTextReaderGetAttribute(inputReader, (const xmlChar *)"id");
|
||||
way.id = StringToUint((char *)way_id);
|
||||
way.id = cast::string_to_uint((char *)way_id);
|
||||
xmlFree(way_id);
|
||||
xmlFree(child_name);
|
||||
break;
|
||||
@@ -265,7 +266,7 @@ ExtractionWay XMLParser::ReadXMLWay()
|
||||
xmlChar *ref = xmlTextReaderGetAttribute(inputReader, (const xmlChar *)"ref");
|
||||
if (ref != nullptr)
|
||||
{
|
||||
way.path.push_back(StringToUint((const char *)ref));
|
||||
way.path.push_back(cast::string_to_uint((const char *)ref));
|
||||
xmlFree(ref);
|
||||
}
|
||||
}
|
||||
@@ -281,19 +282,19 @@ ImportNode XMLParser::ReadXMLNode()
|
||||
xmlChar *attribute = xmlTextReaderGetAttribute(inputReader, (const xmlChar *)"lat");
|
||||
if (attribute != nullptr)
|
||||
{
|
||||
node.lat = static_cast<int>(COORDINATE_PRECISION * StringToDouble((const char *)attribute));
|
||||
node.lat = static_cast<int>(COORDINATE_PRECISION * cast::string_to_double((const char *)attribute));
|
||||
xmlFree(attribute);
|
||||
}
|
||||
attribute = xmlTextReaderGetAttribute(inputReader, (const xmlChar *)"lon");
|
||||
if (attribute != nullptr)
|
||||
{
|
||||
node.lon = static_cast<int>(COORDINATE_PRECISION * StringToDouble((const char *)attribute));
|
||||
node.lon = static_cast<int>(COORDINATE_PRECISION * cast::string_to_double((const char *)attribute));
|
||||
xmlFree(attribute);
|
||||
}
|
||||
attribute = xmlTextReaderGetAttribute(inputReader, (const xmlChar *)"id");
|
||||
if (attribute != nullptr)
|
||||
{
|
||||
node.node_id = StringToUint((const char *)attribute);
|
||||
node.node_id = cast::string_to_uint((const char *)attribute);
|
||||
xmlFree(attribute);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user