PhoenixSerializer  3.0.0
PhoenixSerializer is a framework to save/load/serialize/deserialize data
Loading...
Searching...
No Matches
data_file.h File Reference
#include "data_stream.h"
Include dependency graph for data_file.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

template<typename T>
bool data_load (const std::string &fileName, T &data)
 Load data from a message.
template<typename T>
bool data_load (const std::string &fileName, T *data, size_t nbElement)
 Load data from a message.
template<typename T>
bool data_load (FILE *iter, T &data)
 Load data from a message.
template<typename T>
bool data_load (FILE *iter, T *data, size_t nbElement)
 Load data from a message.
template<typename T>
bool data_save (const std::string &fileName, const T &data)
 Save data in a message.
template<typename T>
bool data_save (const std::string &fileName, const T *data, size_t nbElement)
 Save data in a message.
template<typename T>
bool data_save (FILE *iter, const T &data)
 Save data in a message.
template<typename T>
bool data_save (FILE *iter, const T *data, size_t nbElement)
 Save data in a message.

Function Documentation

◆ data_load() [1/4]

template<typename T>
bool data_load ( const std::string & fileName,
T & data )

Load data from a message.

Parameters
fileName: name of the file to be read
[out]data: data to be loaded from the message
Returns
true on success, false otherwise

Definition at line 93 of file data_file.h.

93 {
94 FILE * iter = fopen(fileName.c_str(), "r");
95 if(iter == nullptr) {
96 return false;
97 }
99 //The file was only read, a failure on close has no consequence
100 (void)fclose(iter);
101 return b;
102}
static bool phoenix_serialize(Stream &ds, T &data)
Dummy function to catch if a type is not specialised.

References data_load(), and Serializer< Stream, Mode, T >::phoenix_serialize().

Here is the call graph for this function:

◆ data_load() [2/4]

template<typename T>
bool data_load ( const std::string & fileName,
T * data,
size_t nbElement )

Load data from a message.

Parameters
fileName: name of the file to be read
[out]data: data to be loaded from the message
nbElement: number of elements in the data
Returns
true on success, false otherwise

Definition at line 111 of file data_file.h.

111 {
112 FILE * iter = fopen(fileName.c_str(), "r");
113 if(iter == nullptr) {
114 return false;
115 }
117 //The file was only read, a failure on close has no consequence
118 (void)fclose(iter);
119 return b;
120}

References data_load(), and Serializer< Stream, Mode, T >::phoenix_serialize().

Here is the call graph for this function:

◆ data_load() [3/4]

template<typename T>
bool data_load ( FILE * iter,
T & data )

Load data from a message.

Parameters
[out]iter: message to be read
[out]data: data to be loaded from the message
Returns
true on success, false otherwise

Definition at line 39 of file data_file.h.

References data_load(), and Serializer< Stream, Mode, T >::phoenix_serialize().

Referenced by data_load(), data_load(), data_load(), and data_load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ data_load() [4/4]

template<typename T>
bool data_load ( FILE * iter,
T * data,
size_t nbElement )

Load data from a message.

Parameters
[out]iter: message to be read
[out]data: data to be loaded from the message
nbElement: number of elements in the data
Returns
true on success, false otherwise

Definition at line 50 of file data_file.h.

50 {
52}

References data_load(), and Serializer< Stream, Mode, T >::phoenix_serialize().

Here is the call graph for this function:

◆ data_save() [1/4]

template<typename T>
bool data_save ( const std::string & fileName,
const T & data )

Save data in a message.

Parameters
fileName: name of the file to be written
data: data to be saved in the message
Returns
true on success, false otherwise

Definition at line 60 of file data_file.h.

60 {
61 FILE * iter = fopen(fileName.c_str(), "w");
62 if(iter == nullptr) {
63 return false;
64 }
65 bool b(Serializer<FILE *, SerializeMode::WRITE, T>::phoenix_serialize(iter, (T &)data)); // NOLINT(modernize-avoid-c-style-cast) WRITE never modifies data, but Serializer takes T & to share one function with READ
66 b = (fclose(iter) == 0) && b;
67 return b;
68}

References data_save(), and Serializer< Stream, Mode, T >::phoenix_serialize().

Here is the call graph for this function:

◆ data_save() [2/4]

template<typename T>
bool data_save ( const std::string & fileName,
const T * data,
size_t nbElement )

Save data in a message.

Parameters
fileName: name of the file to be written
data: data to be saved in the message
nbElement: number of elements in the data
Returns
true on success, false otherwise

Definition at line 77 of file data_file.h.

77 {
78 FILE * iter = fopen(fileName.c_str(), "w");
79 if(iter == nullptr) {
80 return false;
81 }
82 bool b(Serializer<FILE *, SerializeMode::WRITE, T>::phoenix_serialize(iter, (T *)data, nbElement)); // NOLINT(modernize-avoid-c-style-cast) WRITE never modifies data, but Serializer takes T & to share one function with READ
83 b = (fclose(iter) == 0) && b;
84 return b;
85}

References data_save(), and Serializer< Stream, Mode, T >::phoenix_serialize().

Here is the call graph for this function:

◆ data_save() [3/4]

template<typename T>
bool data_save ( FILE * iter,
const T & data )

Save data in a message.

Parameters
[out]iter: message to be written
data: data to be saved in the message
Returns
true on success, false otherwise

Definition at line 18 of file data_file.h.

18 {
19 return Serializer<FILE *, SerializeMode::WRITE, T>::phoenix_serialize(iter, (T &)data); // NOLINT(modernize-avoid-c-style-cast) WRITE never modifies data, but Serializer takes T & to share one function with READ
20}

References data_save(), and Serializer< Stream, Mode, T >::phoenix_serialize().

Referenced by data_save(), data_save(), data_save(), and data_save().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ data_save() [4/4]

template<typename T>
bool data_save ( FILE * iter,
const T * data,
size_t nbElement )

Save data in a message.

Parameters
[out]iter: message to be written
data: data to be saved in the message
nbElement: number of elements in the data
Returns
true on success, false otherwise

Definition at line 29 of file data_file.h.

29 {
30 return Serializer<FILE *, SerializeMode::WRITE, T>::phoenix_serialize(iter, (T *)data, nbElement); // NOLINT(modernize-avoid-c-style-cast) WRITE never modifies data, but Serializer takes T & to share one function with READ
31}

References data_save(), and Serializer< Stream, Mode, T >::phoenix_serialize().

Here is the call graph for this function: