cereal documentation
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Christian Zimmermann 2024-02-03 16:44:34 +01:00
parent b2c52384b0
commit 871910355d
17 changed files with 268 additions and 25 deletions

View file

@ -1,3 +1,13 @@
// -*- C++ -*-
/**
@file include/memory/allocator.cc.h
@brief Allocator template member function implementation
Copyright (c) 2024 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#ifndef __cxz_allocator_cc_h__
#define __cxz_allocator_cc_h__

View file

@ -1,11 +1,10 @@
// -*- C++ -*-
/**
@file include/memory/memcount.h
@brief ...
@file include/memory/allocator.h
@brief Allocator declaration
Copyright (c) 2022 Christian Zimmermann. All rights reserved.
Copyright (c) 2024 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/

View file

@ -1,3 +1,13 @@
// -*- C++ -*-
/**
@file include/operation/basic_operations.cc.h
@brief Basic operations implementation
Copyright (c) 2024 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#ifndef __cxz_basic_operations_cc_h__
#define __cxz_basic_operations_cc_h__

View file

@ -1,3 +1,13 @@
// -*- C++ -*-
/**
@file include/operation/basic_operations.h
@brief Basic operations declaration
Copyright (c) 2024 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#ifndef __cxz_basic_operations_h__
#define __cxz_basic_operations_h__

View file

@ -1,3 +1,13 @@
// -*- C++ -*-
/**
@file opt/cereal/include/cer_array.cc.h
@brief Load and save implementation for MArray.
Copyright (c) 2024 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#ifndef __cxz_cereal_array_cc_h__
#define __cxz_cereal_array_cc_h__
@ -23,7 +33,6 @@ namespace CNORXZ
{
CXZ_ASSERT(version == 1u, "format version = " << version << " not supported");
cer::save_load(ar, "range", AB::mRange);
//ar(cereal::make_nvp("range", AB::mRange));
ar(cereal::make_nvp("data", mCont));
}
}

View file

@ -1,19 +1,35 @@
// -*- C++ -*-
/**
@file opt/cereal/include/cer_base.h
@brief CNORXZ Cereal basic types declaration.
Copyright (c) 2024 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#ifndef __cxz_cer_base_h__
#define __cxz_cer_base_h__
#define CXZ_CEREAL_FORMAT_VERION 1u
#define CXZ_CEREAL_FORMAT_VERION 1u /**< CNORXZ specific cereal format version. */
namespace CNORXZ
{
namespace cer
{
/** ****
Archive format enum class.
*/
enum class Format {
BINARY = 1u,
JSON = 2u,
XML = 3u
};
/** ****
Content type enum class.
*/
enum class ContentType {
ARRAY = 1u,
MAP = 2u

View file

@ -1,3 +1,13 @@
// -*- C++ -*-
/**
@file opt/cereal/include/cer_header.cc.h
@brief Load and save implementation for CNORXZ cereal data header.
Copyright (c) 2024 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#ifndef __cxz_cereal_header_cc_h__
#define __cxz_cereal_header_cc_h__

View file

@ -1,3 +1,13 @@
// -*- C++ -*-
/**
@file opt/cereal/include/cer_header.h
@brief CNORXZ Cereal data header declaration.
Copyright (c) 2024 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#ifndef __cxz_cereal_header_h__
#define __cxz_cereal_header_h__
@ -9,13 +19,19 @@ namespace CNORXZ
{
namespace cer
{
/** ****
Cereal data header struct.
*/
struct Header
{
String version;
String commit;
ContentType content;
String version; /**< CNORXZ version. */
String commit; /**< CNORXZ git commit. */
ContentType content; /**< Content type. */
};
/** Create header.
@param content Content type.
*/
inline Header mkHeader(const ContentType content)
{
Header o;
@ -24,10 +40,20 @@ namespace CNORXZ
o.content = content;
return o;
}
/** Serialze header, store in archive.
@param ar Target archive.
@param h Input header.
@param version Version.
*/
template <class Archive>
void save(Archive& ar, const Header& h, const std::uint32_t version);
/** Deserialze header from archive.
@param ar Source archive.
@param h Target header reference.
@param version Version.
*/
template <class Archive>
void load(Archive& ar, Header& h, const std::uint32_t version);

View file

@ -1,3 +1,13 @@
// -*- C++ -*-
/**
@file opt/cereal/include/cer_ranges.cc.h
@brief Load and save implementation for cnorxz ranges.
Copyright (c) 2024 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#ifndef __cxz_cereal_ranges_cc_h__
#define __cxz_cereal_ranges_cc_h__

View file

@ -1,3 +1,13 @@
// -*- C++ -*-
/**
@file opt/cereal/include/cer_type_register.cc.h
@brief Register CNORXZ cereal types.
Copyright (c) 2024 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#ifndef __cxz_cereal_type_register_cc_h__
#define __cxz_cereal_type_register_cc_h__

View file

@ -1,3 +1,13 @@
// -*- C++ -*-
/**
@file opt/cereal/include/cnorxz_cereal.h
@brief CNORXZ Cereal main header
Copyright (c) 2024 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#include "cer_base.h"
#include "cer_header.h"

View file

@ -1,3 +1,13 @@
// -*- C++ -*-
/**
@file opt/cereal/include/range_save_load.cc.h
@brief CNORXZ Cereal range save load implementation.
Copyright (c) 2024 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#ifndef __range_save_load_cc_h__
#define __range_save_load_cc_h__

View file

@ -1,3 +1,13 @@
// -*- C++ -*-
/**
@file opt/cereal/include/range_save_load.h
@brief CNORXZ Cereal range save load declaration.
Copyright (c) 2024 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#ifndef __range_save_load_h__
#define __range_save_load_h__
@ -8,8 +18,14 @@ namespace CNORXZ
{
namespace cer
{
// use this function to register the range in the map of the range factories
// (otherwise there might be more than one instance of the same range)
/** Deserialize and register range from cereal archive.
Always use this function to load ranges from archives so that it is
registered in the map of the range factories. Otherwise there might be more
than one instance of the same range.
@param ar Archive to read from.
@param name Archive key.
@param r Target range pointer.
*/
template <class Archive>
RangePtr save_load(Archive& ar, const String& name, RangePtr& r);
}

View file

@ -1,3 +1,13 @@
// -*- C++ -*-
/**
@file opt/cereal/include/utilities.cc.h
@brief CNORXZ Cereal utilities implementation.
Copyright (c) 2024 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#ifndef __cxz_cereal_utilities_cc_h__
#define __cxz_cereal_utilities_cc_h__

View file

@ -1,3 +1,13 @@
// -*- C++ -*-
/**
@file opt/cereal/include/utilities.h
@brief CNORXZ Cereal utilities declaration.
Copyright (c) 2024 Christian Zimmermann. All rights reserved.
Mail: chizeta@f3l.de
**/
#ifndef __cxz_cereal_utilities_h__
#define __cxz_cereal_utilities_h__
@ -14,68 +24,141 @@ namespace CNORXZ
{
namespace cer
{
/** ****
Output archive type trait.
@tparam F Format enum.
*/
template <Format F>
struct OutputFormatMap
{};
/** Output archive for binary format. */
template <>
struct OutputFormatMap<Format::BINARY>
{ typedef cereal::BinaryOutputArchive type; };
{ typedef cereal::BinaryOutputArchive type; /**< archive type. */ };
/** Output archive for json format. */
template <>
struct OutputFormatMap<Format::JSON>
{ typedef cereal::JSONOutputArchive type; };
{ typedef cereal::JSONOutputArchive type; /**< archive type. */ };
/** Output archive for xml format. */
template <>
struct OutputFormatMap<Format::XML>
{ typedef cereal::XMLOutputArchive type; };
{ typedef cereal::XMLOutputArchive type; /**< archive type. */ };
/** ****
Input archive type trait.
@tparam F Format enum.
*/
template <Format F>
struct InputFormatMap
{};
/** Input archive for binary format. */
template <>
struct InputFormatMap<Format::BINARY>
{ typedef cereal::BinaryInputArchive type; };
{ typedef cereal::BinaryInputArchive type; /**< archive type. */ };
/** Input archive for json format. */
template <>
struct InputFormatMap<Format::JSON>
{ typedef cereal::JSONInputArchive type; };
{ typedef cereal::JSONInputArchive type; /**< archive type. */ };
/** Input archive for xml format. */
template <>
struct InputFormatMap<Format::XML>
{ typedef cereal::XMLInputArchive type; };
{ typedef cereal::XMLInputArchive type; /**< archive type. */ };
/** Serialize MArray to stream
@tparam F Format enum class [BINARY,JSON,XML].
@tparam T Array element value type.
@param os Output stream.
@param data Array to be serialized.
*/
template <Format F, typename T>
void write(std::ostream& os, const MArray<T>& data);
/** Deserialize MArray from stream
@tparam F Format enum class [BINARY,JSON,XML].
@tparam T Array element value type.
@param is Input stream.
@param data Target array.
*/
template <Format F, typename T>
void read(std::istream& is, MArray<T>& data);
/** Serialize MArray and write to file.
@tparam F Format enum class [BINARY,JSON,XML].
@tparam T Array element value type.
@param name File name.
@param data Array to be saved.
*/
template <Format F, typename T>
void writeFile(const String& name, const MArray<T>& data);
/** Read and deserialize MArray from cereal compatibel file.
@tparam F Format enum class [BINARY,JSON,XML].
@tparam T Array element value type.
@param name File name.
@param data target array.
*/
template <Format F, typename T>
void readFile(const String& name, MArray<T>& data);
/** Serialize MArray and write to binary file.
@tparam T Array element value type.
@param name File name.
@param data Array to be saved.
*/
template <typename T>
void writeBINARYFile(const String& name, const MArray<T>& data) { writeFile<Format::BINARY>(name, data); }
inline void writeBINARYFile(const String& name, const MArray<T>& data)
{ writeFile<Format::BINARY>(name, data); }
/** Read and deserialize MArray from cereal compatibel binary file.
@tparam T Array element value type.
@param name File name.
@param data target array.
*/
template <typename T>
void readBINARYFile(const String& name, MArray<T>& data) { readFile<Format::BINARY>(name, data); }
inline void readBINARYFile(const String& name, MArray<T>& data)
{ readFile<Format::BINARY>(name, data); }
/** Serialize MArray and write to json file.
@tparam T Array element value type.
@param name File name.
@param data Array to be saved.
*/
template <typename T>
void writeJSONFile(const String& name, const MArray<T>& data) { writeFile<Format::JSON>(name, data); }
inline void writeJSONFile(const String& name, const MArray<T>& data)
{ writeFile<Format::JSON>(name, data); }
/** Read and deserialize MArray from cereal compatibel json file.
@tparam T Array element value type.
@param name File name.
@param data target array.
*/
template <typename T>
void readJSONFile(const String& name, MArray<T>& data) { readFile<Format::JSON>(name, data); }
inline void readJSONFile(const String& name, MArray<T>& data)
{ readFile<Format::JSON>(name, data); }
/** Serialize MArray and write to xml file.
@tparam T Array element value type.
@param name File name.
@param data Array to be saved.
*/
template <typename T>
void writeXMLFile(const String& name, const MArray<T>& data) { writeFile<Format::XML>(name, data); }
inline void writeXMLFile(const String& name, const MArray<T>& data)
{ writeFile<Format::XML>(name, data); }
/** Read and deserialize MArray from cereal compatibel xml file.
@tparam T Array element value type.
@param name File name.
@param data target array.
*/
template <typename T>
void readXMLFile(const String& name, MArray<T>& data) { readFile<Format::XML>(name, data); }
inline void readXMLFile(const String& name, MArray<T>& data)
{ readFile<Format::XML>(name, data); }
}
}

View file

@ -133,11 +133,13 @@ namespace CNORXZ
return *this;
}
/** @cond 0 */
struct InitContData
{
const ContentBase* parent;
BIndex<ContentPtr> index;
};
/** @endcond */
static herr_t addName(hid_t id, const char* name, const H5L_info_t* info, void* x)
{

View file

@ -11,6 +11,7 @@ namespace CNORXZ
{
namespace Test
{
/** @cond 0 */
class Numbers
{
private:
@ -51,6 +52,7 @@ namespace CNORXZ
return Vector<Double>(b,e);
}
};
/** @endcond */
}
}