25 fs <<
"#include <array>" << std::endl;
26 fs <<
"#include <algorithm>" << std::endl;
27 fs <<
"#include \"phoenix_data_stream.h\"" << std::endl;
37 PString name(classConfig.
getName());
39 fs <<
"\t\t///Load the current "<<name<<
" with a stream" << std::endl;
40 fs <<
"\t\t/** @param[out] ds : stream to be used" << std::endl;
41 fs <<
"\t\t * @return true on success, false otherwise" << std::endl;
42 fs <<
"\t\t*/" << std::endl;
43 fs <<
"\t\ttemplate<typename Stream, DataStreamMode::DataStreamMode Mode>" << std::endl;
44 fs <<
"\t\tbool readWriteStream(Stream & ds){" << std::endl;
47 if(vecAttr.size() == 0lu){
48 fs <<
"\t\t\treturn true;" << std::endl;
52 fs <<
"\t\t\tconst std::array<bool, " << vecAttr.size() <<
"> vecIsOk{" << std::endl;
53 PString separator(
"\t\t\t\t");
54 for(PVecClassAttribute::const_iterator it(vecAttr.begin()); it != vecAttr.end(); ++it){
55 fs << separator <<
"streamAttribute<Stream, Mode>(ds, p_" << it->getName() <<
")";
56 separator =
",\n\t\t\t\t";
58 fs << std::endl <<
"\t\t\t};" << std::endl;
59 fs <<
"\t\t\treturn std::all_of(vecIsOk.begin(), vecIsOk.end(), [](bool isOk){return isOk;});" << std::endl;
61 fs <<
"\t\t}" << std::endl << std::endl;
82 fs <<
"\t\t///Streams a single attribute" << std::endl;
83 fs <<
"\t\t/** @param[out] ds : stream to be used" << std::endl;
84 fs <<
"\t\t * @param data : attribute to be streamed" << std::endl;
85 fs <<
"\t\t * @return true on success, false otherwise" << std::endl;
86 fs <<
"\t\t*/" << std::endl;
87 fs <<
"\t\ttemplate<typename Stream, DataStreamMode::DataStreamMode Mode, typename T>" << std::endl;
88 fs <<
"\t\tstatic bool streamAttribute(Stream & ds, T & data){" << std::endl;
89 fs <<
"\t\t\treturn DataStream<Stream, Mode, T>::data_stream(ds, data);" << std::endl;
90 fs <<
"\t\t}" << std::endl << std::endl;
127 PString name(classConfig.
getName());
130 fs <<
"PHOENIX_DATA_STREAM_ENUM("<<name<<
"::"<<name<<
")" << std::endl << std::endl;
133 fs <<
"///@brief Generic "<<name<<
" serialisation/deserialisation, load/save and size function for PhoenixDataStream" << std::endl;
134 fs <<
"template<typename Stream, DataStreamMode::DataStreamMode Mode>" << std::endl;
135 fs <<
"struct DataStream<Stream, Mode, "<<fullName<<
">{" << std::endl;
136 fs <<
"\t///Generic function to load/save/serialise/deserialise "<<name << std::endl;
137 fs <<
"\t/**\t@param[out] ds : stream to be used" << std::endl;
138 fs <<
"\t * \t@param data : "<<name<<
" to be used" << std::endl;
139 fs <<
"\t * \t@return true on success, false otherwise" << std::endl;
140 fs <<
"\t*/" << std::endl;
141 fs <<
"\tstatic bool data_stream(Stream & ds, "<<fullName<<
" & data){" << std::endl;
142 fs <<
"\t\treturn data.readWriteStream<Stream, Mode>(ds);" << std::endl;
143 fs <<
"\t}" << std::endl;
144 fs <<
"};" << std::endl << std::endl;
std::vector< PClassAttribute > PVecClassAttribute
virtual void protectedMethodImplementation(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of protected methods.
virtual void publicMethodDeclaration(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Declaration of public methods.
virtual void protectedMethodDeclaration(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Declaration of protected methods.
virtual void headerExtraInclude(std::ofstream &fs, const GeneratorMode &mode) const
Add extra include on the header.
virtual void classExtraFunctionImplementation(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of extra functions.
CppTraitDataStream()
Consctructor of CppTraitDataStream.
virtual void classExtraFunctionDeclaration(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Declaration of extra functions.
virtual ~CppTraitDataStream()
Desctructor of CppTraitDataStream.
virtual void privateMethodDeclaration(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Declaration of private methods.
virtual void privateMethodImplementation(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of private methods.
virtual void publicMethodImplementation(std::ofstream &fs, const PClassConfig &classConfig, const GeneratorMode &mode) const
Implementation of public methods.
Class to describe a basic class.
PString getFullName() const
Returns the full name of the class including the namespace.
const std::vector< PClassAttribute > & getListAttribute() const
Returns the list of attributes of the class.
const PString & getName() const
Returns the class name.
bool getIsEnum() const
Say if the current PClassConfig is an enum.
bool enableDataStream
True to enable data stream interface generator.