OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
regexp.h
Go to the documentation of this file.
1/*------------------------------------------------------------------------*/
2/* */
3/* REGEXP.H */
4/* */
5/*------------------------------------------------------------------------*/
6
7/*
8 * C/C++ Run Time Library - Version 7.0
9 *
10 * Copyright (c) 1987, 1996 by Borland International
11 * All Rights Reserved.
12 *
13 */
14
15
16#ifndef __cplusplus
17#error Must use C++ for REGEXP.H
18#endif
19
20#ifndef __REGEXP_H
21#define __REGEXP_H
22
23#include <owl/defs.h>
24#if defined(BI_HAS_PRAGMA_ONCE)
25# pragma once
26#endif
27
28namespace owl {
29
30#include <owl/preclass.h>
31
32
33/// \class TRegexp
34//
35/// This class represents regular expressions. TRegexp is a support class used by
36/// the string class for string searches.
37/// Regular expressions use these special characters:
38/// \code
39/// . [ ] - ^ * ? + $
40/// \endcode
41///
42/// General Rules
43///
44/// Characters other than the special characters match themselves. For example
45/// "yardbird" matches "yardbird".
46/// A backslash (\\‍) followed by a special character, matches the special character
47/// itself. For example "Pardon\\?" matches "Pardon?".
48/// The following escape codes can be used to match control characters:
49/// \code
50/// \b backspace
51/// \e Esc
52/// \f formfeed
53/// \n newline
54/// \r carriage return
55/// \t tab
56/// \xddd the literal hex number 0xddd
57/// \^x where x matches some control-code (for example \^c, \^c)
58/// \endcode
59///
60/// One-Character Regular Expressions
61/// - The . special character matches any single character except a newline character.
62/// For example ".ive" would match "jive" or "five".
63/// - The [ and ] special characters are used to denote one-character regular
64/// expressions that will match any of the characters within the brackets. For
65/// example, "[aeiou]" would match either "a", "e", "i", "o", or "u".
66/// - The - special character is used within the [ ] special characters to denote a
67/// range of characters to match. For example, "[ a-z ]" would match on any
68/// lowercase alphabetic character between a and z.
69/// - The ^ special character is used to specify search for any character but those
70/// specified. For example, "[ ^g-v ]" would match on any lowercase alphabetic
71/// character NOT between g and v.
72///
73/// Multiple-Character Regular Expressions
74/// - The * special character following a one-character regular expression matches
75/// zero or more occurrences of that regular expression. For example, "[ a-z ]*"
76/// matches zero or more occurrences of lowercase alphabetic characters.
77/// - The + special character following a one-character regular expression matches one
78/// or more occurrences of that regular expression. For example, "[ 0-9 ]+" matches
79/// one or more occurrences of lowercase alphabetic characters.
80/// - The ? special character specifies that the following character is optional. For
81/// example "xy?z" matches on "xy" or "xyz".
82///
83/// Regular expressions can be concatentated. For example, "[ A-Z ][ a-z ]*" matches
84/// capitalized words.
85///
86/// Matching at the Beginning and End of a Line
87/// If the ^ special character is at the beginning of a regular expression, then a
88/// match occurs only if the string is at the beginning of a line. For example, "^[
89/// A-Z ][ a-z ]*" matches capitalized words at the beginning of a line.
90/// If the $ special character is at the end of a regular expression, the then a
91/// match occurs only if the string is at the end of a line. For example, "[ A-Z ][
92/// a-z ]*$" matches capitalized words at the end of a line.
93
95 public:
96/// StatVal enumerates the status conditions returned by TRegexp::status
97 enum StatVal {
98 OK=0, ///< Means the given regular expression is legal
99 ILLEGAL, ///< Means the pattern was illegal
101 TOOLONG ///< Means the pattern exceeded maximum length (128)
102 };
103
104 TRegexp( const tchar *cp );
105 TRegexp( const TRegexp &r );
106 ~TRegexp();
107
108 TRegexp & operator = ( const TRegexp &r );
109 TRegexp & operator = ( const tchar *cp );
110 size_t find( const tstring &s,
111 size_t *len,
112 size_t start = 0 ) const;
113 StatVal status() noexcept;
114
115private:
116
117 void copy_pattern( const TRegexp &r );
118 void gen_pattern( const tchar *cp );
119
120 _TUCHAR *the_pattern;
121 StatVal stat;
122 static const unsigned maxpat;
123};
124
125#include <owl/posclass.h>
126
127} // OWL namespace
128
129#endif /* __REGEXP_H */
This class represents regular expressions.
Definition regexp.h:94
StatVal
StatVal enumerates the status conditions returned by TRegexp::status.
Definition regexp.h:97
@ ILLEGAL
Means the pattern was illegal.
Definition regexp.h:99
unsigned char _TUCHAR
Definition cygwin.h:44
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
char tchar
Definition defs.h:77
std::string tstring
Definition defs.h:79
General definitions used by all ObjectWindows programs.
#define _OWLCLASS
Definition defs.h:338