def __iter__(self): if self.is_array: for i in range(core.BNMetadataSize(self.handle)): yield Metadata( handle=core.BNMetadataGetForIndex(self.handle, i)).value elif self.is_dict: result = core.BNMetadataGetValueStore(self.handle) try: for i in range(result.contents.size): if isinstance(result.contents.keys[i], bytes): yield str(pyNativeStr(result.contents.keys[i])) else: yield result.contents.keys[i] finally: core.BNFreeMetadataValueStore(result) else: raise Exception("Metadata object doesn't support iteration")
def __len__(self): if self.is_array or self.is_dict or self.is_string or self.is_raw: return core.BNMetadataSize(self.handle) raise Exception("Metadata object doesn't support len()")