-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Fw::ObjectName to hold Fw::ObjBase name (#2497)
* Implement Fw::ObjectName * format * Add test case * Fix PolyDb UT and spelling * Explicit constructor and use CHAR * Revise ObjBase.hpp Don't include ObjectName header unless object names are enabled * Update requirements.txt for fpp==2.1.0a4 * Fix static code analysis warnings * cast string_copy return value to void * Resolve unchecked argument --------- Co-authored-by: Robert L. Bocchino Jr <bocchino@jpl.nasa.gov>
- Loading branch information
Showing
20 changed files
with
169 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include <Fw/Types/ObjectName.hpp> | ||
#include <Fw/Types/StringUtils.hpp> | ||
|
||
namespace Fw { | ||
|
||
ObjectName::ObjectName(const CHAR* src) : StringBase() { | ||
(void) Fw::StringUtils::string_copy(this->m_buf, src, sizeof(this->m_buf)); | ||
} | ||
|
||
ObjectName::ObjectName(const StringBase& src) : StringBase() { | ||
(void) Fw::StringUtils::string_copy(this->m_buf, src.toChar(), sizeof(this->m_buf)); | ||
} | ||
|
||
ObjectName::ObjectName(const ObjectName& src) : StringBase() { | ||
(void) Fw::StringUtils::string_copy(this->m_buf, src.toChar(), sizeof(this->m_buf)); | ||
} | ||
|
||
ObjectName::ObjectName() : StringBase() { | ||
this->m_buf[0] = 0; | ||
} | ||
|
||
ObjectName& ObjectName::operator=(const ObjectName& other) { | ||
if(this == &other) { | ||
return *this; | ||
} | ||
|
||
(void) Fw::StringUtils::string_copy(this->m_buf, other.toChar(), sizeof(this->m_buf)); | ||
return *this; | ||
} | ||
|
||
ObjectName& ObjectName::operator=(const StringBase& other) { | ||
if(this == &other) { | ||
return *this; | ||
} | ||
|
||
(void) Fw::StringUtils::string_copy(this->m_buf, other.toChar(), sizeof(this->m_buf)); | ||
return *this; | ||
} | ||
|
||
ObjectName& ObjectName::operator=(const CHAR* other) { | ||
(void) Fw::StringUtils::string_copy(this->m_buf, other, sizeof(this->m_buf)); | ||
return *this; | ||
} | ||
|
||
ObjectName::~ObjectName() { | ||
} | ||
|
||
const CHAR* ObjectName::toChar() const { | ||
return this->m_buf; | ||
} | ||
|
||
NATIVE_UINT_TYPE ObjectName::getCapacity() const { | ||
return STRING_SIZE; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#ifndef FW_OBJECT_NAME_TYPE_HPP | ||
#define FW_OBJECT_NAME_TYPE_HPP | ||
|
||
#include <FpConfig.hpp> | ||
#include <Fw/Types/StringType.hpp> | ||
#include <Fw/Cfg/SerIds.hpp> | ||
|
||
namespace Fw { | ||
|
||
class ObjectName : public Fw::StringBase { | ||
public: | ||
|
||
enum { | ||
SERIALIZED_TYPE_ID = FW_TYPEID_OBJECT_NAME, //!< typeid for string type | ||
STRING_SIZE = FW_OBJ_NAME_MAX_SIZE, //!< Storage for string | ||
SERIALIZED_SIZE = STRING_SIZE + sizeof(FwBuffSizeType) //!< Serialized size is size of buffer + size field | ||
}; | ||
|
||
explicit ObjectName(const CHAR* src); //!< char* source constructor | ||
explicit ObjectName(const StringBase& src); //!< StringBase string constructor | ||
ObjectName(const ObjectName& src); //!< ObjectName string constructor | ||
ObjectName(); //!< default constructor | ||
ObjectName& operator=(const ObjectName& other); //!< assignment operator | ||
ObjectName& operator=(const StringBase& other); //!< StringBase string assignment operator | ||
ObjectName& operator=(const CHAR* other); //!< char* assignment operator | ||
~ObjectName(); //!< destructor | ||
|
||
const CHAR* toChar() const; //!< gets char buffer | ||
NATIVE_UINT_TYPE getCapacity() const; //!< return buffer size | ||
|
||
private: | ||
|
||
CHAR m_buf[STRING_SIZE]; //!< storage for string data | ||
}; | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters