1 #include "NodeMessage.h"
2 #include <StorageKit.h>
7 These functions gives a nice BMessage interface to node attributes,
8 by letting you transfer attributes to and from BMessages. It makes
9 it so you can use all the convenient Find...() and Add...() functions
10 provided by BMessage for attributes too. You use it as follows:
14 if (reading) { n>>m; printf("woohoo=%s\n",m.FindString("woohoo")) }
15 else { m.AddString("woohoo","it's howdy doody time"); n<<m; }
17 If there is more than one data item with a given name, the first
18 item is the one writen to the node.
20 _EXPORT BNode
& operator<<(BNode
& n
, const BMessage
& m
)
22 #if defined(HAIKU_TARGET_PLATFORM_DANO)
31 m
.GetInfo(B_ANY_TYPE
, i
, &name
, &type
) == 0;
33 m
.FindData (name
,type
,0,&data
,&bytes
);
34 n
.WriteAttr(name
,type
,0, data
, bytes
);
40 _EXPORT BNode
& operator>>(BNode
& n
, BMessage
& m
)
42 char name
[B_ATTR_NAME_LENGTH
];
47 while (n
.GetNextAttrName(name
) == B_OK
) {
48 if (n
.GetAttrInfo(name
,&info
) != B_OK
)
52 if (char *newBuffer
= (char*)realloc(buf
, info
.size
))
57 info
.size
=n
.ReadAttr(name
,info
.type
,0,buf
,info
.size
);
59 m
.AddData(name
,info
.type
,buf
,info
.size
);