Calling pn_data_narrow() changes the effect of pn_data_rewind(). Rewind will no longer bring you back to the start of the data, but instead it will bring you back to wherever you were when you called pn_data_narrow(). Pn_data_widen() restores the default behaviour of pn_data_rewind(). It's roughly analogous to the "narrow to region" functionality of emacs, although I'm sure that's a useless analogy for most people. ;-) It's also vaguely like the "slice/subset/view" concept that various languages have except instead of returning a new object representing a subset of the tree it functions by changing the original object to behave as a subset/slice/view.
On Wed, May 21, 2014 at 1:49 PM, Fraser Adams <[email protected] > wrote: > I was looking at these the other day and left scratching my head, I saw > them in the "lookup" unit test for codec but TBH I'm really none the wiser, > except to note that the test fails if I don't use them :-). > > > TBH codec could do with some API documentation, to be fair many of the > methods are fairly obvious, but there are a few less obvious ones. > Unfortunately codec.h was the one file I missed during my 0.7 documentation push, but I should be able to finish it up for 0.8. > > I also came across quite a subtle difference between codec and message: > > PN_EXTERN ssize_t pn_data_encode(pn_data_t *data, char *bytes, size_t > size); > PN_EXTERN int pn_message_encode(pn_message_t *msg, char *bytes, size_t > *size); > > The former return the actual size but the latter returns an error code > with the size updated in a reference parameter. That's a fairly easy one to > miss. > Yeah, the pn_message_encode is following an older pattern. At some point I would like to change all the signatures to be consistent. --Rafael
