本文整理汇总了C++中Context::FormatPointer方法的典型用法代码示例。如果您正苦于以下问题:C++ Context::FormatPointer方法的具体用法?C++ Context::FormatPointer怎么用?C++ Context::FormatPointer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Context
的用法示例。
在下文中一共展示了Context::FormatPointer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
// read_string
static
string
read_string(Context &context, void *data)
{
if (data == NULL || !context.GetContents(Context::STRINGS))
return context.FormatPointer(data);
char buffer[256];
int32 bytesRead;
status_t error = context.Reader().Read(data, buffer, sizeof(buffer), bytesRead);
if (error == B_OK) {
// return string("\"") + string(buffer, bytesRead) + "\"";
//string result("\"");
//result += string(buffer, bytesRead);
//result += "\"";
//return result;
// TODO: Unless I'm missing something obvious, our STL string class is broken.
// The appended "\"" doesn't appear in either of the above cases.
int32 len = strnlen(buffer, sizeof(buffer));
char largeBuffer[259];
largeBuffer[0] = '"';
memcpy(largeBuffer + 1, buffer, len);
largeBuffer[len + 1] = '"';
largeBuffer[len + 2] = '\0';
return largeBuffer;
}
return context.FormatPointer(data) + " (" + strerror(error) + ")";
}
示例2: read_fdset
string
TypeHandlerImpl<fd_set *>::GetParameterValue(Context &context, Parameter *,
const void *address)
{
void *data = *(void **)address;
if (data != NULL && context.GetContents(Context::SIMPLE_STRUCTS))
return read_fdset(context, data);
return context.FormatPointer(data);
}
示例3:
static string
format_unsigned_integer_pointer(Context &context, void *address)
{
Type data;
if (obtain_pointer_data(context, &data, address, Context::POINTER_VALUES))
return "[" + context.FormatUnsigned(data) + "]";
return context.FormatPointer(address);
}
示例4:
static string
format_pointer_value(Context &context, void *address)
{
Type data;
if (obtain_pointer_data(context, &data, address, Context::COMPLEX_STRUCTS))
return "{" + format_pointer(context, &data) + "}";
return context.FormatPointer(address);
}
示例5: sizeof
static string
read_fdset(Context &context, void *data)
{
// default FD_SETSIZE is 1024
unsigned long tmp[1024 / (sizeof(unsigned long) * 8)];
int32 bytesRead;
status_t err = context.Reader().Read(data, &tmp, sizeof(tmp), bytesRead);
if (err != B_OK)
return context.FormatPointer(data);
/* implicitly align to unsigned long lower boundary */
int count = bytesRead / sizeof(unsigned long);
int added = 0;
string r;
r.reserve(16);
r = "[";
for (int i = 0; i < count && added < 8; i++) {
for (int j = 0;
j < (int)(sizeof(unsigned long) * 8) && added < 8; j++) {
if (tmp[i] & (1 << j)) {
if (added > 0)
r += " ";
unsigned int fd = i * sizeof(unsigned long) * 8 + j;
r += format_number(fd);
added++;
}
}
}
if (added >= 8)
r += " ...";
r += "]";
return r;
}