Elliott Hughes | 653c210 | 2019-01-09 15:41:36 -0800 | [diff] [blame] | 1 | .TH PCRE2_SERIALIZE_ENCODE 3 "27 June 2018" "PCRE2 10.32" |
Janis Danisevskis | 112c9cc | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 2 | .SH NAME |
| 3 | PCRE2 - 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 |
| 18 | This function encodes a list of compiled patterns into a byte stream that can |
Elliott Hughes | 653c210 | 2019-01-09 15:41:36 -0800 | [diff] [blame] | 19 | be saved on disc or elsewhere. Note that this is not an abstract format like |
| 20 | Java or .NET. Conversion of the byte stream back into usable compiled patterns |
| 21 | can only happen on a host that is running the same version of PCRE2, with the |
| 22 | same code unit width, and the host must also have the same endianness, pointer |
| 23 | width and PCRE2_SIZE type. The arguments for \fBpcre2_serialize_encode()\fP |
| 24 | are: |
Janis Danisevskis | 112c9cc | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 25 | .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 |
| 32 | The context argument is used to obtain memory for the byte stream. When the |
| 33 | serialized 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 |
| 35 | serialized 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 |
| 43 | PCRE2_ERROR_BADMAGIC means either that a pattern's code has been corrupted, or |
| 44 | that a slot in the vector does not point to a compiled pattern. |
| 45 | .P |
| 46 | There is a complete description of the PCRE2 native API in the |
| 47 | .\" HREF |
| 48 | \fBpcre2api\fP |
| 49 | .\" |
Elliott Hughes | 653c210 | 2019-01-09 15:41:36 -0800 | [diff] [blame] | 50 | page and a description of the serialization functions in the |
Janis Danisevskis | 112c9cc | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 51 | .\" HREF |
Elliott Hughes | 653c210 | 2019-01-09 15:41:36 -0800 | [diff] [blame] | 52 | \fBpcre2serialize\fP |
Janis Danisevskis | 112c9cc | 2016-03-31 13:35:25 +0100 | [diff] [blame] | 53 | .\" |
| 54 | page. |