本文整理汇总了C++中BNode::ReadAttr方法的典型用法代码示例。如果您正苦于以下问题:C++ BNode::ReadAttr方法的具体用法?C++ BNode::ReadAttr怎么用?C++ BNode::ReadAttr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BNode
的用法示例。
在下文中一共展示了BNode::ReadAttr方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
status_t
StyledEditView::GetStyledText(BPositionIO* stream)
{
fSuppressChanges = true;
status_t result = BTranslationUtils::GetStyledText(stream, this,
fEncoding.String());
fSuppressChanges = false;
if (result != B_OK)
return result;
BNode* node = dynamic_cast<BNode*>(stream);
if (node != NULL) {
// get encoding
if (node->ReadAttrString("be:encoding", &fEncoding) != B_OK) {
// try to read as "int32"
int32 encoding;
ssize_t bytesRead = node->ReadAttr("be:encoding", B_INT32_TYPE, 0,
&encoding, sizeof(encoding));
if (bytesRead == (ssize_t)sizeof(encoding)) {
if (encoding == 65535) {
fEncoding = "UTF-8";
} else {
const BCharacterSet* characterSet
= BCharacterSetRoster::GetCharacterSetByConversionID(encoding);
if (characterSet != NULL)
fEncoding = characterSet->GetName();
}
}
}
// TODO: move those into BTranslationUtils::GetStyledText() as well?
// restore alignment
int32 align;
ssize_t bytesRead = node->ReadAttr("alignment", 0, 0, &align, sizeof(align));
if (bytesRead == (ssize_t)sizeof(align))
SetAlignment((alignment)align);
// restore wrapping
bool wrap;
bytesRead = node->ReadAttr("wrap", 0, 0, &wrap, sizeof(wrap));
if (bytesRead == (ssize_t)sizeof(wrap)) {
SetWordWrap(wrap);
if (wrap == false) {
BRect textRect;
textRect = Bounds();
textRect.OffsetTo(B_ORIGIN);
textRect.InsetBy(TEXT_INSET, TEXT_INSET);
// the width comes from stylededit R5. TODO: find a better way
textRect.SetRightBottom(BPoint(1500.0, textRect.RightBottom().y));
SetTextRect(textRect);
}
}
}
return result;
}
示例2: while
/* copy atribytes */
bool
BF_GUI_FilesPanel_CopyTask::Copy_Atributes(BNode & o_NodeSrc,BNode & o_NodeDest)
{
char pcName[B_ATTR_NAME_LENGTH];
attr_info uAttrInfo;
uint32 iBufMaxSize=255;
char *pcBuf = (char*)malloc(iBufMaxSize);
o_NodeSrc.RewindAttrs();
//
while(B_OK==o_NodeSrc.GetNextAttrName(pcName)) {
if(B_OK==o_NodeSrc.GetAttrInfo(pcName,&uAttrInfo)) {
/* check buffer size */
if(uAttrInfo.size>iBufMaxSize) {
DELETE(pcBuf);
iBufMaxSize = uAttrInfo.size;
pcBuf = (char*)malloc(iBufMaxSize);
}
/* read attr */
o_NodeSrc.ReadAttr(pcName,uAttrInfo.type,0,
(void*)pcBuf,uAttrInfo.size);
/* write attr */
o_NodeDest.WriteAttr(pcName,uAttrInfo.type,
0,(void*)pcBuf,uAttrInfo.size);
/* check for cancel_process */
if(Canceled()) return false;
}
}
DELETE(pcBuf);
return true;
}/* end of atributes */
示例3: MakeTypeString
bool
ResourceData::SetFromAttribute(const char *name, BNode &node)
{
attr_info info;
if (node.GetAttrInfo(name, &info) != B_OK) {
*this = ResourceData();
return false;
}
fType = info.type;
fID = -1;
fIDString = "(attr)";
fName = name;
fLength = info.size;
fAttr = true;
fTypeString = MakeTypeString(fType);
fData = (char *)malloc(fLength);
if (fData) {
ssize_t size = node.ReadAttr(name, info.type, 0, (void*)fData, fLength);
if (size >= 0) {
fLength = (size_t) size;
return true;
}
}
*this = ResourceData();
return false;
}
示例4: memIO
/*
* this method is not currently being used, but it may be useful in the future...
*/
status_t
DefaultCatalog::ReadFromAttribute(const entry_ref &appOrAddOnRef)
{
BNode node;
status_t res = node.SetTo(&appOrAddOnRef);
if (res != B_OK)
return B_ENTRY_NOT_FOUND;
attr_info attrInfo;
res = node.GetAttrInfo(BLocaleRoster::kEmbeddedCatAttr, &attrInfo);
if (res != B_OK)
return B_NAME_NOT_FOUND;
if (attrInfo.type != B_MESSAGE_TYPE)
return B_BAD_TYPE;
size_t size = attrInfo.size;
auto_ptr<char> buf(new(std::nothrow) char [size]);
if (buf.get() == NULL)
return B_NO_MEMORY;
res = node.ReadAttr(BLocaleRoster::kEmbeddedCatAttr, B_MESSAGE_TYPE, 0,
buf.get(), size);
if (res < (ssize_t)size)
return res < B_OK ? res : B_BAD_DATA;
BMemoryIO memIO(buf.get(), size);
res = Unflatten(&memIO);
return res;
}
示例5: app_sig_for_pathname
void app_sig_for_pathname(const char * path, BString * signature)
{
*signature = ZK_APP_SIG;
BNode node (path);
attr_info info;
char buffer [B_MIME_TYPE_LENGTH];
if (node.GetAttrInfo("BEOS:APP_SIG", & info) == B_OK)
{
PRINT(("node.GetAttrInfo(BEOS:APP_SIG, & info) == B_OK\n"));
if (node.ReadAttr("BEOS:APP_SIG", info.type, 0, & buffer, info.size) == info.size)
{
PRINT(("node.ReadAttr(BEOS:APP_SIG, info.type, 0, & buffer, info.size) == B_OK\n"));
PRINT(("attribute: %s \n", buffer));
*signature = buffer;
}
else
PRINT(("No BEOS:APP_SIG attribute. Fallback to default.\n"));
}
else
PRINT(("No BEOS:APP_SIG attribute. Fallback to default.\n"));
}
示例6:
void
BepdfApplication::UpdateAttr(BNode &node, const char *name, type_code type, off_t offset, void *buffer, size_t length) {
char dummy[10];
if (B_ENTRY_NOT_FOUND == node.ReadAttr(name, type, offset, (char*)dummy, sizeof(dummy))) {
node.WriteAttr(name, type, offset, buffer, length);
}
}
示例7: BNode
void
ActivityView::_LoadBackgroundInfo(bool watch)
{
fCachedOutline = false;
fCachedWorkspace = -1;
BPath path;
if (find_directory(B_DESKTOP_DIRECTORY, &path) == B_OK) {
BNode desktopNode = BNode(path.Path());
attr_info info;
if (desktopNode.GetAttrInfo(kDesktopAttrName, &info) != B_OK)
return;
char* buffer = new char[info.size];
if (desktopNode.ReadAttr(kDesktopAttrName, B_MESSAGE_TYPE, 0,
buffer, (size_t)info.size) == info.size) {
BMessage message;
if (message.Unflatten(buffer) == B_OK)
fBackgroundInfo = message;
}
delete[] buffer;
if (watch) {
node_ref nref;
desktopNode.GetNodeRef(&nref);
watch_node(&nref, B_WATCH_ATTR, this);
}
}
}
示例8:
/*! Work-around for a broken index that contains out-of-date information.
*/
/*static*/ bool
MailDaemonApp::_IsPending(BNode& node)
{
int32 flags;
if (node.ReadAttr(B_MAIL_ATTR_FLAGS, B_INT32_TYPE, 0, &flags, sizeof(int32))
!= (ssize_t)sizeof(int32))
return false;
return (flags & B_MAIL_PENDING) != 0;
}
示例9: sizeof
uint32
IMAPFolder::_ReadUInt32(BNode& node, const char* attribute) const
{
uint32 value;
ssize_t bytesRead = node.ReadAttr(attribute, B_UINT32_TYPE, 0,
&value, sizeof(uint32));
if (bytesRead == (ssize_t)sizeof(uint32))
return value;
return 0;
}
示例10: new
/*! \brief Fetches the vector icon used by an application of this type for files of the
given type.
The type of the \c BMimeType object is not required to actually be a subtype of
\c "application/"; that is the intended use however, and calling \c get_icon_for_type()
on a non-application type will likely return \c B_ENTRY_NOT_FOUND.
The icon data is allocated and returned in \a data.
\param type The MIME type
\param fileType Pointer to a pre-allocated string containing the MIME type whose
custom icon you wish to fetch. If NULL, works just like get_icon().
\param data Pointer in which the icon data is returned on success.
\param size Pointer in which the size of the icon data is returned.
\return
- \c B_OK: Success
- \c B_ENTRY_NOT_FOUND: No vector icon exists for the given type
- "error code": Failure
*/
status_t
get_icon_for_type(const char* type, const char* fileType, uint8** data,
size_t* size)
{
if (!type || !data || !size)
return B_BAD_VALUE;
// open the node for the given type
BNode node;
ssize_t err = open_type(type, &node);
if (err < B_OK)
return (status_t)err;
// construct our attribute name
std::string iconAttrName;
if (fileType)
iconAttrName = kIconAttrPrefix + BPrivate::Storage::to_lower(fileType);
else
iconAttrName = kIconAttr;
// get info about attribute for that name
attr_info info;
if (!err)
err = node.GetAttrInfo(iconAttrName.c_str(), &info);
// validate attribute type
if (!err)
err = (info.type == B_VECTOR_ICON_TYPE) ? B_OK : B_BAD_VALUE;
// allocate a buffer and read the attribute data into it
if (!err) {
uint8* buffer = new(std::nothrow) uint8[info.size];
if (!buffer)
err = B_NO_MEMORY;
if (!err) {
err = node.ReadAttr(iconAttrName.c_str(), B_VECTOR_ICON_TYPE,
0, buffer, info.size);
}
if (err >= 0)
err = (err == info.size) ? (ssize_t)B_OK : (ssize_t)B_FILE_ERROR;
if (!err) {
// success, set data pointer and size
*data = buffer;
*size = info.size;
} else {
delete[] buffer;
}
}
return err;
}
示例11: memset
status_t
IMAPStorage::ReadUniqueID(BNode& node, int32& uid)
{
const uint32 kMaxUniqueLength = 32;
char uidString[kMaxUniqueLength];
memset(uidString, 0, kMaxUniqueLength);
if (node.ReadAttr("MAIL:unique_id", B_STRING_TYPE, 0, uidString,
kMaxUniqueLength) < 0)
return B_ERROR;
uid = atoi(uidString);
return B_OK;
}
示例12: memIO
/*
* this method is not currently being used, but it may be useful in the future...
*/
status_t
DefaultCatalog::ReadFromAttribute(entry_ref *appOrAddOnRef)
{
BNode node;
status_t res = node.SetTo(appOrAddOnRef);
if (res != B_OK) {
log_team(LOG_ERR,
"couldn't find app or add-on (dev=%lu, dir=%Lu, name=%s)",
appOrAddOnRef->device, appOrAddOnRef->directory,
appOrAddOnRef->name);
return B_ENTRY_NOT_FOUND;
}
log_team(LOG_DEBUG,
"looking for embedded catalog-attribute in app/add-on"
"(dev=%lu, dir=%Lu, name=%s)", appOrAddOnRef->device,
appOrAddOnRef->directory, appOrAddOnRef->name);
attr_info attrInfo;
res = node.GetAttrInfo(BLocaleRoster::kEmbeddedCatAttr, &attrInfo);
if (res != B_OK) {
log_team(LOG_DEBUG, "no embedded catalog found");
return B_NAME_NOT_FOUND;
}
if (attrInfo.type != B_MESSAGE_TYPE) {
log_team(LOG_ERR, "attribute %s has incorrect type and is ignored!",
BLocaleRoster::kEmbeddedCatAttr);
return B_BAD_TYPE;
}
size_t size = attrInfo.size;
auto_ptr<char> buf(new(std::nothrow) char [size]);
if (buf.get() == NULL) {
log_team(LOG_ERR, "couldn't allocate array of %d chars", size);
return B_NO_MEMORY;
}
res = node.ReadAttr(BLocaleRoster::kEmbeddedCatAttr, B_MESSAGE_TYPE, 0,
buf.get(), size);
if (res < (ssize_t)size) {
log_team(LOG_ERR, "unable to read embedded catalog from attribute");
return res < B_OK ? res : B_BAD_DATA;
}
BMemoryIO memIO(buf.get(), size);
res = Unflatten(&memIO);
return res;
}
示例13: sizeof
status_t
read_read_attr(BNode& node, read_flags& flag)
{
if (node.ReadAttr(B_MAIL_ATTR_READ, B_INT32_TYPE, 0, &flag, sizeof(int32))
== sizeof(int32))
return B_OK;
#if R5_COMPATIBLE
BString statusString;
if (node.ReadAttrString(B_MAIL_ATTR_STATUS, &statusString) == B_OK) {
if (statusString.ICompare("New"))
flag = B_UNREAD;
else
flag = B_READ;
return B_OK;
}
#endif
return B_ERROR;
}
示例14: sizeof
/* isProject
* checks if an selected folder is a lava project folder.
*/
bool
ProjectTypeSelector::isProject()
{
BNode objNode;
BString *Project = (BString*)FileList->FirstItem();
objNode.SetTo(Project->String());
char buffer[500];
memset(buffer, 0, sizeof(buffer));
if(objNode.ReadAttr("LAVA:Type", B_STRING_TYPE, 0, buffer, sizeof(buffer)) == B_ENTRY_NOT_FOUND)
return false;
else {
BDirectory objDir;
objDir.SetTo(Project->String());
if(objDir.InitCheck() != B_OK)
return false;
else
return true;
}
}
示例15: Filter
bool EventFileRefFilter::Filter( const entry_ref* ref,
BNode* node,
struct stat_beos* st,
const char* filetype )
{
BString fileType( filetype );
BDirectory testDir( ref );
BEntry tempEntry;
BNode tempNode;
char buffer[ B_MIME_TYPE_LENGTH ];
// All directories are allowed - else the user won't be able to travel
if ( testDir.InitCheck() == B_OK ) {
return true;
}
// All Event files are allowed
if ( fileType.IFindFirst( kEventFileMIMEType ) == 0 ) {
return true;
}
// Symlinks are traversed and allowed only if they point to audio file
while ( fileType.IFindFirst( "application/x-vnd.Be-symlink" ) == 0 )
{
if ( ( B_OK == tempEntry.SetTo( ref, true ) ) && // Find the entry referenced by symlink
( B_OK == tempNode.SetTo( &tempEntry ) ) && // Access the attributes (needed to read file type)
( 0 != tempNode.ReadAttr( "BEOS:TYPE", B_STRING_TYPE, 0, buffer, 255 ) ) &&
( NULL != fileType.SetTo( buffer ) ) && // This check is really unnecessary
( fileType.IFindFirst( kEventFileMIMEType ) == 0 ) )
{
return true;
}
}
return false;
} // <-- end of function EventFileRefFilter::Filter