Skip to content

Commit

Permalink
Explicit constructor and use CHAR
Browse files Browse the repository at this point in the history
  • Loading branch information
thomas-bc committed Jan 24, 2024
1 parent 42332a5 commit 384d1d2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Fw/Types/ObjectName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace Fw {

ObjectName::ObjectName(const char* src) : StringBase() {
ObjectName::ObjectName(const CHAR* src) : StringBase() {
Fw::StringUtils::string_copy(this->m_buf, src, sizeof(this->m_buf));
}

Expand Down Expand Up @@ -37,15 +37,15 @@ namespace Fw {
return *this;
}

ObjectName& ObjectName::operator=(const char* other) {
ObjectName& ObjectName::operator=(const CHAR* other) {
Fw::StringUtils::string_copy(this->m_buf, other, sizeof(this->m_buf));
return *this;
}

ObjectName::~ObjectName() {
}

const char* ObjectName::toChar() const {
const CHAR* ObjectName::toChar() const {
return this->m_buf;
}

Expand Down
10 changes: 5 additions & 5 deletions Fw/Types/ObjectName.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,21 @@ namespace Fw {
SERIALIZED_SIZE = STRING_SIZE + sizeof(FwBuffSizeType) //!< Serialized size is size of buffer + size field
};

ObjectName(const char* src); //!< char* source constructor
ObjectName(const StringBase& src); //!< StringBase string constructor
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& operator=(const CHAR* other); //!< char* assignment operator
~ObjectName(); //!< destructor

const char* toChar() const; //!< gets char buffer
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
CHAR m_buf[STRING_SIZE]; //!< storage for string data
};
}

Expand Down
4 changes: 1 addition & 3 deletions Fw/Types/test/ut/TypesTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1215,10 +1215,8 @@ TEST(TypesTest,ObjectNameTest) {

Fw::ObjectName copyStr("ASTRING");
ASSERT_EQ(copyStr,"ASTRING");
Fw::ObjectName copyStr2 = "ASTRING";
Fw::ObjectName copyStr2(copyStr);
ASSERT_EQ(copyStr2,"ASTRING");
Fw::ObjectName copyStr3(copyStr2);
ASSERT_EQ(copyStr3,"ASTRING");

Fw::InternalInterfaceString ifstr("IfString");
Fw::ObjectName if2(ifstr);
Expand Down

0 comments on commit 384d1d2

Please sign in to comment.