Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

domainname Class Reference

class representing a domain name More...

List of all members.


Public Member Functions

  domainname ()
  default constructor

  domainname (const char *text, domainname origin)
  constructor from human-readable text

  domainname (const char *text, const _domain origin="")
  constructor from human-readable text

  domainname (message_buff &buff, int ix)
  constructor from data in a DNS message

  domainname (bool is_binary, const _domain dom)
  constructor from binary domain name

  domainname (const domainname &nam)
  copy constructor

bool  operator== (const domainname &nam)
  equality test

bool  operator!= (const domainname &nam)
  negatice equality test

domainname operator= (const domainname &nam)
  assignment

domainname operator= (const char *buff)
  assignment from human-readable text

domainname operator+= (const domainname &dom)
  concatenation using +=

domainname operator+ (const domainname &dom)
  concatenation using +

bool  operator>= (const domainname &dom)
  parent-child test

bool  operator> (const domainname &dom)
  parent-child test

  ~domainname ()
  destructor

_domain  c_str ()
  binary representation of domain

int  len ()
  length of binary representation

stl_string  tostring ()
  convert to human-readable string

int  nlabels ()
  number of labels of the domain name

stl_string  label (int ix)
  label in domain name

domainname  from (int ix)
  domain-name portion

domainname  to (int labels)
  domain-name portion

stl_string  torelstring (domainname &root)
  return relative representation

int  ncommon (domainname &dom)
  check label match count


Detailed Description

class representing a domain name

This class represents a domain name. It offers functions to add domain names together, retrieving labels from the domainname, and converting it to human-readable strings and the binary format used in DNS messages.

Definition at line 64 of file domainfn.h.


Constructor & Destructor Documentation

domainname::domainname  ) 
 

default constructor

This constructor sets the domain name to ".", the root domain.

domainname::domainname const char *  text,
domainname  origin
 

constructor from human-readable text

This constructor takes a domain name in human-readable notation, e.g. "www.acdam.net", and an origin. If a relative domain name is given, it will be considered relative to the specified origin.

Parameters:
text  Human-readable domain name
origin  Origin to which relative domain names are relative

domainname::domainname const char *  text,
const _domain  origin = ""
 

constructor from human-readable text

This constructor takes a domain name in human-readable notation, e.g. "www.acdam.net", and optionally an origin. The origin is in the binary _domain format as found in DNS messages. In case of a relative domain name, it is considered relative to this origin (or to the root domain, if no origin is given).

Parameters:
text  Human-readable domain name
origin  Origin, in binary format, to which relative domain names are relative

domainname::domainname message_buff buff,
int  ix
 

constructor from data in a DNS message

This constructor takes a DNS message, stored in a message_buff structor, and an offset in this message where the domain name is to begin. This function will decompress the domain name if nessecary.

Parameters:
buff  A DNS message
ix  Offset in the DNS message

domainname::domainname bool  is_binary,
const _domain  dom
 

constructor from binary domain name

This constructor takes a domain name in binary form. Since a domain name in binary form is a char *, just like a human-readable domain name, this contructor takes a boolean value as well to prevent it from being ambiguous. The value of the boolean is silently ignored.

Parameters:
is_binary  Ignored
The  binary domain name

domainname::domainname const domainname nam  ) 
 

copy constructor

This constructor just copies the given domainname structore.

Parameters:
nam  The domain name

domainname::~domainname  ) 
 

destructor

Frees resources associated with the domain name


Member Function Documentation

_domain domainname::c_str  ) 
 

binary representation of domain

Returns the binary representation of the domain name as it would appear in DNS messages (though in uncompressed form).

Returns:
Binary representation for the domain name

domainname domainname::from int  ix  ) 
 

domain-name portion

Returns the portion of the domain name from the label specified by ix.

Parameters:
ix  Label index (inclusive)
Returns:
The domain name portion
See also:
nlabels(), to()

stl_string domainname::label int  ix  ) 
 

label in domain name

Returns a label in the domain name. This is just plain human-readable text. It does not contain dots.

Parameters:
Label  index (0 <= ix < nlabels())
Returns:
The label at the specified index
See also:
nlabels()

int domainname::len  ) 
 

length of binary representation

Returns the length, in bytes, also counting the terminating character, of the binary representation of the domain name.

Returns:
Length of binary representation

int domainname::ncommon domainname dom  ) 
 

check label match count

Returns the number of labels the two domain names have in common at their ends; for example this returns 2 for www.acdam.net and www.foo.acdam.net .

Parameters:
dom  The domain name to check with
Returns:
Number of common labels
See also:
nlabels()

int domainname::nlabels  ) 
 

number of labels of the domain name

Returns the number of labels in the domain name, also counting the root ' ' label at the end,

Returns:
Number of labels
See also:
label()

bool domainname::operator!= const domainname nam  ) 
 

negatice equality test

Tests whether the two domain names are the same. Comparison is done in a case-insensitive way.

Parameters:
nam  Domain name to compare with
Returns:
True if the domain names are not the same

domainname& domainname::operator+ const domainname dom  ) 
 

concatenation using +

Appends two domain names, returning a third. The first domain name becomes a child domain of the second one.

Parameters:
dom  The domain name to append
Returns:
The result of the concaternation.

domainname& domainname::operator+= const domainname dom  ) 
 

concatenation using +=

Appends another domain name to the current domain name. The current domain name becomes a child domain of the appended domain name, for example, domainname("www") += domainname("acdam.net") would become www.acdam.net.

Parameters:
dom  Domain name to append
Returns:
The resulting domain name
See also:
#operator+

domainname& domainname::operator= const char *  buff  ) 
 

assignment from human-readable text

Assigns another domain name, given in human-readable text. Relative domain names are considered relative to the root domain

Parameters:
buff  The domain name in human-readable text
Returns:
The assigned domain name

domainname& domainname::operator= const domainname nam  ) 
 

assignment

Assigns another domain name

Parameters:
nam  The domain name to assign
Returns:
The assigned domain name

bool domainname::operator== const domainname nam  ) 
 

equality test

Tests whether the two domain names are the same. Comparison is done in a case-insensitive way.

Parameters:
nam  Domain name to compare with
Returns:
True if the domain names are the same

bool domainname::operator> const domainname dom  ) 
 

parent-child test

Tests whether we are the child domain of the given domain name. Returns false if the child and parent domain names given are the same.

Parameters:
dom  Domain name to test
Returns:
True if we are the parent
See also:
operator>=

bool domainname::operator>= const domainname dom  ) 
 

parent-child test

Tests whether we are the child domain of the given domain name. This function also returns true if the child and parent domains are the same.

Parameters:
dom  Domain name to test
Returns:
True if we are the parent
See also:
operator>

domainname domainname::to int  labels  ) 
 

domain-name portion

Returns a domain name consisting of the first label labels of the given domain name.

Parameters:
labels  Number of labels
Returns:
The domain name portion
See also:
from()

stl_string domainname::torelstring domainname root  ) 
 

return relative representation

Returns a string representation of the domain name, relative to the given origin. If the domain is not a child of the given root, the complete, absolte domain name is returned. If we are the domain name queried itself, an "@" is returned.

Parameters:
Domain  name this domain is relative to
Returns:
Relative string representation
See also:
tostring()

stl_string domainname::tostring  ) 
 

convert to human-readable string

Converts the domain name to a human-readable string. The string will always have a trailing dot.

Returns:
Human-readable domain name
See also:
tocstr()

The documentation for this class was generated from the following file:
Generated on Fri Dec 24 19:55:16 2004 for Poslib by doxygen 1.3.7