openpilot is an open source driver assistance system. openpilot performs the functions of Automated Lane Centering and Adaptive Cruise Control for over 200 supported car makes and models.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

199 lines
7.0 KiB

'\" t
.\" Title: zrex
.\" Author: [see the "AUTHORS" section]
.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
.\" Date: 12/31/2016
.\" Manual: CZMQ Manual
.\" Source: CZMQ 4.0.2
.\" Language: English
.\"
.TH "ZREX" "3" "12/31/2016" "CZMQ 4\&.0\&.2" "CZMQ Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
zrex \- work with regular expressions
.SH "SYNOPSIS"
.sp
.nf
// Constructor\&. Optionally, sets an expression against which we can match
// text and capture hits\&. If there is an error in the expression, reports
// zrex_valid() as false and provides the error in zrex_strerror()\&. If you
// set a pattern, you can call zrex_matches() to test it against text\&.
CZMQ_EXPORT zrex_t *
zrex_new (const char *expression);
// Destructor
CZMQ_EXPORT void
zrex_destroy (zrex_t **self_p);
// Return true if the expression was valid and compiled without errors\&.
CZMQ_EXPORT bool
zrex_valid (zrex_t *self);
// Return the error message generated during compilation of the expression\&.
CZMQ_EXPORT const char *
zrex_strerror (zrex_t *self);
// Returns true if the text matches the previously compiled expression\&.
// Use this method to compare one expression against many strings\&.
CZMQ_EXPORT bool
zrex_matches (zrex_t *self, const char *text);
// Returns true if the text matches the supplied expression\&. Use this
// method to compare one string against several expressions\&.
CZMQ_EXPORT bool
zrex_eq (zrex_t *self, const char *text, const char *expression);
// Returns number of hits from last zrex_matches or zrex_eq\&. If the text
// matched, returns 1 plus the number of capture groups\&. If the text did
// not match, returns zero\&. To retrieve individual capture groups, call
// zrex_hit ()\&.
CZMQ_EXPORT int
zrex_hits (zrex_t *self);
// Returns the Nth capture group from the last expression match, where
// N is 0 to the value returned by zrex_hits()\&. Capture group 0 is the
// whole matching string\&. Sequence 1 is the first capture group, if any,
// and so on\&.
CZMQ_EXPORT const char *
zrex_hit (zrex_t *self, uint index);
// Fetches hits into string variables provided by caller; this makes for
// nicer code than accessing hits by index\&. Caller should not modify nor
// free the returned values\&. Returns number of strings returned\&. This
// method starts at hit 1, i\&.e\&. first capture group, as hit 0 is always
// the original matched string\&.
CZMQ_EXPORT int
zrex_fetch (zrex_t *self, const char **string_p, \&.\&.\&.);
// Self test of this class
CZMQ_EXPORT void
zrex_test (bool verbose);
Please add \*(Aq@interface\*(Aq section in \*(Aq\&./\&.\&./src/zrex\&.c\*(Aq\&.
.fi
.SH "DESCRIPTION"
.sp
Wraps a very simple regular expression library (SLRE) as a CZMQ class\&. Supports this syntax:
.sp
.if n \{\
.RS 4
.\}
.nf
^ Match beginning of a buffer
$ Match end of a buffer
() Grouping and substring capturing
[\&.\&.\&.] Match any character from set
[^\&.\&.\&.] Match any character but ones from set
\&. Match any character
\es Match whitespace
\eS Match non\-whitespace
\ed Match decimal digit
\eD Match non decimal digit
\ea Match alphabetic character
\eA Match non\-alphabetic character
\ew Match alphanumeric character
\eW Match non\-alphanumeric character
\er Match carriage return
\en Match newline
+ Match one or more times (greedy)
+? Match one or more times (non\-greedy)
* Match zero or more times (greedy)
*? Match zero or more times (non\-greedy)
? Match zero or once
\exDD Match byte with hex value 0xDD
\emeta Match one of the meta character: ^$()\&.[*+?\e
.fi
.if n \{\
.RE
.\}
.sp
Please add \fI@discuss\fR section in \fI\&./\&.\&./src/zrex\&.c\fR\&.
.SH "EXAMPLE"
.PP
\fBFrom zrex_test method\fR.
.sp
.if n \{\
.RS 4
.\}
.nf
// This shows the pattern of matching many lines to a single pattern
zrex_t *rex = zrex_new ("\e\ed+\-\e\ed+\-\e\ed+");
assert (rex);
assert (zrex_valid (rex));
bool matches = zrex_matches (rex, "123\-456\-789");
assert (matches);
assert (zrex_hits (rex) == 1);
assert (streq (zrex_hit (rex, 0), "123\-456\-789"));
assert (zrex_hit (rex, 1) == NULL);
zrex_destroy (&rex);
// Here we pick out hits using capture groups
rex = zrex_new ("(\e\ed+)\-(\e\ed+)\-(\e\ed+)");
assert (rex);
assert (zrex_valid (rex));
matches = zrex_matches (rex, "123\-456\-ABC");
assert (!matches);
matches = zrex_matches (rex, "123\-456\-789");
assert (matches);
assert (zrex_hits (rex) == 4);
assert (streq (zrex_hit (rex, 0), "123\-456\-789"));
assert (streq (zrex_hit (rex, 1), "123"));
assert (streq (zrex_hit (rex, 2), "456"));
assert (streq (zrex_hit (rex, 3), "789"));
zrex_destroy (&rex);
// This shows the pattern of matching one line against many
// patterns and then handling the case when it hits
rex = zrex_new (NULL); // No initial pattern
assert (rex);
char *input = "Mechanism: CURVE";
matches = zrex_eq (rex, input, "Version: (\&.+)");
assert (!matches);
assert (zrex_hits (rex) == 0);
matches = zrex_eq (rex, input, "Mechanism: (\&.+)");
assert (matches);
assert (zrex_hits (rex) == 2);
const char *mechanism;
zrex_fetch (rex, &mechanism, NULL);
assert (streq (zrex_hit (rex, 1), "CURVE"));
assert (streq (mechanism, "CURVE"));
zrex_destroy (&rex);
.fi
.if n \{\
.RE
.\}
.sp
.SH "AUTHORS"
.sp
The czmq manual was written by the authors in the AUTHORS file\&.
.SH "RESOURCES"
.sp
Main web site: \m[blue]\fB\%\fR\m[]
.sp
Report bugs to the email <\m[blue]\fBzeromq\-dev@lists\&.zeromq\&.org\fR\m[]\&\s-2\u[1]\d\s+2>
.SH "COPYRIGHT"
.sp
Copyright (c) the Contributors as noted in the AUTHORS file\&. This file is part of CZMQ, the high\-level C binding for 0MQ: http://czmq\&.zeromq\&.org\&. This Source Code Form is subject to the terms of the Mozilla Public License, v\&. 2\&.0\&. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla\&.org/MPL/2\&.0/\&. LICENSE included with the czmq distribution\&.
.SH "NOTES"
.IP " 1." 4
zeromq-dev@lists.zeromq.org
.RS 4
\%mailto:zeromq-dev@lists.zeromq.org
.RE