KOSMIndoorMap

o5mwriter.h
1/*
2 SPDX-FileCopyrightText: 2023 Volker Krause <vkrause@kde.org>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6#ifndef OSM_O5MWRITER_H
7#define OSM_O5MWRITER_H
8
9#include "abstractwriter.h"
10
11#include <cstdint>
12#include <cstring>
13#include <string>
14#include <unordered_map>
15
16#include <QDebug>
17
18namespace OSM {
19
20struct O5mStringPair {
21 std::string s1;
22 std::string s2;
23
24 [[nodiscard]] inline bool operator==(const O5mStringPair &other) const {
25 return s1 == other.s1 && s2 == other.s2;
26 }
27};
28}
29
30template<>
31struct std::hash<OSM::O5mStringPair>
32{
33
34 [[nodiscard]] std::size_t operator()(const OSM::O5mStringPair &p) const noexcept
35 {
36 std::size_t h1 = std::hash<std::string>{}(p.s1);
37 std::size_t h2 = std::hash<std::string>{}(p.s2);
38 return h1 ^ (h2 << 1);
39 }
40};
41
42namespace OSM {
43
44/** Serialize an OSM::DataSet into the o5m file format. */
46{
47private:
48 void writeToIODevice(const OSM::DataSet& dataSet, QIODevice* io) override;
49
50 void writeNodes(const OSM::DataSet &dataSet, QIODevice *io);
51 void writeWays(const OSM::DataSet &dataSet, QIODevice *io);
52 void writeRelations(const OSM::DataSet &dataSet, QIODevice *io);
53 template <typename T> void writeTags(const T &elem, QIODevice *io);
54 void writeStringPair(const char *s1, const char *s2, QIODevice *io);
55
56 std::unordered_map<O5mStringPair, int16_t> m_stringTable;
57};
58
59}
60
61#endif // OSM_O5MWRITER_H
Abstract base class for OSM file format writers.
A set of nodes, ways and relations.
Definition datatypes.h:340
Serialize an OSM::DataSet into the o5m file format.
Definition o5mwriter.h:46
Low-level types and functions to work with raw OSM data as efficiently as possible.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:20:03 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.