CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
Unreal
CarlaUnreal
Plugins
Carla
Source
Carla
Recorder
CarlaRecorderHelpers.h
Go to the documentation of this file.
1
// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2
// de Barcelona (UAB).
3
//
4
// This work is licensed under the terms of the MIT license.
5
// For a copy, see <https://opensource.org/licenses/MIT>.
6
7
#pragma once
8
9
#include <sstream>
10
#include <vector>
11
12
// get the final path + filename
13
std::string
GetRecorderFilename
(std::string Filename);
14
15
// ---------
16
// recorder
17
// ---------
18
19
// write binary data (using sizeof())
20
template
<
typename
T>
21
void
WriteValue
(std::ostream &OutFile,
const
T &InObj)
22
{
23
OutFile.write(
reinterpret_cast<
const
char
*
>
(&InObj),
sizeof
(T));
24
}
25
26
template
<
typename
T>
27
void
WriteStdVector
(std::ostream &OutFile,
const
std::vector<T> &InVec)
28
{
29
WriteValue<uint32_t>
(OutFile, InVec.size());
30
for
(
const
auto
& InObj : InVec)
31
{
32
WriteValue<T>
(OutFile, InObj);
33
}
34
}
35
36
template
<
typename
T>
37
void
WriteTArray
(std::ostream &OutFile,
const
TArray<T> &InVec)
38
{
39
WriteValue<uint32_t>
(OutFile, InVec.Num());
40
for
(
const
auto
& InObj : InVec)
41
{
42
WriteValue<T>
(OutFile, InObj);
43
}
44
}
45
46
// write binary data from FVector
47
void
WriteFVector
(std::ostream &OutFile,
const
FVector &InObj);
48
49
// write binary data from FTransform
50
void
WriteFTransform
(std::ofstream &OutFile,
const
FTransform &InObj);
51
// write binary data from FString (length + text)
52
void
WriteFString
(std::ostream &OutFile,
const
FString &InObj);
53
54
// ---------
55
// replayer
56
// ---------
57
58
// read binary data (using sizeof())
59
template
<
typename
T>
60
void
ReadValue
(std::istream &InFile, T &OutObj)
61
{
62
InFile.read(
reinterpret_cast<
char
*
>
(&OutObj),
sizeof
(T));
63
}
64
65
template
<
typename
T>
66
void
ReadStdVector
(std::istream &InFile, std::vector<T> &OutVec)
67
{
68
uint32_t VecSize = 0;
69
ReadValue<uint32_t>
(InFile, VecSize);
70
OutVec.clear();
71
for
(uint32_t i = 0; (i < VecSize) && InFile; ++i)
72
{
73
T InObj;
74
ReadValue<T>
(InFile, InObj);
75
OutVec.push_back(InObj);
76
}
77
}
78
79
template
<
typename
T>
80
void
ReadTArray
(std::istream &InFile, TArray<T> &OutVec)
81
{
82
uint32_t VecSize = 0;
83
ReadValue<uint32_t>
(InFile, VecSize);
84
OutVec.Empty();
85
for
(uint32_t i = 0; (i < VecSize) && InFile; ++i)
86
{
87
T InObj;
88
ReadValue<T>
(InFile, InObj);
89
OutVec.Add(InObj);
90
}
91
}
92
93
// read binary data from FVector
94
void
ReadFVector
(std::istream &InFile, FVector &OutObj);
95
96
// read binary data from FTransform
97
void
ReadTransform
(std::ifstream &InFile, FTransform &OutObj);
98
// read binary data from FString (length + text)
99
void
ReadFString
(std::istream &InFile, FString &OutObj);
WriteFTransform
void WriteFTransform(std::ofstream &OutFile, const FTransform &InObj)
Definition
CarlaRecorderHelpers.cpp:50
WriteFString
void WriteFString(std::ostream &OutFile, const FString &InObj)
Definition
CarlaRecorderHelpers.cpp:57
ReadFString
void ReadFString(std::istream &InFile, FString &OutObj)
Definition
CarlaRecorderHelpers.cpp:90
WriteFVector
void WriteFVector(std::ostream &OutFile, const FVector &InObj)
Definition
CarlaRecorderHelpers.cpp:42
ReadFVector
void ReadFVector(std::istream &InFile, FVector &OutObj)
Definition
CarlaRecorderHelpers.cpp:72
GetRecorderFilename
std::string GetRecorderFilename(std::string Filename)
Definition
CarlaRecorderHelpers.cpp:21
WriteTArray
void WriteTArray(std::ostream &OutFile, const TArray< T > &InVec)
Definition
CarlaRecorderHelpers.h:37
ReadTransform
void ReadTransform(std::ifstream &InFile, FTransform &OutObj)
WriteStdVector
void WriteStdVector(std::ostream &OutFile, const std::vector< T > &InVec)
Definition
CarlaRecorderHelpers.h:27
ReadTArray
void ReadTArray(std::istream &InFile, TArray< T > &OutVec)
Definition
CarlaRecorderHelpers.h:80
ReadStdVector
void ReadStdVector(std::istream &InFile, std::vector< T > &OutVec)
Definition
CarlaRecorderHelpers.h:66
WriteValue
void WriteValue(std::ostream &OutFile, const T &InObj)
Definition
CarlaRecorderHelpers.h:21
ReadValue
void ReadValue(std::istream &InFile, T &OutObj)
Definition
CarlaRecorderHelpers.h:60
Generated by
1.18.0