本文整理汇总了C++中AttributeValue::SetTo方法的典型用法代码示例。如果您正苦于以下问题:C++ AttributeValue::SetTo方法的具体用法?C++ AttributeValue::SetTo怎么用?C++ AttributeValue::SetTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AttributeValue
的用法示例。
在下文中一共展示了AttributeValue::SetTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _AddAttribute
PackageWriter::Attribute*
PackageWriter::_AddStringAttribute(const char* attributeName, const char* value)
{
AttributeValue attributeValue;
attributeValue.SetTo(_GetCachedString(value));
return _AddAttribute(attributeName, attributeValue);
}
示例2: switch
status_t
PackageReader::_ReadAttributeValue(uint8 type, uint8 encoding,
AttributeValue& _value)
{
switch (type) {
case B_HPKG_ATTRIBUTE_TYPE_INT:
case B_HPKG_ATTRIBUTE_TYPE_UINT:
{
uint64 intValue;
status_t error;
switch (encoding) {
case B_HPKG_ATTRIBUTE_ENCODING_INT_8_BIT:
{
uint8 value;
error = _Read(value);
intValue = value;
break;
}
case B_HPKG_ATTRIBUTE_ENCODING_INT_16_BIT:
{
uint16 value;
error = _Read(value);
intValue = B_BENDIAN_TO_HOST_INT16(value);
break;
}
case B_HPKG_ATTRIBUTE_ENCODING_INT_32_BIT:
{
uint32 value;
error = _Read(value);
intValue = B_BENDIAN_TO_HOST_INT32(value);
break;
}
case B_HPKG_ATTRIBUTE_ENCODING_INT_64_BIT:
{
uint64 value;
error = _Read(value);
intValue = B_BENDIAN_TO_HOST_INT64(value);
break;
}
default:
{
fErrorOutput->PrintError("Error: Invalid TOC section: "
"invalid encoding %d for int value type %d\n", encoding,
type);
return B_BAD_VALUE;
}
}
if (error != B_OK)
return error;
if (type == B_HPKG_ATTRIBUTE_TYPE_INT)
_value.SetTo((int64)intValue);
else
_value.SetTo(intValue);
return B_OK;
}
case B_HPKG_ATTRIBUTE_TYPE_STRING:
{
if (encoding == B_HPKG_ATTRIBUTE_ENCODING_STRING_TABLE) {
uint64 index;
status_t error = _ReadUnsignedLEB128(index);
if (error != B_OK)
return error;
if (index > fTOCStringsCount) {
fErrorOutput->PrintError("Error: Invalid TOC section: "
"string reference out of bounds\n");
return B_BAD_DATA;
}
_value.SetTo(fStrings[index]);
} else if (encoding == B_HPKG_ATTRIBUTE_ENCODING_STRING_INLINE) {
const char* string;
status_t error = _ReadString(string);
if (error != B_OK)
return error;
_value.SetTo(string);
} else {
fErrorOutput->PrintError("Error: Invalid TOC section: invalid "
"string encoding (%u)\n", encoding);
return B_BAD_DATA;
}
return B_OK;
}
case B_HPKG_ATTRIBUTE_TYPE_RAW:
{
uint64 size;
status_t error = _ReadUnsignedLEB128(size);
if (error != B_OK)
return error;
if (encoding == B_HPKG_ATTRIBUTE_ENCODING_RAW_HEAP) {
uint64 offset;
//.........这里部分代码省略.........