diff options
| author | Rutger Broekhoff | 2026-08-28 22:22:24 +0200 |
|---|---|---|
| committer | Rutger Broekhoff | 2026-08-28 22:22:24 +0200 |
| commit | b0d7600970d2fdb1eb6fff813c7336ea34d4e228 (patch) | |
| tree | 051d6f80c7e332f4b31027025ae7c60c7ac70742 /server/src/gpx.cpp | |
| parent | 70643a9e4821bd11c3f363f1708fe420965467d1 (diff) | |
| download | routemon-b0d7600970d2fdb1eb6fff813c7336ea34d4e228.tar.gz routemon-b0d7600970d2fdb1eb6fff813c7336ea34d4e228.zip | |
Indent tweaks
Diffstat (limited to 'server/src/gpx.cpp')
| -rw-r--r-- | server/src/gpx.cpp | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/server/src/gpx.cpp b/server/src/gpx.cpp index f70c133..078248f 100644 --- a/server/src/gpx.cpp +++ b/server/src/gpx.cpp | |||
| @@ -22,7 +22,7 @@ auto qname(std::string_view local) -> xml::qname_view | |||
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | auto parse_wpt(xml::executor_ref e, xml::attribute_view attrs) | 24 | auto parse_wpt(xml::executor_ref e, xml::attribute_view attrs) |
| 25 | -> xml::parser<geo::point> | 25 | -> xml::parser<geo::point> |
| 26 | { | 26 | { |
| 27 | auto parse_xml_double = [](std::string_view sv) -> std::optional<double> | 27 | auto parse_xml_double = [](std::string_view sv) -> std::optional<double> |
| 28 | { return util::parse_double(sv, std::chars_format::fixed); }; | 28 | { return util::parse_double(sv, std::chars_format::fixed); }; |
| @@ -48,11 +48,11 @@ auto parse_wpt(xml::executor_ref e, xml::attribute_view attrs) | |||
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | auto parse_trkseg(xml::executor_ref e, xml::attribute_view) | 50 | auto parse_trkseg(xml::executor_ref e, xml::attribute_view) |
| 51 | -> xml::parser<track_segment> | 51 | -> xml::parser<track_segment> |
| 52 | { | 52 | { |
| 53 | auto s = track_segment{}; | 53 | auto s = track_segment{}; |
| 54 | while (auto mwpt = | 54 | while (auto mwpt = co_await allow_element( |
| 55 | co_await allow_element(e, qname("trkpt"), xml::hohalo<parse_wpt>())) | 55 | e, qname("trkpt"), xml::hohalo<parse_wpt>())) |
| 56 | bgeo::append(s.waypoints, *mwpt); | 56 | bgeo::append(s.waypoints, *mwpt); |
| 57 | co_return std::move(s); | 57 | co_return std::move(s); |
| 58 | } | 58 | } |
| @@ -61,20 +61,20 @@ auto parse_trk(xml::executor_ref e, xml::attribute_view) -> xml::parser<track> | |||
| 61 | { | 61 | { |
| 62 | auto t = track{}; | 62 | auto t = track{}; |
| 63 | t.name = co_await allow_element( | 63 | t.name = co_await allow_element( |
| 64 | e, qname("name"), xml::hohalo<xml::read_string_contents>()); | 64 | e, qname("name"), xml::hohalo<xml::read_string_contents>()); |
| 65 | co_await allow_element( | 65 | co_await allow_element( |
| 66 | e, qname("cmt"), xml::hohalo<xml::ignore_element_contents>()); | 66 | e, qname("cmt"), xml::hohalo<xml::ignore_element_contents>()); |
| 67 | t.desc = co_await allow_element( | 67 | t.desc = co_await allow_element( |
| 68 | e, qname("desc"), xml::hohalo<xml::read_string_contents>()); | 68 | e, qname("desc"), xml::hohalo<xml::read_string_contents>()); |
| 69 | co_await xml::ignore_contents(e, /* until */ qname("trkseg")); | 69 | co_await xml::ignore_contents(e, /* until */ qname("trkseg")); |
| 70 | while (auto mseg = co_await allow_element( | 70 | while (auto mseg = co_await allow_element( |
| 71 | e, qname("trkseg"), xml::hohalo<parse_trkseg>())) | 71 | e, qname("trkseg"), xml::hohalo<parse_trkseg>())) |
| 72 | t.segments.push_back(std::move(*mseg)); | 72 | t.segments.push_back(std::move(*mseg)); |
| 73 | co_return std::move(t); | 73 | co_return std::move(t); |
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | auto parse_gpx(xml::executor_ref e, xml::attribute_view attrs) | 76 | auto parse_gpx(xml::executor_ref e, xml::attribute_view attrs) |
| 77 | -> xml::parser<file> | 77 | -> xml::parser<file> |
| 78 | { | 78 | { |
| 79 | auto f = file{}; | 79 | auto f = file{}; |
| 80 | if (attrs.lookup(qname("version")) != "1.0"sv) | 80 | if (attrs.lookup(qname("version")) != "1.0"sv) |
| @@ -85,13 +85,13 @@ auto parse_gpx(xml::executor_ref e, xml::attribute_view attrs) | |||
| 85 | throw std::runtime_error{"expected GPX file to have creator"}; | 85 | throw std::runtime_error{"expected GPX file to have creator"}; |
| 86 | 86 | ||
| 87 | f.meta.name = co_await allow_element( | 87 | f.meta.name = co_await allow_element( |
| 88 | e, qname("name"), xml::hohalo<xml::read_string_contents>()); | 88 | e, qname("name"), xml::hohalo<xml::read_string_contents>()); |
| 89 | f.meta.desc = co_await allow_element( | 89 | f.meta.desc = co_await allow_element( |
| 90 | e, qname("desc"), xml::hohalo<xml::read_string_contents>()); | 90 | e, qname("desc"), xml::hohalo<xml::read_string_contents>()); |
| 91 | 91 | ||
| 92 | co_await xml::ignore_contents(e, /* until */ qname("trk")); | 92 | co_await xml::ignore_contents(e, /* until */ qname("trk")); |
| 93 | while (auto mtrk = | 93 | while (auto mtrk = |
| 94 | co_await allow_element(e, qname("trk"), xml::hohalo<parse_trk>())) | 94 | co_await allow_element(e, qname("trk"), xml::hohalo<parse_trk>())) |
| 95 | f.tracks.push_back(std::move(*mtrk)); | 95 | f.tracks.push_back(std::move(*mtrk)); |
| 96 | co_await xml::ignore_contents(e); | 96 | co_await xml::ignore_contents(e); |
| 97 | 97 | ||
| @@ -109,19 +109,19 @@ auto qname(std::string_view local) -> xml::qname_view | |||
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | auto parse_metadata(xml::executor_ref e, xml::attribute_view) | 111 | auto parse_metadata(xml::executor_ref e, xml::attribute_view) |
| 112 | -> xml::parser<metadata> | 112 | -> xml::parser<metadata> |
| 113 | { | 113 | { |
| 114 | auto meta = metadata{}; | 114 | auto meta = metadata{}; |
| 115 | meta.name = co_await allow_element( | 115 | meta.name = co_await allow_element( |
| 116 | e, qname("name"), xml::hohalo<xml::read_string_contents>()); | 116 | e, qname("name"), xml::hohalo<xml::read_string_contents>()); |
| 117 | meta.desc = co_await allow_element( | 117 | meta.desc = co_await allow_element( |
| 118 | e, qname("desc"), xml::hohalo<xml::read_string_contents>()); | 118 | e, qname("desc"), xml::hohalo<xml::read_string_contents>()); |
| 119 | co_await xml::ignore_contents(e); | 119 | co_await xml::ignore_contents(e); |
| 120 | co_return meta; | 120 | co_return meta; |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | auto parse_wpt(xml::executor_ref e, xml::attribute_view attrs) | 123 | auto parse_wpt(xml::executor_ref e, xml::attribute_view attrs) |
| 124 | -> xml::parser<geo::point> | 124 | -> xml::parser<geo::point> |
| 125 | { | 125 | { |
| 126 | auto parse_xml_double = [](std::string_view sv) -> std::optional<double> | 126 | auto parse_xml_double = [](std::string_view sv) -> std::optional<double> |
| 127 | { return util::parse_double(sv, std::chars_format::fixed); }; | 127 | { return util::parse_double(sv, std::chars_format::fixed); }; |
| @@ -147,14 +147,14 @@ auto parse_wpt(xml::executor_ref e, xml::attribute_view attrs) | |||
| 147 | } | 147 | } |
| 148 | 148 | ||
| 149 | auto parse_trkseg(xml::executor_ref e, xml::attribute_view) | 149 | auto parse_trkseg(xml::executor_ref e, xml::attribute_view) |
| 150 | -> xml::parser<track_segment> | 150 | -> xml::parser<track_segment> |
| 151 | { | 151 | { |
| 152 | auto s = track_segment{}; | 152 | auto s = track_segment{}; |
| 153 | while (auto mwpt = | 153 | while (auto mwpt = co_await allow_element( |
| 154 | co_await allow_element(e, qname("trkpt"), xml::hohalo<parse_wpt>())) | 154 | e, qname("trkpt"), xml::hohalo<parse_wpt>())) |
| 155 | bgeo::append(s.waypoints, *mwpt); | 155 | bgeo::append(s.waypoints, *mwpt); |
| 156 | co_await allow_element( | 156 | co_await allow_element( |
| 157 | e, qname("extensions"), xml::hohalo<xml::ignore_element_contents>()); | 157 | e, qname("extensions"), xml::hohalo<xml::ignore_element_contents>()); |
| 158 | co_return std::move(s); | 158 | co_return std::move(s); |
| 159 | } | 159 | } |
| 160 | 160 | ||
| @@ -162,20 +162,20 @@ auto parse_trk(xml::executor_ref e, xml::attribute_view) -> xml::parser<track> | |||
| 162 | { | 162 | { |
| 163 | auto t = track{}; | 163 | auto t = track{}; |
| 164 | t.name = co_await allow_element( | 164 | t.name = co_await allow_element( |
| 165 | e, qname("name"), xml::hohalo<xml::read_string_contents>()); | 165 | e, qname("name"), xml::hohalo<xml::read_string_contents>()); |
| 166 | co_await allow_element( | 166 | co_await allow_element( |
| 167 | e, qname("cmt"), xml::hohalo<xml::ignore_element_contents>()); | 167 | e, qname("cmt"), xml::hohalo<xml::ignore_element_contents>()); |
| 168 | t.desc = co_await allow_element( | 168 | t.desc = co_await allow_element( |
| 169 | e, qname("desc"), xml::hohalo<xml::read_string_contents>()); | 169 | e, qname("desc"), xml::hohalo<xml::read_string_contents>()); |
| 170 | co_await xml::ignore_contents(e, /* until */ qname("trkseg")); | 170 | co_await xml::ignore_contents(e, /* until */ qname("trkseg")); |
| 171 | while (auto mseg = co_await allow_element( | 171 | while (auto mseg = co_await allow_element( |
| 172 | e, qname("trkseg"), xml::hohalo<parse_trkseg>())) | 172 | e, qname("trkseg"), xml::hohalo<parse_trkseg>())) |
| 173 | t.segments.push_back(std::move(*mseg)); | 173 | t.segments.push_back(std::move(*mseg)); |
| 174 | co_return std::move(t); | 174 | co_return std::move(t); |
| 175 | } | 175 | } |
| 176 | 176 | ||
| 177 | auto parse_gpx(xml::executor_ref e, xml::attribute_view attrs) | 177 | auto parse_gpx(xml::executor_ref e, xml::attribute_view attrs) |
| 178 | -> xml::parser<file> | 178 | -> xml::parser<file> |
| 179 | { | 179 | { |
| 180 | auto f = file{}; | 180 | auto f = file{}; |
| 181 | if (attrs.lookup(qname("version")) != "1.1"sv) | 181 | if (attrs.lookup(qname("version")) != "1.1"sv) |
| @@ -186,14 +186,14 @@ auto parse_gpx(xml::executor_ref e, xml::attribute_view attrs) | |||
| 186 | throw std::runtime_error{"expected GPX file to have creator"}; | 186 | throw std::runtime_error{"expected GPX file to have creator"}; |
| 187 | 187 | ||
| 188 | if (auto mmeta = co_await allow_element( | 188 | if (auto mmeta = co_await allow_element( |
| 189 | e, qname("metadata"), xml::hohalo<parse_metadata>())) | 189 | e, qname("metadata"), xml::hohalo<parse_metadata>())) |
| 190 | f.meta = *mmeta; | 190 | f.meta = *mmeta; |
| 191 | co_await xml::ignore_contents(e, /* until */ qname("trk")); | 191 | co_await xml::ignore_contents(e, /* until */ qname("trk")); |
| 192 | while (auto mtrk = | 192 | while (auto mtrk = |
| 193 | co_await allow_element(e, qname("trk"), xml::hohalo<parse_trk>())) | 193 | co_await allow_element(e, qname("trk"), xml::hohalo<parse_trk>())) |
| 194 | f.tracks.push_back(std::move(*mtrk)); | 194 | f.tracks.push_back(std::move(*mtrk)); |
| 195 | co_await allow_element( | 195 | co_await allow_element( |
| 196 | e, qname("extensions"), xml::hohalo<xml::ignore_element_contents>()); | 196 | e, qname("extensions"), xml::hohalo<xml::ignore_element_contents>()); |
| 197 | 197 | ||
| 198 | co_return std::move(f); | 198 | co_return std::move(f); |
| 199 | } | 199 | } |
| @@ -205,14 +205,14 @@ auto parse_file(xml::executor_ref e) -> xml::parser<file> | |||
| 205 | auto decl = co_await expect_event<xml::xml_decl_event>(e); | 205 | auto decl = co_await expect_event<xml::xml_decl_event>(e); |
| 206 | if (decl.version != "1.0"sv) | 206 | if (decl.version != "1.0"sv) |
| 207 | throw std::runtime_error{std::format( | 207 | throw std::runtime_error{std::format( |
| 208 | "unsupported XML version, got {}", std::string_view{decl.version})}; | 208 | "unsupported XML version, got {}", std::string_view{decl.version})}; |
| 209 | if (decl.encoding != "UTF-8"sv) | 209 | if (decl.encoding != "UTF-8"sv) |
| 210 | throw std::runtime_error{"unsupported encoding"}; | 210 | throw std::runtime_error{"unsupported encoding"}; |
| 211 | if (auto mf = co_await allow_element( | 211 | if (auto mf = co_await allow_element( |
| 212 | e, v10::qname("gpx"), xml::hohalo<v10::parse_gpx>())) | 212 | e, v10::qname("gpx"), xml::hohalo<v10::parse_gpx>())) |
| 213 | co_return std::move(*mf); | 213 | co_return std::move(*mf); |
| 214 | if (auto mf = co_await allow_element( | 214 | if (auto mf = co_await allow_element( |
| 215 | e, v11::qname("gpx"), xml::hohalo<v11::parse_gpx>())) | 215 | e, v11::qname("gpx"), xml::hohalo<v11::parse_gpx>())) |
| 216 | co_return std::move(*mf); | 216 | co_return std::move(*mf); |
| 217 | throw std::runtime_error{"no supported GPX document found"}; | 217 | throw std::runtime_error{"no supported GPX document found"}; |
| 218 | } | 218 | } |