Consts and references

This commit is contained in:
2022-09-09 20:10:38 +02:00
parent b050c23577
commit 699e2a4784
16 changed files with 156 additions and 179 deletions
+8 -3
View File
@@ -4,6 +4,7 @@
#include <cstdint>
#include <fstream>
#include <string>
#include <utility>
#include <vector>
#include "constants.h"
@@ -24,15 +25,19 @@ namespace germanairlinesva_logbook
class Logbook
{
private:
std::vector<std::uint8_t> file;
std::vector<LogbookEntry> entries;
void fromFile(const std::string &file);
void readVersion1(std::ifstream &in);
public:
Logbook();
void addEntry(LogbookEntry entry);
void toFile();
template <class... Args> inline void addEntry(Args &&...args)
{
this->entries.emplace_back(std::forward<Args>(args)...);
}
void toFile() const;
};
} // namespace germanairlinesva_logbook
+8 -21
View File
@@ -71,14 +71,14 @@ namespace germanairlinesva_logbook
* STRLEN | STRING
* Postamble (5)
* FLOAT32 | BITFIELD
* --------------+---
* POINTS | FLAGS
* FLOAT | BITFIELD
* -------+---------
* POINTS | FLAGS
* Flags Bitfield
* 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
* ---+---+---+---+---+---+---+-----
* NIL|NIL|NIL|NIL|NIL|NIL|NIL|FILED
* 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0
* ----+-----+-----+-----+-----+-----+-----+------
* NIL | NIL | NIL | NIL | NIL | NIL | NIL | FILED
*/
class LogbookEntry
{
@@ -145,21 +145,8 @@ namespace germanairlinesva_logbook
float points,
std::uint8_t flags);
inline std::uint8_t *getBinaryData() { return file.data(); }
inline std::size_t getBinaryLength() { return file.size(); }
std::string to_string() const
{
std::ostringstream str;
// TO STR
return str.str();
}
friend inline std::ostream &operator<<(std::ostream &os,
const LogbookEntry &gate)
{
return os << gate.to_string();
}
inline const std::uint8_t *getBinaryData() const { return file.data(); }
inline std::size_t getBinaryLength() const { return file.size(); }
};
} // namespace germanairlinesva_logbook
+3 -3
View File
@@ -28,10 +28,10 @@ namespace germanairlinesva_recording
std::vector<std::uint8_t> file{'V', 'G', 'A', 'R', '\0', 1};
public:
void addSegment(PathSegment segment);
void addSegment(const PathSegment &segment);
inline std::uint8_t *getBinaryData() { return file.data(); }
inline std::size_t getBinaryLength() { return file.size(); }
inline const std::uint8_t *getBinaryData() const { return file.data(); }
inline std::size_t getBinaryLength() const { return file.size(); }
};
} // namespace germanairlinesva_recording
+2 -2
View File
@@ -31,8 +31,8 @@ namespace germanairlinesva_recording
std::uint16_t groundSpeed,
struct germanairlinesva_geodata::point coordinates);
inline std::uint8_t *getBinaryData() { return file.data(); }
inline std::size_t getBinaryLength() { return file.size(); }
inline const std::uint8_t *getBinaryData() const { return file.data(); }
inline std::size_t getBinaryLength() const { return file.size(); }
friend inline bool operator==(const PathSegment &lhs,
const PathSegment &rhs)