packValues method

void packValues(
  1. Map<String, ValuePackager> codec, {
  2. bool rebuildHierarchy = true,
})

Replaces each string value with its packed bytes, using the packager the tag dictionary assigns to that tag path.

Implementation

void packValues(Map<String, ValuePackager> codec, {bool rebuildHierarchy = true}) {
  if (rebuildHierarchy) rebuildTagsHierarchy();
  for (final TlvMsg item in tags) {
    final Object? value = item.value;
    if (value is TlvList) {
      value.packValues(codec, rebuildHierarchy: false);
    } else {
      final ValuePackager? packager = codec[item.completeTagString];
      if (packager != null) item.value = packager.pack(value);
    }
  }
}