#include "NodeMessage.h" #include #include #include /* These functions gives a nice BMessage interface to node attributes, by letting you transfer attributes to and from BMessages. It makes it so you can use all the convenient Find...() and Add...() functions provided by BMessage for attributes too. You use it as follows: BMessage m; BNode n(path); if (reading) { n>>m; printf("woohoo=%s\n",m.FindString("woohoo")) } else { m.AddString("woohoo","it's howdy doody time"); n<>(BNode& n, BMessage& m) { char name[B_ATTR_NAME_LENGTH]; attr_info info; char *buf = NULL; n.RewindAttrs(); while (n.GetNextAttrName(name) == B_OK) { if (n.GetAttrInfo(name,&info) != B_OK) continue; // resize the buffer if (char *newBuffer = (char*)realloc(buf, info.size)) buf = newBuffer; else continue; info.size=n.ReadAttr(name,info.type,0,buf,info.size); if (info.size >= 0) m.AddData(name,info.type,buf,info.size); } n.RewindAttrs(); free(buf); return n; }