High Performance OPC UA Server SDK  1.2.1.203
UA File Format Reader

This file reader implements a SAX like parser for the UA binary file format. More...

Data Structures

struct  ua_file_reader
 UA File Reader. More...
 

Typedefs

typedef int(* fct_add_namespace )(uint16_t nsidx, const char *uri, enum namespace_type type, struct ua_file_node_stat *stat, void *userdata)
 
typedef int(* fct_add_extension_namespace )(uint16_t nsidx, const char *uri, void *userdata)
 
typedef int(* fct_add_string_table )(unsigned int table_index, const char *locale, size_t size, void *userdata)
 
typedef int(* fct_add_string )(unsigned int table_index, unsigned int string_index, const char *text, void *userdata)
 
typedef int(* fct_add_node )(struct ua_file_reader_basenode *nodeinfo, void *userdata)
 
typedef int(* fct_add_reference )(struct ua_nodeid *src, struct ua_nodeid *dst, struct ua_nodeid *type, void *userdata)
 
typedef void(* fct_report_stat )(enum ua_file_reader_statistic_type type, size_t size, void *userdata)
 

Enumerations

enum  namespace_type { NS_PROVIDED = 0, NS_REQUIRED }
 
enum  ua_file_reader_statistic_type {
  UAF_STAT_HEADER = 0, UAF_STAT_EXT_NAMESPACES, UAF_STAT_GLOBAL_EXTENSIONS, UAF_STAT_STRINGTABLES,
  UAF_STAT_NAMESPACES, UAF_STAT_DATATYPES, UAF_STAT_REFERENCETYPES, UAF_STAT_VARIABLETYPES,
  UAF_STAT_OBJECTTYPES, UAF_STAT_VARIABLES, UAF_STAT_OBJECTS, UAF_STAT_METHODS,
  UAF_STAT_VIEWS, UAF_STAT_REFERENCES
}
 

Functions

int ua_file_reader_init (struct ua_file_reader *r, fct_add_namespace add_namespace_cb, fct_add_extension_namespace add_ext_namespace_cb, fct_add_string_table add_string_table_cb, fct_add_string add_string_cb, fct_add_node add_node_cb, fct_add_reference add_reference_cb, fct_report_stat report_stat_cb, void *userdata)
 Initializes the file reader context. More...
 
int ua_file_reader_load_file (struct ua_file_reader *r, const char *filename)
 Loads the given file. More...
 
int ua_file_reader_load_file_info (struct ua_file_reader *r, const char *filename)
 Only loads the file header info, not the complete file. More...
 
int ua_file_reader_get_version (struct ua_file_reader *r, unsigned char version[2])
 Returns the file version of the last loaded file. More...
 

Detailed Description

This file reader implements a SAX like parser for the UA binary file format.

For each parsed element a callback is called that the caller can use to create an address space from the file data.

Function Documentation

int ua_file_reader_get_version ( struct ua_file_reader r,
unsigned char  version[2] 
)

Returns the file version of the last loaded file.

You need to call ua_file_reader_load_file_info() or ua_file_reader_load_file() before calling this function.

Parameters
rFile reader context.
version[2]Vesion info. The first byte contains the major version, the second byte the minor version of the file.
Returns
Zero on success.
int ua_file_reader_init ( struct ua_file_reader r,
fct_add_namespace  add_namespace_cb,
fct_add_extension_namespace  add_ext_namespace_cb,
fct_add_string_table  add_string_table_cb,
fct_add_string  add_string_cb,
fct_add_node  add_node_cb,
fct_add_reference  add_reference_cb,
fct_report_stat  report_stat_cb,
void *  userdata 
)

Initializes the file reader context.

Parameters
rThe file reader context.
add_namespace_cbCallback for adding a new namespace.
add_ext_namespace_cbCallback for adding a new extension namespace.
add_string_table_cbCallback for adding a new string table.
add_string_cbCallback for adding a new string to an existing string table.
add_node_cbCallback for adding a new node.
add_reference_cbCallback for adding a new reference.
report_stat_cbCallback for reporting the file statistics. This contains the number of all nodes, references, etc. This is called first before any other callback is invoked. This can be used to setup the required memory pools.
Returns
Always returns 0.
int ua_file_reader_load_file ( struct ua_file_reader r,
const char *  filename 
)

Loads the given file.

Parameters
rInitializes file reader context.
filenameFilename of file to load.

Example code:

1 struct ua_file_reader reader;
2 int ret;
3 
4 ua_file_reader_init(&reader, my_add_namespace, my_ext_namespace_cb, my_add_string_table, my_add_string, my_add_node, my_add_reference, my_report_stat);
5 
6 ret = ua_file_reader_load_file(&reader, filename);
7 if (ret == 0) {
8  // Success
9 } else {
10  // Error
11 }
Returns
Zero on success.
int ua_file_reader_load_file_info ( struct ua_file_reader r,
const char *  filename 
)

Only loads the file header info, not the complete file.

Parameters
rInitializes file reader context with the file's meta data.
filenameFilename of file to load.
Returns
Zero on success.