-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshapemapgroupdata.cpp
40 lines (34 loc) · 1.39 KB
/
shapemapgroupdata.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// SPDX-FileCopyrightText: 2000-2010 University College London, Alasdair Turner
// SPDX-FileCopyrightText: 2011-2012 Tasos Varoudis
// SPDX-FileCopyrightText: 2024 Petros Koutsolampros
//
// SPDX-License-Identifier: GPL-3.0-or-later
#include "shapemapgroupdata.hpp"
#include "shapemap.hpp"
#include "genlib/stringutils.hpp"
bool ShapeMapGroupData::readInNameAndRegion(std::istream &stream) {
name = dXstring::readString(stream);
stream.read(reinterpret_cast<char *>(®ion), sizeof(region));
if (name.empty()) {
name = "<unknown>";
}
return true;
}
std::tuple<std::vector<ShapeMap>, std::vector<std::tuple<bool, bool, int>>>
ShapeMapGroupData::readSpacePixels(std::istream &stream) {
std::vector<ShapeMap> spacePixels;
std::vector<std::tuple<bool, bool, int>> displayData;
int count;
stream.read(reinterpret_cast<char *>(&count), sizeof(count));
for (int i = 0; i < count; i++) {
spacePixels.emplace_back();
auto [completed, editable, shown, displayedAttribute] = spacePixels.back().read(stream);
displayData.emplace_back(editable, shown, displayedAttribute);
}
return std::make_tuple(std::move(spacePixels), displayData);
}
bool ShapeMapGroupData::writeOutNameAndRegion(std::ostream &stream) const {
dXstring::writeString(stream, name);
stream.write(reinterpret_cast<const char *>(®ion), sizeof(region));
return true;
}