F´ Flight Software - C/C++ Documentation  NASA-v2.0.0
A framework for building embedded system applications to NASA flight quality standards.
QueueString.cpp
Go to the documentation of this file.
3 #include <Os/QueueString.hpp>
4 #include <Fw/Types/Assert.hpp>
5 #include <string.h>
6 #include <stdio.h>
7 #include <stdlib.h>
8 
9 namespace Os {
10 
11  QueueString::QueueString(const char* src) : StringBase() {
12  this->copyBuff(src,sizeof(this->m_buf));
13  }
14 
15  QueueString::QueueString(const StringBase& src) : StringBase() {
16  this->copyBuff(src.toChar(),sizeof(this->m_buf));
17  }
18 
19  QueueString::QueueString(const QueueString& src) : StringBase() {
20  this->copyBuff(src.m_buf,sizeof(this->m_buf));
21  }
22 
23  QueueString::QueueString(void) : StringBase() {
24  this->m_buf[0] = 0;
25  }
26 
28  }
29 
31  this->copyBuff(other.m_buf,this->getCapacity());
32  return *this;
33  }
34 
35 
37  return strnlen(this->m_buf,sizeof(this->m_buf));
38  }
39 
40  const char* QueueString::toChar(void) const {
41  return this->m_buf;
42  }
43 
44  void QueueString::copyBuff(const char* buff, NATIVE_UINT_TYPE size) {
45  FW_ASSERT(buff);
46  // check for self copy
47  if (buff != this->m_buf) {
48  (void)strncpy(this->m_buf,buff,size);
49  // NULL terminate
50  this->terminate(sizeof(this->m_buf));
51  }
52  }
53 
54  NATIVE_UINT_TYPE QueueString::getCapacity(void) const {
56  }
57 
58  void QueueString::terminate(NATIVE_UINT_TYPE size) {
59  // null terminate the string
60  this->m_buf[size < sizeof(this->m_buf)?size:sizeof(this->m_buf)-1] = 0;
61  }
62 
63 }
StringType.hpp
Declares ISF string base class.
Os
Definition: File.cpp:7
Assert.hpp
Os::QueueString::~QueueString
~QueueString(void)
destructor
Definition: QueueString.cpp:27
QueueString.hpp
Os::QueueString::length
NATIVE_UINT_TYPE length(void) const
get current length of string
Definition: QueueString.cpp:36
Os::QueueString
Definition: QueueString.hpp:10
NATIVE_UINT_TYPE
unsigned int NATIVE_UINT_TYPE
native unsigned integer type declaration
Definition: BasicTypes.hpp:30
FW_ASSERT
#define FW_ASSERT(...)
Definition: Assert.hpp:9
Os::QueueString::toChar
const char * toChar(void) const
get pointer to char buffer
Definition: QueueString.cpp:40
Os::QueueString::QueueString
QueueString(void)
default constructor
Definition: QueueString.cpp:23
BasicTypes.hpp
Declares ISF basic types.
Os::QueueString::operator=
const QueueString & operator=(const QueueString &other)
equal operator
Definition: QueueString.cpp:30
FW_QUEUE_NAME_MAX_SIZE
#define FW_QUEUE_NAME_MAX_SIZE
Max size of message queue name.
Definition: FpConfig.hpp:210