MCPcopy Create free account
hub / github.com/blues/note / binExtractString

Method binExtractString

lib/bulk.go:438–457  ·  view source on GitHub ↗
(ctx context.Context, what string, maxlen int)

Source from the content-addressed store, hash-verified

436}
437
438func (tmplContext *BulkTemplateContext) binExtractString(ctx context.Context, what string, maxlen int) (value string) {
439 var strbytes []byte
440 if tmplContext.NoteFormat == BulkNoteFormatOriginal {
441 for i := 0; i < maxlen; i++ {
442 b := byte(tmplContext.binExtractUint8(ctx, "stringlen"))
443 if b != 0 {
444 strbytes = append(strbytes, b)
445 }
446 }
447 } else if tmplContext.NoteFormat == BulkNoteFormatFlexNano {
448 stringLen := tmplContext.binExtractUint8(ctx, "stringlen")
449 strbytes = tmplContext.binExtractBytes(ctx, what, int(stringLen))
450 } else {
451 stringLen := tmplContext.binExtractUint16(ctx, "stringlen")
452 strbytes = tmplContext.binExtractBytes(ctx, what, int(stringLen))
453 }
454 // Escape any quotes in the string
455 value = strings.TrimSuffix(strings.TrimPrefix(strconv.Quote(string(strbytes)), "\""), "\"")
456 return
457}
458
459// BulkDecodeNextEntry extract a JSON object from the binary. Note that both 'when' and 'wherewhen'
460// returned in standard unix epoch seconds (not in nanoseconds)

Callers 1

BulkDecodeNextEntryMethod · 0.95

Calls 3

binExtractUint8Method · 0.95
binExtractBytesMethod · 0.95
binExtractUint16Method · 0.95

Tested by

no test coverage detected