PARCBufferComposer * ccnxNameSegment_BuildString(const CCNxNameSegment *segment, PARCBufferComposer *composer) { ccnxNameLabel_BuildString(segment->label, composer); if (ccnxNameSegment_Length(segment) > 0) { PARCURISegment *uriSegment = parcURISegment_CreateFromBuffer(ccnxNameSegment_GetValue(segment)); parcURISegment_BuildString(uriSegment, composer); parcURISegment_Release(&uriSegment); } return composer; }
char * parcURISegment_ToString(const PARCURISegment *segment) { PARCBufferComposer *composer = parcBufferComposer_Create(); char *result = NULL; if (parcURISegment_BuildString(segment, composer)) { PARCBuffer *tempBuffer = parcBufferComposer_ProduceBuffer(composer); result = parcBuffer_ToString(tempBuffer); parcBuffer_Release(&tempBuffer); } parcBufferComposer_Release(&composer); return result; }
PARCBufferComposer * parcURIPath_BuildString(const PARCURIPath *path, PARCBufferComposer *composer) { size_t nSegments = parcArrayList_Size(path->segments); for (size_t i = 0; i < nSegments && composer != NULL; i++) { if (parcURISegment_BuildString(parcURIPath_Get(path, i), composer) == NULL) { composer = NULL; } if (i < (nSegments - 1)) { composer = parcBufferComposer_PutChar(composer, '/'); } } return composer; }