本文整理汇总了C++中BVariant类的典型用法代码示例。如果您正苦于以下问题:C++ BVariant类的具体用法?C++ BVariant怎么用?C++ BVariant使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BVariant类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: setAsyncResult
virtual void setAsyncResult(const BVariant& result) {
try {
if (result.isException()) {
innerResult->setAsyncResult(result);
}
else {
POBJECT obj;
result.get(obj);
PMessage msg = byps_static_ptr_cast<BMessage>(obj);
BNegotiate nego;
nego.read(msg->buf);
{
byps_unique_lock lock(transport->mtx);
transport->protocol = transport->createNegotiatedProtocol(nego);
transport->targetId = nego.targetId;
transport->connectedServerId = nego.targetId.getServerId();
transport->sessionId = nego.sessionId;
}
transport->internalAuthenticate(innerResult);
}
}
catch (const exception& ex) {
innerResult->setAsyncResult(BVariant(ex));
}
delete this;
}
示例3: 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;
}
示例4: 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;
}
}
示例5: Value
SettingsOption*
Settings::OptionValue(OptionsSetting* setting) const
{
BVariant value = Value(setting);
return value.Type() == B_STRING_TYPE
? setting->OptionByID(value.ToString())
: setting->DefaultOption();
}
示例6: locker
BVariant
Settings::Value(Setting* setting) const
{
AutoLocker<BLocker> locker(fLock);
BVariant value;
return value.SetFromMessage(fValues, setting->ID()) == B_OK
? value : setting->DefaultValue();
}
示例7: GetValueFormatter
bool
TableCellIntegerEditor::ValidateInput() const
{
BVariant variantValue;
if (!InitialValue()->ToVariant(variantValue))
return false;
return GetValueFormatter()->ValidateFormattedValue(Text(),
variantValue.Type());
}
示例8: 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;
}
示例9:
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;
}
}
示例10: 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;
}
示例11: GetPreferredWidth
float GetPreferredWidth(const BVariant& value, BView* targetView) const
{
// get the preferred width from the node's designated renderer
if (value.Type() == VALUE_NODE_TYPE) {
ModelNode* node = dynamic_cast<ModelNode*>(value.ToReferenceable());
if (node != NULL && node->GetValue() != NULL
&& node->TableCellRenderer() != NULL) {
return node->TableCellRenderer()->PreferredValueWidth(
node->GetValue(), targetView);
}
}
return fColumn.BTitledColumn::GetPreferredWidth(NULL, targetView);
}
示例12: if
bool
CpuStateX8664::SetRegisterValue(const Register* reg, const BVariant& value)
{
int32 index = reg->Index();
if (index >= X86_64_XMM_REGISTER_END)
return false;
if (index < X86_64_INT_REGISTER_END)
fIntRegisters[index] = value.ToUInt64();
else if (index >= X86_64_REGISTER_ST0 && index < X86_64_FP_REGISTER_END)
fFloatRegisters[index - X86_64_REGISTER_ST0] = value.ToDouble();
else if (index >= X86_64_REGISTER_MM0 && index < X86_64_MMX_REGISTER_END) {
if (value.Size() > sizeof(int64))
return false;
memset(&fMMXRegisters[index - X86_64_REGISTER_MM0], 0,
sizeof(x86_64_fp_register));
memcpy(fMMXRegisters[index - X86_64_REGISTER_MM0].value,
value.ToPointer(), value.Size());
} else if (index >= X86_64_REGISTER_XMM0
&& index < X86_64_XMM_REGISTER_END) {
if (value.Size() > sizeof(x86_64_xmm_register))
return false;
memset(&fXMMRegisters[index - X86_64_REGISTER_XMM0], 0,
sizeof(x86_64_xmm_register));
memcpy(fXMMRegisters[index - X86_64_REGISTER_XMM0].value,
value.ToPointer(), value.Size());
} else
return false;
fSetRegisters[index] = 1;
return true;
}
示例13:
status_t
InitializeBFSEditor::ParameterChanged(const char* name, const BVariant& variant)
{
if (!strcmp(name, "name"))
fNameControl->SetText(variant.ToString());
return B_OK;
}
示例14:
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;
}
示例15: 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;
}
}