string EnumTypeHandler::RenderValue(Context &context, unsigned int value) const { if (context.GetContents(Context::ENUMERATIONS)) { EnumMap::const_iterator i = fMap.find(value); if (i != fMap.end() && i->second != NULL) return i->second; } return context.FormatUnsigned(value); }
static bool obtain_pointer_data(Context &context, Type *data, void *address, uint32 what) { if (address == NULL || !context.GetContents(what)) return false; int32 bytesRead; status_t err = context.Reader().Read(address, data, sizeof(Type), bytesRead); if (err != B_OK || bytesRead < (int32)sizeof(Type)) return false; return true; }
static string format_socket_type(Context &context, int type) { if (context.GetContents(Context::ENUMERATIONS)) { switch (type) { case SOCK_RAW: return "SOCK_RAW"; case SOCK_DGRAM: return "SOCK_DGRAM"; case SOCK_STREAM: return "SOCK_STREAM"; } } return "type = " + context.FormatSigned(type); }
static string format_socket_protocol(Context &context, int protocol) { if (context.GetContents(Context::ENUMERATIONS)) { switch (protocol) { case IPPROTO_IP: return "IPPROTO_IP"; case IPPROTO_RAW: return "IPPROTO_RAW"; case IPPROTO_ICMP: return "IPPROTO_ICMP"; case IPPROTO_UDP: return "IPPROTO_UDP"; case IPPROTO_TCP: return "IPPROTO_TCP"; } } return "protocol = " + context.FormatSigned(protocol); }
static string format_socket_family(Context &context, int family) { if (context.GetContents(Context::ENUMERATIONS)) { #define SOCKET_FAMILY(family) \ case family: \ return #family switch (family) { SOCKET_FAMILY(AF_UNSPEC); SOCKET_FAMILY(AF_INET); SOCKET_FAMILY(AF_APPLETALK); SOCKET_FAMILY(AF_ROUTE); SOCKET_FAMILY(AF_LINK); SOCKET_FAMILY(AF_INET6); SOCKET_FAMILY(AF_LOCAL); } } return "family = " + context.FormatSigned(family); }