blob: d5293608a42bbaf55a652fed8d3e4e8f47c99246 [file] [log] [blame]
Elliott Hughes653c2102019-01-09 15:41:36 -08001.TH PCRE2_SERIALIZE_ENCODE 3 "27 June 2018" "PCRE2 10.32"
Janis Danisevskis112c9cc2016-03-31 13:35:25 +01002.SH NAME
3PCRE2 - Perl-compatible regular expressions (revised API)
4.SH SYNOPSIS
5.rs
6.sp
7.B #include <pcre2.h>
8.PP
9.nf
10.B int32_t pcre2_serialize_encode(const pcre2_code **\fIcodes\fP,
11.B " int32_t \fInumber_of_codes\fP, uint8_t **\fIserialized_bytes\fP,"
12.B " PCRE2_SIZE *\fIserialized_size\fP, pcre2_general_context *\fIgcontext\fP);"
13.fi
14.
15.SH DESCRIPTION
16.rs
17.sp
18This function encodes a list of compiled patterns into a byte stream that can
Elliott Hughes653c2102019-01-09 15:41:36 -080019be saved on disc or elsewhere. Note that this is not an abstract format like
20Java or .NET. Conversion of the byte stream back into usable compiled patterns
21can only happen on a host that is running the same version of PCRE2, with the
22same code unit width, and the host must also have the same endianness, pointer
23width and PCRE2_SIZE type. The arguments for \fBpcre2_serialize_encode()\fP
24are:
Janis Danisevskis112c9cc2016-03-31 13:35:25 +010025.sp
26 \fIcodes\fP pointer to a vector containing the list
27 \fInumber_of_codes\fP number of slots in the vector
28 \fIserialized_bytes\fP set to point to the serialized byte stream
29 \fIserialized_size\fP set to the number of bytes in the byte stream
30 \fIgcontext\fP pointer to a general context or NULL
31.sp
32The context argument is used to obtain memory for the byte stream. When the
33serialized data is no longer needed, it must be freed by calling
34\fBpcre2_serialize_free()\fP. The yield of the function is the number of
35serialized patterns, or one of the following negative error codes:
36.sp
37 PCRE2_ERROR_BADDATA \fInumber_of_codes\fP is zero or less
38 PCRE2_ERROR_BADMAGIC mismatch of id bytes in one of the patterns
39 PCRE2_ERROR_MEMORY memory allocation failed
40 PCRE2_ERROR_MIXEDTABLES the patterns do not all use the same tables
41 PCRE2_ERROR_NULL an argument other than \fIgcontext\fP is NULL
42.sp
43PCRE2_ERROR_BADMAGIC means either that a pattern's code has been corrupted, or
44that a slot in the vector does not point to a compiled pattern.
45.P
46There is a complete description of the PCRE2 native API in the
47.\" HREF
48\fBpcre2api\fP
49.\"
Elliott Hughes653c2102019-01-09 15:41:36 -080050page and a description of the serialization functions in the
Janis Danisevskis112c9cc2016-03-31 13:35:25 +010051.\" HREF
Elliott Hughes653c2102019-01-09 15:41:36 -080052\fBpcre2serialize\fP
Janis Danisevskis112c9cc2016-03-31 13:35:25 +010053.\"
54page.