1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
|
#include "stdafx.h"
#include "Host.h"
namespace sql {
Host::Host() : data(null) {}
Host Host::socket(Address *address) {
Host c;
c.data = address;
return c;
}
Host Host::local(Str *name) {
Host c;
c.data = name;
return c;
}
Host Host::local() {
return Host();
}
MAYBE(Address *) Host::isSocket() const {
return as<Address>(data);
}
MAYBE(Str *) Host::isLocal() const {
return as<Str>(data);
}
void Host::toS(StrBuf *to) const {
if (Address *a = isSocket())
*to << S("socket: ") << a;
else if (Str *l = isLocal())
*to << S("local socket/pipe: ") << l;
else
*to << S("local, default");
}
}
|