read_dictT_read_dictReadDictReadDictread_dict (Operator)

Name

read_dictT_read_dictReadDictReadDictread_dict — Read a dictionary from a file.

Signature

read_dict( : : FileName, GenParamName, GenParamValue : DictHandle)

Herror T_read_dict(const Htuple FileName, const Htuple GenParamName, const Htuple GenParamValue, Htuple* DictHandle)

void ReadDict(const HTuple& FileName, const HTuple& GenParamName, const HTuple& GenParamValue, HTuple* DictHandle)

void HDict::HDict(const HString& FileName, const HTuple& GenParamName, const HTuple& GenParamValue)

void HDict::HDict(const HString& FileName, const HString& GenParamName, const HString& GenParamValue)

void HDict::HDict(const char* FileName, const char* GenParamName, const char* GenParamValue)

void HDict::HDict(const wchar_t* FileName, const wchar_t* GenParamName, const wchar_t* GenParamValue)   (Windows only)

void HDict::ReadDict(const HString& FileName, const HTuple& GenParamName, const HTuple& GenParamValue)

void HDict::ReadDict(const HString& FileName, const HString& GenParamName, const HString& GenParamValue)

void HDict::ReadDict(const char* FileName, const char* GenParamName, const char* GenParamValue)

void HDict::ReadDict(const wchar_t* FileName, const wchar_t* GenParamName, const wchar_t* GenParamValue)   (Windows only)

static void HOperatorSet.ReadDict(HTuple fileName, HTuple genParamName, HTuple genParamValue, out HTuple dictHandle)

public HDict(string fileName, HTuple genParamName, HTuple genParamValue)

public HDict(string fileName, string genParamName, string genParamValue)

void HDict.ReadDict(string fileName, HTuple genParamName, HTuple genParamValue)

void HDict.ReadDict(string fileName, string genParamName, string genParamValue)

def read_dict(file_name: str, gen_param_name: MaybeSequence[str], gen_param_value: MaybeSequence[Union[int, float, str]]) -> HHandle

Description

read_dictread_dictReadDictReadDictReadDictread_dict reads a dictionary from the file FileNameFileNameFileNameFileNamefileNamefile_name and returns the handle of the dictionary in DictHandleDictHandleDictHandleDictHandledictHandledict_handle.

The operator supports the following file formats:

'hdict'"hdict""hdict""hdict""hdict""hdict":

Binary HALCON format for dictionaries. Files with this format can be written by write_dictwrite_dictWriteDictWriteDictWriteDictwrite_dict. The default file extension for this format is 'hdict'.

'json'"json""json""json""json""json":

JSON (JavaScript Object Notation) file format. The default file extension for this format is 'json'.

If the given file does not exist, the operator attempts to find the file by appending the default file extensions to the filename. The file type is automatically recognized based on the file content and the file ending (which have to be consistent).

A set of additional optional parameters can be set. The names and values of the parameters are passed in GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name and GenParamValueGenParamValueGenParamValueGenParamValuegenParamValuegen_param_value, respectively. Some of the optional parameters can only be set for a certain file type. The following values for GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name are possible:

'json_value_true'"json_value_true""json_value_true""json_value_true""json_value_true""json_value_true", 'json_value_false'"json_value_false""json_value_false""json_value_false""json_value_false""json_value_false", 'json_value_null'"json_value_null""json_value_null""json_value_null""json_value_null""json_value_null":

Set the values that are used for JSON primitives. Valid JSON primitives are 'true'"true""true""true""true""true", 'false'"false""false""false""false""false", and 'null'"null""null""null""null""null". When encountering such a primitive in a JSON file, the corresponding value in the read dictionary is set to the value defined with these parameters. The value passed in GenParamValueGenParamValueGenParamValueGenParamValuegenParamValuegen_param_value must be a tuple of length 1.

The default values for primitives are 1 for 'true'"true""true""true""true""true", 0 for 'false'"false""false""false""false""false", and 'HNULL'"HNULL""HNULL""HNULL""HNULL""HNULL" for 'null'"null""null""null""null""null". These parameters only have an effect when reading a JSON file.

Execution Information

This operator returns a handle. Note that the state of an instance of this handle type may be changed by specific operators even though the handle is used as an input parameter by those operators.

Parameters

FileNameFileNameFileNameFileNamefileNamefile_name (input_control)  filename.read HTuplestrHTupleHtuple (string) (string) (HString) (char*)

File name.

File extension: .hdict, .json

GenParamNameGenParamNameGenParamNameGenParamNamegenParamNamegen_param_name (input_control)  attribute.name(-array) HTupleMaybeSequence[str]HTupleHtuple (string) (string) (HString) (char*)

Name of the generic parameter.

Default value: []

List of values: 'json_value_false'"json_value_false""json_value_false""json_value_false""json_value_false""json_value_false", 'json_value_null'"json_value_null""json_value_null""json_value_null""json_value_null""json_value_null", 'json_value_true'"json_value_true""json_value_true""json_value_true""json_value_true""json_value_true"

GenParamValueGenParamValueGenParamValueGenParamValuegenParamValuegen_param_value (input_control)  attribute.name(-array) HTupleMaybeSequence[Union[int, float, str]]HTupleHtuple (string / integer / real) (string / int / long / double) (HString / Hlong / double) (char* / Hlong / double)

Value of the generic parameter.

Default value: []

Suggested values: 0, 1, 'HNULL'"HNULL""HNULL""HNULL""HNULL""HNULL"

DictHandleDictHandleDictHandleDictHandledictHandledict_handle (output_control)  dict HDict, HTupleHHandleHTupleHtuple (handle) (IntPtr) (HHandle) (handle)

Dictionary handle.

Number of elements: DictHandle == 1

Result

If the parameters are valid, the operator read_dictread_dictReadDictReadDictReadDictread_dict returns the value TRUE. If necessary an exception is raised.

Possible Predecessors

write_dictwrite_dictWriteDictWriteDictWriteDictwrite_dict

See also

write_dictwrite_dictWriteDictWriteDictWriteDictwrite_dict, serialize_handleserialize_handleSerializeHandleSerializeHandleSerializeHandleserialize_handle, deserialize_handledeserialize_handleDeserializeHandleDeserializeHandleDeserializeHandledeserialize_handle

Module

Foundation