本文整理汇总了C++中BVariant::SetTo方法的典型用法代码示例。如果您正苦于以下问题:C++ BVariant::SetTo方法的具体用法?C++ BVariant::SetTo怎么用?C++ BVariant::SetTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BVariant
的用法示例。
在下文中一共展示了BVariant::SetTo方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _GetBreakpointValueAt
bool _GetBreakpointValueAt(UserBreakpoint* breakpoint, int32 rowIndex,
int32 columnIndex, BVariant &value)
{
const UserBreakpointLocation& location = breakpoint->Location();
switch (columnIndex) {
case 0:
value.SetTo((int32)breakpoint->IsEnabled());
return true;
case 1:
value.SetTo(location.GetFunctionID()->FunctionName(),
B_VARIANT_DONT_COPY_DATA);
return true;
case 2:
{
LocatableFile* sourceFile = location.SourceFile();
BString data;
if (sourceFile != NULL) {
data.SetToFormat("%s:%" B_PRId32, sourceFile->Name(),
location.GetSourceLocation().Line() + 1);
} else {
AutoLocker<Team> teamLocker(fTeam);
if (UserBreakpointInstance* instance
= breakpoint->InstanceAt(0)) {
data.SetToFormat("%#" B_PRIx64, instance->Address());
}
}
value.SetTo(data);
return true;
}
default:
return false;
}
}
示例2: GetValueAt
virtual bool GetValueAt(void* object, int32 columnIndex, BVariant& value)
{
if (columnIndex != 0)
return false;
if (object == this)
return false;
if (object >= fSourceFileIndices
&& object < fSourceFileIndices + fSourceFileCount) {
int32 index = *(int32*)object;
if (LocatableFile* file = fFunctions[index]->SourceFile()) {
BString path;
file->GetPath(path);
value.SetTo(path);
} else
value.SetTo("<no source file>", B_VARIANT_DONT_COPY_DATA);
return true;
}
FunctionInstance* function = (FunctionInstance*)object;
value.SetTo(function->PrettyName(), B_VARIANT_DONT_COPY_DATA);
return true;
}
示例3: GetValueAt
virtual bool GetValueAt(int32 rowIndex, int32 columnIndex, BVariant& value)
{
StackFrame* frame
= fStackTrace != NULL ? fStackTrace->FrameAt(rowIndex) : NULL;
if (frame == NULL)
return false;
switch (columnIndex) {
case 0:
value.SetTo(frame->FrameAddress());
return true;
case 1:
value.SetTo(frame->InstructionPointer());
return true;
case 2:
{
char buffer[512];
value.SetTo(UiUtils::FunctionNameForFrame(frame, buffer,
sizeof(buffer)));
return true;
}
default:
return false;
}
}
示例4: strtoumax
status_t
IntegerValueFormatter::_ValidateUnsigned(const BString& input, type_code type,
::Value*& _output, integer_format format, bool wantsValue) const
{
const char* text = input.String();
int32 base = format == INTEGER_FORMAT_UNSIGNED ? 10 : 16;
char *parseEnd = NULL;
uintmax_t parsedValue = strtoumax(text, &parseEnd, base);
if (parseEnd - text < input.Length() && !isspace(*parseEnd))
return B_BAD_VALUE;
BVariant newValue;
switch (type) {
case B_UINT8_TYPE:
{
if (parsedValue > UINT8_MAX)
return B_BAD_VALUE;
newValue.SetTo((uint8)parsedValue);
break;
}
case B_UINT16_TYPE:
{
if (parsedValue > UINT16_MAX)
return B_BAD_VALUE;
newValue.SetTo((uint16)parsedValue);
break;
}
case B_UINT32_TYPE:
{
if (parsedValue > UINT32_MAX)
return B_BAD_VALUE;
newValue.SetTo((uint32)parsedValue);
break;
}
case B_UINT64_TYPE:
{
newValue.SetTo((uint64)parsedValue);
break;
}
default:
return B_BAD_VALUE;
}
if (wantsValue) {
_output = new(std::nothrow) IntegerValue(newValue);
if (_output == NULL)
return B_NO_MEMORY;
}
return B_OK;
}
示例5:
status_t
ArchitectureX8664::ReadValueFromMemory(target_addr_t address, uint32 valueType,
BVariant& _value) const
{
uint8 buffer[64];
size_t size = BVariant::SizeOfType(valueType);
if (size == 0 || size > sizeof(buffer))
return B_BAD_VALUE;
ssize_t bytesRead = fTeamMemory->ReadMemory(address, buffer, size);
if (bytesRead < 0)
return bytesRead;
if ((size_t)bytesRead != size)
return B_ERROR;
// TODO: We need to swap endianess, if the host is big endian!
switch (valueType) {
case B_INT8_TYPE:
_value.SetTo(*(int8*)buffer);
return B_OK;
case B_UINT8_TYPE:
_value.SetTo(*(uint8*)buffer);
return B_OK;
case B_INT16_TYPE:
_value.SetTo(*(int16*)buffer);
return B_OK;
case B_UINT16_TYPE:
_value.SetTo(*(uint16*)buffer);
return B_OK;
case B_INT32_TYPE:
_value.SetTo(*(int32*)buffer);
return B_OK;
case B_UINT32_TYPE:
_value.SetTo(*(uint32*)buffer);
return B_OK;
case B_INT64_TYPE:
_value.SetTo(*(int64*)buffer);
return B_OK;
case B_UINT64_TYPE:
_value.SetTo(*(uint64*)buffer);
return B_OK;
case B_FLOAT_TYPE:
_value.SetTo(*(float*)buffer);
// TODO: float on the host might work differently!
return B_OK;
case B_DOUBLE_TYPE:
_value.SetTo(*(double*)buffer);
// TODO: double on the host might work differently!
return B_OK;
default:
return B_BAD_VALUE;
}
}
示例6: strtoimax
status_t
IntegerValueFormatter::_ValidateSigned(const BString& input, type_code type,
::Value*& _output, bool wantsValue) const
{
const char* text = input.String();
char *parseEnd = NULL;
intmax_t parsedValue = strtoimax(text, &parseEnd, 10);
if (parseEnd - text < input.Length() && !isspace(*parseEnd))
return B_NO_MEMORY;
BVariant newValue;
switch (type) {
case B_INT8_TYPE:
{
if (parsedValue < INT8_MIN || parsedValue > INT8_MAX)
return B_BAD_VALUE;
newValue.SetTo((int8)parsedValue);
break;
}
case B_INT16_TYPE:
{
if (parsedValue < INT16_MIN || parsedValue > INT16_MAX)
return B_BAD_VALUE;
newValue.SetTo((int16)parsedValue);
break;
}
case B_INT32_TYPE:
{
if (parsedValue < INT32_MIN || parsedValue > INT32_MAX)
return B_BAD_VALUE;
newValue.SetTo((int32)parsedValue);
break;
}
case B_INT64_TYPE:
{
newValue.SetTo((int64)parsedValue);
break;
}
default:
return B_BAD_VALUE;
}
if (wantsValue) {
_output = new(std::nothrow) IntegerValue(newValue);
if (_output == NULL)
return B_NO_MEMORY;
}
return B_OK;
}
示例7:
bool
CpuStateX86::GetRegisterValue(const Register* reg, BVariant& _value) const
{
int32 index = reg->Index();
if (!IsRegisterSet(index))
return false;
if (index >= X86_INT_REGISTER_END)
return false;
if (reg->BitSize() == 16)
_value.SetTo((uint16)fIntRegisters[index]);
else
_value.SetTo(fIntRegisters[index]);
return true;
}
示例8: GetValueAt
virtual bool GetValueAt(int32 rowIndex, int32 columnIndex, BVariant& value)
{
Image* image = fImages.ItemAt(rowIndex);
if (image == NULL)
return false;
switch (columnIndex) {
case 0:
value.SetTo(image->ID());
return true;
case 1:
value.SetTo(image->Name(), B_VARIANT_DONT_COPY_DATA);
return true;
default:
return false;
}
}
示例9: GetValueAt
virtual bool GetValueAt(int32 rowIndex, int32 columnIndex, BVariant& value)
{
UserBreakpoint* breakpoint = fBreakpoints.ItemAt(rowIndex);
if (breakpoint == NULL)
return false;
const UserBreakpointLocation& location = breakpoint->Location();
switch (columnIndex) {
case 0:
value.SetTo((int32)breakpoint->IsEnabled());
return true;
case 1:
value.SetTo(location.GetFunctionID()->FunctionName(),
B_VARIANT_DONT_COPY_DATA);
return true;
case 2:
if (LocatableFile* sourceFile = location.SourceFile()) {
value.SetTo(sourceFile->Name(), B_VARIANT_DONT_COPY_DATA);
return true;
}
return false;
case 3:
if (location.SourceFile() != NULL) {
value.SetTo(location.GetSourceLocation().Line() + 1);
return true;
}
return false;
case 4:
if (location.SourceFile() == NULL) {
AutoLocker<Team> teamLocker(fTeam);
if (UserBreakpointInstance* instance
= breakpoint->InstanceAt(0)) {
value.SetTo(instance->Address());
return true;
}
}
return false;
default:
return false;
}
}
示例10: if
bool
CpuStateX8664::GetRegisterValue(const Register* reg, BVariant& _value) const
{
int32 index = reg->Index();
if (!IsRegisterSet(index))
return false;
if (index >= X86_64_XMM_REGISTER_END)
return false;
if (BVariant::TypeIsInteger(reg->ValueType())) {
if (reg->BitSize() == 16)
_value.SetTo((uint16)fIntRegisters[index]);
else
_value.SetTo(fIntRegisters[index]);
} else if (BVariant::TypeIsFloat(reg->ValueType())) {
index -= X86_64_REGISTER_ST0;
if (reg->ValueType() == B_FLOAT_TYPE)
_value.SetTo((float)fFloatRegisters[index]);
else
_value.SetTo(fFloatRegisters[index]);
} else {
if (index >= X86_64_REGISTER_MM0 && index < X86_64_REGISTER_XMM0) {
index -= X86_64_REGISTER_MM0;
_value.SetTo(fMMXRegisters[index].value);
} else {
index -= X86_64_REGISTER_XMM0;
_value.SetTo(fXMMRegisters[index].value);
}
}
return true;
}
示例11: _GetWatchpointValueAt
bool _GetWatchpointValueAt(Watchpoint* watchpoint, int32 rowIndex,
int32 columnIndex, BVariant &value)
{
switch (columnIndex) {
case 0:
value.SetTo((int32)watchpoint->IsEnabled());
return true;
case 1:
{
BString data;
data.SetToFormat("%s at 0x%" B_PRIx64 " (%" B_PRId32 " bytes)",
_WatchpointTypeToString(watchpoint->Type()),
watchpoint->Address(), watchpoint->Length());
value.SetTo(data);
return true;
}
case 2:
{
return false;
}
default:
return false;
}
}
示例12: GetValueAt
virtual bool GetValueAt(int32 rowIndex, int32 columnIndex, BVariant& value)
{
Thread* thread = fThreads.ItemAt(rowIndex);
if (thread == NULL)
return false;
switch (columnIndex) {
case 0:
value.SetTo(thread->ID());
return true;
case 1:
{
switch (thread->State()) {
case THREAD_STATE_RUNNING:
value.SetTo("Running", B_VARIANT_DONT_COPY_DATA);
return true;
case THREAD_STATE_STOPPED:
break;
case THREAD_STATE_UNKNOWN:
default:
value.SetTo("?", B_VARIANT_DONT_COPY_DATA);
return true;
}
// thread is stopped -- get the reason
switch (thread->StoppedReason()) {
case THREAD_STOPPED_DEBUGGER_CALL:
value.SetTo("Call", B_VARIANT_DONT_COPY_DATA);
return true;
case THREAD_STOPPED_EXCEPTION:
value.SetTo("Exception", B_VARIANT_DONT_COPY_DATA);
return true;
case THREAD_STOPPED_BREAKPOINT:
case THREAD_STOPPED_WATCHPOINT:
case THREAD_STOPPED_SINGLE_STEP:
case THREAD_STOPPED_DEBUGGED:
case THREAD_STOPPED_UNKNOWN:
default:
value.SetTo("Debugged", B_VARIANT_DONT_COPY_DATA);
return true;
}
}
case 2:
value.SetTo(thread->Name(), B_VARIANT_DONT_COPY_DATA);
return true;
default:
return false;
}
}