(ctx context.Context, what string, maxlen int)
| 436 | } |
| 437 | |
| 438 | func (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) |
no test coverage detected