#include "dnsutil.h"
#include "wwwi/string.h"
using WWWI::MemCaseCmp;
using std::memcpy;
inline bool Label::operator<(const Label &ci_lbr) const {
if (m_usLength<ci_lbr.m_usLength) return true;
if (m_usLength>ci_lbr.m_usLength) return false;
if (MemCaseCmp(m_str, ci_lbr.m_str, m_usLength)<0) return true;
return false;
}
inline Label &Label::operator=(const Label &ci_lbr) {
this->Set(ci_lbr.m_usLength,ci_lbr.m_str);
return *this;
}
inline bool Label::operator==(const Label &ci_lbr) const {
if (m_usLength != ci_lbr.m_usLength) return false;
if (MemCaseCmp(m_str, ci_lbr.m_str, m_usLength)!=0) return false;
return true;
}
inline bool Label::operator!=(const Label &ci_lbr) const {
return (this->operator==(ci_lbr)==false);
}
inline unsigned short Label::GetLength() const { return m_usLength; }
inline const char *Label::GetString() const { return m_str; }
inline void Label::Set(unsigned short i_usLength, const char *ci_str) {
assert(i_usLength<64);
SoftDeleteArray(m_str);
m_usLength = i_usLength;
m_str = new char[i_usLength+1];
memcpy(m_str,ci_str,i_usLength);
m_str[i_usLength] = 0;
}
template <class SM> SM& operator<<(SM &io_smr, const Label &ci_lbr) {
io_smr << &ci_lbr;
return io_smr;
}
template <class SM> SM& operator<<(SM &io_smr, const Label *ci_lbp) {
io_smr << ci_lbp->GetString();
return io_smr;
}