F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
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 <Fw/FPrimeBasicTypes.hpp>
11 
12 #include "Fw/Types/StringBase.hpp"
13 
14 namespace Fw {
15 
16 template <Fw::StringBase::SizeType size>
17 class StringTemplate final : public StringBase {
18  public:
19  enum {
20  STRING_SIZE = size,
22  };
23 
24  StringTemplate() : StringBase() { *this = ""; }
25 
26  StringTemplate(const StringTemplate& src) : StringBase() { *this = src; }
27 
28  StringTemplate(const StringBase& src) : StringBase() { *this = src; }
29 
30  explicit StringTemplate(const char* src) : StringBase() { *this = src; }
31 
33 
35  (void)StringBase::operator=(src);
36  return *this;
37  }
38 
40  (void)StringBase::operator=(src);
41  return *this;
42  }
43 
44  StringTemplate& operator=(const char* src) {
45  (void)StringBase::operator=(src);
46  return *this;
47  }
48 
49  const char* toChar() const { return this->m_buf; }
50 
51  StringBase::SizeType getCapacity() const { return sizeof this->m_buf; }
52 
53  private:
54  char m_buf[BUFFER_SIZE(size)];
55 };
56 } // namespace Fw
57 
58 #endif
StringTemplate(const char *src)
StringTemplate & operator=(const char *src)
StringTemplate(const StringBase &src)
StringTemplate & operator=(const StringTemplate &src)
StringTemplate(const StringTemplate &src)
const char * toChar() const
FwSizeType SizeType
Definition: StringBase.hpp:27
StringBase::SizeType getCapacity() const
return size of buffer
static constexpr SizeType BUFFER_SIZE(SizeType maxLength)
Get the size of a null-terminated string buffer.
Definition: StringBase.hpp:42
StringTemplate & operator=(const StringBase &src)
Declares F Prime string base class.
static constexpr SizeType STATIC_SERIALIZED_SIZE(SizeType maxLength)
Definition: StringBase.hpp:36