mirror of
https://github.com/nasa/fpp.git
synced 2025-12-11 11:16:42 -06:00
189 lines
5.0 KiB
C++
Vendored
189 lines
5.0 KiB
C++
Vendored
// ======================================================================
|
|
// \title String2ArrayAc.hpp
|
|
// \author Generated by fpp-to-cpp
|
|
// \brief hpp file for String2 array
|
|
// ======================================================================
|
|
|
|
#ifndef String2ArrayAc_HPP
|
|
#define String2ArrayAc_HPP
|
|
|
|
#include <initializer_list>
|
|
|
|
#include "Fw/FPrimeBasicTypes.hpp"
|
|
#include "Fw/Types/ExternalString.hpp"
|
|
#include "Fw/Types/Serializable.hpp"
|
|
#include "Fw/Types/String.hpp"
|
|
|
|
//! An array of strings with specified default value and format string
|
|
class String2 :
|
|
public Fw::Serializable
|
|
{
|
|
|
|
public:
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Types
|
|
// ----------------------------------------------------------------------
|
|
|
|
//! The element type
|
|
using ElementType = Fw::ExternalString;
|
|
|
|
public:
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Constants
|
|
// ----------------------------------------------------------------------
|
|
|
|
enum {
|
|
//! The size of the array
|
|
SIZE = 2,
|
|
//! The string size of each element
|
|
ELEMENT_STRING_SIZE = 80,
|
|
//! The buffer size of each element
|
|
ELEMENT_BUFFER_SIZE = Fw::StringBase::BUFFER_SIZE(ELEMENT_STRING_SIZE),
|
|
//! The serialized size of each element
|
|
ELEMENT_SERIALIZED_SIZE = Fw::StringBase::STATIC_SERIALIZED_SIZE(ELEMENT_STRING_SIZE),
|
|
//! The size of the serial representation
|
|
SERIALIZED_SIZE = SIZE * ELEMENT_SERIALIZED_SIZE
|
|
};
|
|
|
|
public:
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Constructors
|
|
// ----------------------------------------------------------------------
|
|
|
|
//! Constructor (default value)
|
|
String2();
|
|
|
|
//! Constructor (primitive array)
|
|
String2(
|
|
const ElementType (&a)[SIZE] //!< The array
|
|
);
|
|
|
|
//! Constructor (single element)
|
|
explicit String2(
|
|
const Fw::StringBase& e //!< The element
|
|
);
|
|
|
|
//! Constructor (initializer list)
|
|
String2(
|
|
const std::initializer_list<Fw::String>& il //!< The initializer list
|
|
);
|
|
|
|
//! Copy constructor
|
|
String2(
|
|
const String2& obj //!< The source object
|
|
);
|
|
|
|
public:
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Operators
|
|
// ----------------------------------------------------------------------
|
|
|
|
//! Subscript operator
|
|
ElementType& operator[](
|
|
const FwSizeType i //!< The subscript index
|
|
);
|
|
|
|
//! Const subscript operator
|
|
const ElementType& operator[](
|
|
const FwSizeType i //!< The subscript index
|
|
) const;
|
|
|
|
//! Copy assignment operator (object)
|
|
String2& operator=(
|
|
const String2& obj //!< The source object
|
|
);
|
|
|
|
//! Copy assignment operator (primitive array)
|
|
String2& operator=(
|
|
const ElementType (&a)[SIZE] //!< The source array
|
|
);
|
|
|
|
//! Copy assignment operator (initializer list)
|
|
String2& operator=(
|
|
const std::initializer_list<Fw::String>& il //!< The initializer list
|
|
);
|
|
|
|
//! Copy assignment operator (single element)
|
|
String2& operator=(
|
|
const ElementType& e //!< The element
|
|
);
|
|
|
|
//! Equality operator
|
|
bool operator==(
|
|
const String2& obj //!< The other object
|
|
) const;
|
|
|
|
//! Inequality operator
|
|
bool operator!=(
|
|
const String2& obj //!< The other object
|
|
) const;
|
|
|
|
#ifdef BUILD_UT
|
|
|
|
//! Ostream operator
|
|
friend std::ostream& operator<<(
|
|
std::ostream& os, //!< The ostream
|
|
const String2& obj //!< The object
|
|
);
|
|
|
|
#endif
|
|
|
|
public:
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Public member functions
|
|
// ----------------------------------------------------------------------
|
|
|
|
//! Serialization
|
|
Fw::SerializeStatus serializeTo(
|
|
Fw::SerialBufferBase& buffer, //!< The serial buffer
|
|
Fw::Endianness mode = Fw::Endianness::BIG //!< Endianness of serialized buffer
|
|
) const;
|
|
|
|
//! Deserialization
|
|
Fw::SerializeStatus deserializeFrom(
|
|
Fw::SerialBufferBase& buffer, //!< The serial buffer
|
|
Fw::Endianness mode = Fw::Endianness::BIG //!< Endianness of serialized buffer
|
|
);
|
|
|
|
//! Get the dynamic serialized size of the array
|
|
FwSizeType serializedSize() const;
|
|
|
|
#if FW_SERIALIZABLE_TO_STRING
|
|
|
|
//! Convert array to string
|
|
void toString(
|
|
Fw::StringBase& sb //!< The StringBase object to hold the result
|
|
) const;
|
|
|
|
#endif
|
|
|
|
private:
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Private member functions
|
|
// ----------------------------------------------------------------------
|
|
|
|
//! Initialize elements
|
|
void initElements();
|
|
|
|
private:
|
|
|
|
// ----------------------------------------------------------------------
|
|
// Member variables
|
|
// ----------------------------------------------------------------------
|
|
|
|
//! The char buffers
|
|
char buffers[SIZE][ELEMENT_BUFFER_SIZE];
|
|
|
|
//! The array elements
|
|
ElementType elements[SIZE];
|
|
|
|
};
|
|
|
|
#endif
|