F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Loading...
Searching...
No Matches
StringTemplate.hpp
Go to the documentation of this file.
1// ======================================================================
2// @file StringTemplate.hpp
3// @author Rob Bocchino
4// @brief A string template parameterized by size
5// ======================================================================
6
7#ifndef FW_STRING_TEMPLATE_HPP
8#define FW_STRING_TEMPLATE_HPP
9
10#include <FpConfig.hpp>
11
13
14namespace Fw {
15
16template<Fw::StringBase::SizeType size> class StringTemplate final : public StringBase {
17 public:
18 enum {
21 };
22
23 StringTemplate() : StringBase() { *this = ""; }
24
25 explicit StringTemplate(const StringTemplate& src) : StringBase() { *this = src; }
26
27 explicit StringTemplate(const StringBase& src) : StringBase() { *this = src; }
28
29 explicit StringTemplate(const char* src) : StringBase() { *this = src; }
30
32
34 (void)StringBase::operator=(src);
35 return *this;
36 }
37
39 (void)StringBase::operator=(src);
40 return *this;
41 }
42
43 StringTemplate& operator=(const char* src) {
44 (void)StringBase::operator=(src);
45 return *this;
46 }
47
48 const char* toChar() const { return this->m_buf; }
49
50 StringBase::SizeType getCapacity() const { return sizeof this->m_buf; }
51
52 private:
53 char m_buf[BUFFER_SIZE(size)];
54};
55} // namespace Fw
56
57#endif
C++-compatible configuration header for fprime configuration.
Declares F Prime string base class.
NATIVE_UINT_TYPE SizeType
static constexpr SizeType STATIC_SERIALIZED_SIZE(SizeType maxLength)
static constexpr SizeType BUFFER_SIZE(SizeType maxLength)
Get the size of a null-terminated string buffer.
StringTemplate(const char *src)
StringTemplate(const StringBase &src)
const char * toChar() const
StringTemplate & operator=(const StringBase &src)
StringTemplate & operator=(const char *src)
StringTemplate(const StringTemplate &src)
StringBase::SizeType getCapacity() const
return size of buffer
StringTemplate & operator=(const StringTemplate &src)