27 using namespace basis;
33 machine_uid::machine_uid()
42 *_contents += address;
56 *_contents += address;
63 static astring TCPIP_NAME =
"TCPIP";
64 static astring IPX_NAME =
"IPX";
65 static astring NETBIOS_NAME =
"NETBIOS";
66 static astring UNKNOWN_NAME =
"INVALID";
72 default:
return UNKNOWN_NAME;
78 if (
this == &to_copy)
return *
this;
79 *_contents = *to_copy._contents;
87 for (
int i = 1; i < _contents->
length(); i++) {
92 if (i < _contents->length() - 1)
102 byte_formatter::bytes_to_shifted_string(*_contents, to_return);
109 to_return._contents->
reset();
110 byte_formatter::shifted_string_to_bytes(compacted, *to_return._contents);
117 if (!_contents->
length() || !to_compare._contents->
length())
118 return !_contents->
length() && !to_compare._contents->
length();
119 if (_contents->
length() != to_compare._contents->
length())
return false;
120 for (
int i = 0; i < _contents->
length(); i++)
121 if (_contents->
get(i) != to_compare._contents->
get(i))
return false;
139 packed_form += *_contents;
147 if (packed_form.
length() < len)
return false;
149 *_contents = packed_form.
subarray(0, len - 1);
150 packed_form.
zap(0, len - 1);
162 class internal_machine_uid_array :
public array<machine_uid> {};
165 : _uids(new internal_machine_uid_array)
170 _uids(new internal_machine_uid_array(*to_copy._uids))
184 if (
this != &to_copy) {
185 *_uids = *to_copy._uids;
192 if (
member(to_add))
return false;
193 _uids->concatenate(to_add);
202 for (
int i = 0; i < _uids->length(); i++) {
203 to_return += _uids->get(i).text_form() +
" ";
209 {
return _uids->use(index); }
212 {
return _uids->get(index); }
218 const int test_len = to_test.
raw().
length();
219 for (
int i = 0; i < _uids->length(); i++) {
222 if ( (test_len == curr.
raw().
length()) && (curr == to_test) ) {
224 }
else if (!to_test.
valid() && !curr.
valid())
return true;
a_sprintf is a specialization of astring that provides printf style support.
Represents a sequential, ordered, contiguous collection of objects.
void reset(int number=0, const contents *initial_contents=NULL_POINTER)
Resizes this array and sets the contents from an array of contents.
array subarray(int start, int end) const
Returns the array segment between the indices "start" and "end".
const contents & get(int index) const
Accesses individual objects stored in "this" at the "index" position.
int length() const
Returns the current reported length of the allocated C array.
outcome zap(int start, int end)
Deletes from "this" the objects inclusively between "start" and "end".
int last() const
Returns the last valid element in the array.
Provides a dynamically resizable ASCII character string.
int length() const
Returns the current length of the string.
virtual const char * observe() const
observes the underlying pointer to the zero-terminated string.
A very common template for a dynamic array of bytes.
A base class for objects that can pack into an array of bytes.
internet_machine_uid(const basis::astring &hostname, const basis::byte_array &ip_address)
static const machine_uid_array & blank_array()
machine_uid & operator[](int index)
bool operator+=(const machine_uid &to_add)
bool member(const machine_uid &to_test) const
basis::astring text_form() const
virtual int packed_size() const
Estimates the space needed for the packed structure.
virtual bool unpack(basis::byte_array &packed_form)
Restores the packable from the "packed_form".
basis::byte_array native() const
static machine_uid expand(const basis::astring &compacted)
basis::astring text_form() const
known_location_types type() const
const basis::byte_array & raw() const
static const basis::astring & type_name(known_location_types type)
void reset(known_location_types type, const basis::byte_array &address)
virtual void pack(basis::byte_array &packed_form) const
Creates a packed form of the packable object in "packed_form".
machine_uid & operator=(const machine_uid &to_copy)
bool operator==(const machine_uid &to_compare) const
basis::astring compact_form() const
The guards collection helps in testing preconditions and reporting errors.
void WHACK(contents *&ptr)
deletion with clearing of the pointer.
unsigned char abyte
A fairly important unit which is seldom defined...
unsigned short un_short
Abbreviated name for unsigned short integers.
Provides access to the operating system's socket methods.
SAFE_STATIC_CONST(byte_array, internet_address::localhost,(ADDRESS_SIZE, localhosts_bytes)) bool internet_address
A dynamic container class that holds any kind of object via pointers.
void attach(byte_array &packed_form, const byte_array &to_attach)
Packs a byte_array "to_attach" into "packed_form".
const int PACKED_SIZE_INT32
bool detach(byte_array &packed_form, byte_array &to_detach)
Unpacks a byte_array "to_detach" from "packed_form".