Loading...
Searching...
No Matches
regularExpression.h
Go to the documentation of this file.
// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
#ifndef BALL_DATATYPE_REGULAREXPRESSION_H
#define BALL_DATATYPE_REGULAREXPRESSION_H
#ifndef BALL_COMMON_H
# include <BALL/common.h>
#endif
#include <boost/regex.h>
#if !defined(__GNUC__) && !defined(__KAI__) && defined(IRIX)
# pragma reset woff 1174
#endif
#ifndef BALL_DATATYPE_STRING_H
# include <BALL/DATATYPE/string.h>
#endif
#define BALL_REGULAR_EXPRESSION_DEFAULT_PATTERN ""
namespace BALL
{
class BALL_EXPORT RegularExpression
{
public:
BALL_CREATE(RegularExpression)
static const String ALPHA;
static const String ALPHANUMERIC;
static const String REAL;
static const String IDENTIFIER;
static const String INTEGER;
static const String HEXADECIMAL_INTEGER;
static const String LOWERCASE;
static const String NON_ALPHA;
static const String NON_ALPHANUMERIC;
static const String NON_NUMERIC;
static const String NON_WHITESPACE;
static const String UPPERCASE;
static const String WHITESPACE;
RegularExpression();
RegularExpression(const RegularExpression& regular_expression);
RegularExpression(const String& pattern, bool wildcard_pattern = false);
virtual ~RegularExpression();
virtual void clear();
void destroy();
RegularExpression& operator = (const RegularExpression& expression);
void set(const RegularExpression& regular_expression);
void set(const String& pattern, bool wildcard_pattern = false);
void get(RegularExpression& regular_expression) const;
const String& getPattern() const;
Size countSubexpressions() const;
static bool match(const char* text, const char* pattern,
int compile_flags = 0 | REG_EXTENDED | REG_NOSUB, int execute_flags = 0);
bool match(const String& text, Index from = 0, int execute_flags = 0) const;
bool match(const Substring& text, Index from = 0, int execute_flags = 0) const;
bool match(const char* text, int execute_flags = 0) const;
bool find(const String& text, Substring& found,
Index from = 0, int execute_flags = 0) const;
bool find(const String& text, vector<Substring>& subexpressions,
Index from = 0, int execute_flags = 0) const;
bool isEmpty() const;
bool operator == (const RegularExpression& regular_expression) const;
bool operator != (const RegularExpression& regular_expression) const;
bool operator < (const RegularExpression& regular_expression) const;
bool operator <= (const RegularExpression& regular_expression) const;
bool operator >= (const RegularExpression& regular_expression) const;
bool operator > (const RegularExpression& regular_expression) const;
virtual bool isValid() const;
virtual void dump(std::ostream& s = std::cout, Size depth = 0) const;
BALL_EXPORT
friend std::ostream& operator << (std::ostream& s, const RegularExpression& regular_expression);
BALL_EXPORT
friend std::istream& operator >> (std::istream& s, RegularExpression& regular_expression);
private:
void compilePattern_();
void toExtendedRegularExpression_();
regex_t regex_;
String pattern_;
bool valid_pattern_;
};
# ifndef BALL_NO_INLINE_FUNCTIONS
# include <BALL/DATATYPE/regularExpression.iC>
# endif
} // namespace BALL
#endif // BALL_DATATYPE_REGULAREXPRESSION_H
BALL_EXPORT
#define BALL_EXPORT
Definition COMMON/global.h:50
BALL::RegularExpression::set
void set(const RegularExpression &regular_expression)
Assign from another instance.
BALL::RegularExpression::NON_NUMERIC
static const String NON_NUMERIC
Definition regularExpression.h:77
BALL::RegularExpression::getPattern
const String & getPattern() const
Get the expression pattern.
BALL::RegularExpression::match
static bool match(const char *text, const char *pattern, int compile_flags=0|REG_EXTENDED|REG_NOSUB, int execute_flags=0)
BALL::RegularExpression::clear
virtual void clear()
Reset the object attributes to their default values.
BALL::RegularExpression::INTEGER
static const String INTEGER
Definition regularExpression.h:57
BALL::RegularExpression::UPPERCASE
static const String UPPERCASE
Definition regularExpression.h:85
BALL::RegularExpression::HEXADECIMAL_INTEGER
static const String HEXADECIMAL_INTEGER
Definition regularExpression.h:61
BALL::RegularExpression::ALPHANUMERIC
static const String ALPHANUMERIC
Definition regularExpression.h:45
BALL::RegularExpression::NON_ALPHANUMERIC
static const String NON_ALPHANUMERIC
Definition regularExpression.h:73
BALL::RegularExpression::RegularExpression
RegularExpression()
Default constructor.
BALL::RegularExpression::dump
virtual void dump(std::ostream &s=std::cout, Size depth=0) const
BALL::RegularExpression::WHITESPACE
static const String WHITESPACE
Definition regularExpression.h:89
BALL::RegularExpression::get
void get(RegularExpression &regular_expression) const
Assign to another instance.
BALL::RegularExpression::ALPHA
static const String ALPHA
Definition regularExpression.h:41
BALL::RegularExpression::countSubexpressions
Size countSubexpressions() const
Count subexpressions.
BALL::RegularExpression::NON_ALPHA
static const String NON_ALPHA
Definition regularExpression.h:69
BALL::RegularExpression::isValid
virtual bool isValid() const
BALL::RegularExpression::LOWERCASE
static const String LOWERCASE
Definition regularExpression.h:65
BALL::RegularExpression::IDENTIFIER
static const String IDENTIFIER
Definition regularExpression.h:53
BALL::RegularExpression::isEmpty
bool isEmpty() const
BALL::RegularExpression::NON_WHITESPACE
static const String NON_WHITESPACE
Definition regularExpression.h:81
BALL::RegularExpression::destroy
void destroy()
Destroy the instance.
BALL::RegularExpression::REAL
static const String REAL
Definition regularExpression.h:49
BALL::RegularExpression::find
bool find(const String &text, Substring &found, Index from=0, int execute_flags=0) const
BALL::String
Definition string.h:57
BALL::Substring
Definition string.h:1386
common.h
BALL_CREATE
#define BALL_CREATE(name)
Definition create.h:62
BALL
Definition constants.h:13
BALL::Size
BALL_SIZE_TYPE Size
Definition COMMON/global.h:114
BALL::Index
BALL_INDEX_TYPE Index
Definition COMMON/global.h:105
std
STL namespace.
string.h