std::string DNSName::toString(const std::string& separator, const bool trailing) const
{
- if (d_empty)
+ if (empty())
return "";
- if(d_storage.empty() && trailing) // I keep wondering if there is some deeper meaning to the need to do this
+ if(empty() && trailing) // I keep wondering if there is some deeper meaning to the need to do this
return separator;
std::string ret;
for(const auto& s : getRawLabels()) {
std::string DNSName::toDNSString() const
{
- if (d_empty)
- return "";
+ // if (empty())
+ // return "";
string ret(d_storage.c_str(), d_storage.length());
ret.append(1,(char)0);
return toLower(ret); // toLower or not toLower, that is the question
// return ret;
}
-size_t DNSName::length() const {
- return this->toString().length();
-}
-
/**
* Get the length of the DNSName on the wire
*
// are WE part of parent
bool DNSName::isPartOf(const DNSName& parent) const
{
- if(parent.d_empty || d_empty)
+ if(parent.empty() || empty())
return false;
if(parent.d_storage.empty())
return true;
DNSName DNSName::labelReverse() const
{
DNSName ret;
- if (!d_empty) {
+ if (!empty()) {
vector<string> l=getRawLabels();
while(!l.empty()) {
ret.appendRawLabel(l.back());
bool DNSName::operator==(const DNSName& rhs) const
{
- if(rhs.d_empty != d_empty || rhs.d_storage.size() != d_storage.size())
+ if(rhs.empty() != empty() || rhs.d_storage.size() != d_storage.size())
return false;
auto us = d_storage.crbegin();
class DNSName
{
public:
- DNSName() : d_empty(true) {} //!< Don't constructs the root name
+ DNSName() : d_empty(true) {} //!< Constructs an *empty* DNSName, NOT the root!
explicit DNSName(const char* p); //!< Constructs from a human formatted, escaped presentation
explicit DNSName(const std::string& str) : DNSName(str.c_str()) {} //!< Constructs from a human formatted, escaped presentation
DNSName(const char* p, int len, int offset, bool uncompress, uint16_t* qtype=0, uint16_t* qclass=0, unsigned int* consumed=0); //!< Construct from a DNS Packet, taking the first question if offset=12
DNSName labelReverse() const;
bool isWildcard() const;
unsigned int countLabels() const;
- size_t length() const; // FIXME400 remove me?
size_t wirelength() const; //!< Number of total bytes in the name
bool empty() const { return d_empty; }
bool isRoot() const { return !d_empty && d_storage.empty(); }