getIdentifier method

String getIdentifier()

Gets the the document identifier.

return The document identifier. throws DocumentException An error has occurred during Document Library execution.

Implementation

String getIdentifier() {
  Pointer<Char> pIdentifier = nullptr;
  Pointer<Int> pIdentifierSize = calloc.allocate(1);
  pIdentifierSize[0] = -1;
  try {
    var err = documentSDK.id3DocumentInfo_GetIdentifier(_pHandle.value, pIdentifier, pIdentifierSize);
    if (err == DocumentError.insufficientBuffer.value) {
      pIdentifier = calloc.allocate(pIdentifierSize.value);
      err = documentSDK.id3DocumentInfo_GetIdentifier(_pHandle.value, pIdentifier, pIdentifierSize);
      if (err != DocumentError.success.value) {
        throw DocumentException(err);
      }
    }
    final vIdentifier = utf8.decode(Uint8List.fromList(pIdentifier.cast<Uint8>().asTypedList(pIdentifierSize.value)));
    return vIdentifier;
  } finally {
    calloc.free(pIdentifier);
    calloc.free(pIdentifierSize);
  }
}