PrettyPrintValue returns the string representation of all contiguous decodable values in the provided byte slice, separated by a provided separator. The directions each value is encoded may be provided. If valDirs is nil, all values are decoded and printed with the default direction (ascending).
(valDirs []Direction, b []byte, sep string)
| 1426 | // The directions each value is encoded may be provided. If valDirs is nil, |
| 1427 | // all values are decoded and printed with the default direction (ascending). |
| 1428 | func PrettyPrintValue(valDirs []Direction, b []byte, sep string) string { |
| 1429 | s1, allDecoded := prettyPrintValueImpl(valDirs, b, sep) |
| 1430 | if allDecoded { |
| 1431 | return s1 |
| 1432 | } |
| 1433 | if undoPrefixEnd, ok := UndoPrefixEnd(b); ok { |
| 1434 | // When we UndoPrefixEnd, we may have lost a tail of 0xFFs. Try to add |
| 1435 | // enough of them to get something decoded. This is best-effort, we have to stop |
| 1436 | // somewhere. |
| 1437 | cap := 20 |
| 1438 | if len(valDirs) > len(b) { |
| 1439 | cap = len(valDirs) - len(b) |
| 1440 | } |
| 1441 | for i := 0; i < cap; i++ { |
| 1442 | if s2, allDecoded := prettyPrintValueImpl(valDirs, undoPrefixEnd, sep); allDecoded { |
| 1443 | return s2 + sep + "PrefixEnd" |
| 1444 | } |
| 1445 | undoPrefixEnd = append(undoPrefixEnd, 0xFF) |
| 1446 | } |
| 1447 | } |
| 1448 | return s1 |
| 1449 | } |
| 1450 | |
| 1451 | func prettyPrintValueImpl(valDirs []Direction, b []byte, sep string) (string, bool) { |
| 1452 | allDecoded := true |
nothing calls this directly
no test coverage detected
searching dependent graphs…