[ITA2] Added assignment operator overload and copy constructor
This commit is contained in:
parent
71ccce4a3d
commit
9e8da76740
2 changed files with 31 additions and 0 deletions
|
@ -20,6 +20,25 @@ ITA2String::ITA2String(const char* str) {
|
||||||
ita2Len = 0;
|
ita2Len = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ITA2String::ITA2String(const ITA2String& ita2) {
|
||||||
|
this->asciiLen = ita2.asciiLen;
|
||||||
|
this->ita2Len = ita2.ita2Len;
|
||||||
|
#if !RADIOLIB_STATIC_ONLY
|
||||||
|
this->strAscii = new char[asciiLen + 1];
|
||||||
|
#endif
|
||||||
|
strcpy(this->strAscii, ita2.strAscii);
|
||||||
|
}
|
||||||
|
|
||||||
|
ITA2String& ITA2String::operator=(const ITA2String& ita2) {
|
||||||
|
this->asciiLen = ita2.asciiLen;
|
||||||
|
this->ita2Len = ita2.ita2Len;
|
||||||
|
#if !RADIOLIB_STATIC_ONLY
|
||||||
|
this->strAscii = new char[asciiLen + 1];
|
||||||
|
#endif
|
||||||
|
strcpy(this->strAscii, ita2.strAscii);
|
||||||
|
return(*this);
|
||||||
|
}
|
||||||
|
|
||||||
ITA2String::~ITA2String() {
|
ITA2String::~ITA2String() {
|
||||||
#if !RADIOLIB_STATIC_ONLY
|
#if !RADIOLIB_STATIC_ONLY
|
||||||
delete[] strAscii;
|
delete[] strAscii;
|
||||||
|
|
|
@ -35,6 +35,18 @@ class ITA2String {
|
||||||
*/
|
*/
|
||||||
explicit ITA2String(const char* str);
|
explicit ITA2String(const char* str);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Copy constructor.
|
||||||
|
\param ita2 ITA2String instance to copy.
|
||||||
|
*/
|
||||||
|
ITA2String(const ITA2String& ita2);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Overload for assignment operator.
|
||||||
|
\param ita2 rvalue ITA2String.
|
||||||
|
*/
|
||||||
|
ITA2String& operator=(const ITA2String& ita2);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Default destructor.
|
\brief Default destructor.
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Add table
Reference in a new issue