MCPcopy Create free account
hub / github.com/PDAL/PDAL / inferType

Method inferType

pdal/Metadata.cpp:53–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

51
52
53std::string Metadata::inferType(const std::string& val)
54{
55 size_t pos;
56
57 long l = 0;
58 try
59 {
60 pos = 0;
61 l = std::stol(val, &pos);
62 }
63 catch (std::invalid_argument&)
64 {}
65 if (pos == val.length())
66 return (l < 0 ? "nonNegativeInteger" : "integer");
67
68 try
69 {
70 pos = 0;
71
72 // silence discarding return value of function with 'nodiscard' attribute
73 // with the (void) cast
74 (void)std::stod(val, &pos);
75 }
76 catch(std::invalid_argument&)
77 {}
78
79 if (pos == val.length())
80 return "double";
81
82 BOX2D b2d;
83 std::istringstream iss1(val);
84 try
85 {
86 iss1 >> b2d;
87 if (iss1.good())
88 return "bounds";
89 }
90 catch (const BOX2D::error&)
91 {}
92
93 BOX3D b3d;
94 std::istringstream iss2(val);
95 try
96 {
97 iss2 >> b3d;
98 if (iss2.good())
99 return "bounds";
100 }
101 catch (const BOX3D::error&)
102 {}
103
104 if (val == "true" || val == "false")
105 return "boolean";
106
107 try
108 {
109 gdal::ErrorHandlerSuspender();
110

Callers

nothing calls this directly

Calls 2

isJSONFunction · 0.85
lengthMethod · 0.45

Tested by

no test coverage detected