// -*- Mode: C++; tab-width: 2; -*-
// vi: set ts=2:
//
// $Id: regularExpression.iC,v 1.2 2003/08/26 08:04:11 oliver Exp $
//

BALL_INLINE 
void RegularExpression::set(const RegularExpression& regular_expression)
{
	pattern_.set(regular_expression.pattern_);
	regfree(&regex_);
	compilePattern_();
}

BALL_INLINE 
void RegularExpression::set(const String& pattern, bool wildcard_pattern)
{
  pattern_.set(pattern);

  if (wildcard_pattern == true)
	{
    toExtendedRegularExpression_();
	}
	regfree(&regex_);
	compilePattern_();
}

BALL_INLINE 
RegularExpression& RegularExpression::operator = (const RegularExpression& expression) 
{
	this->set(expression);
	return (*this);
}


BALL_INLINE 
void RegularExpression::get(RegularExpression& regular_expression) const
{
  regular_expression.set(*this);
}

BALL_INLINE 
const String& RegularExpression::getPattern() const
{
  return pattern_;
}

BALL_INLINE 
Size RegularExpression::countSubexpressions() const
{
  if (valid_pattern_ == true)
  {
    return (Size)regex_.re_nsub;
  }

  return 0;
}

BALL_INLINE 
void RegularExpression::clear()
{
  set(BALL_REGULAR_EXPRESSION_DEFAULT_PATTERN);
}

BALL_INLINE 
void RegularExpression::destroy()
{
  clear();
}

BALL_INLINE
bool RegularExpression::isEmpty() const
{
  return pattern_.isEmpty();
}

BALL_INLINE 
bool RegularExpression::operator == (const RegularExpression& regular_expression) const
{
  return (pattern_ == regular_expression.pattern_);
}

BALL_INLINE 
bool RegularExpression::operator != (const RegularExpression& regular_expression) const
{
  return (pattern_ != regular_expression.pattern_);
}

BALL_INLINE 
bool RegularExpression::operator < (const RegularExpression& regular_expression) const
{
  return (pattern_ < regular_expression.pattern_);
}

BALL_INLINE 
bool RegularExpression::operator <= (const RegularExpression& regular_expression) const
{
  return (pattern_ <= regular_expression.pattern_);
}

BALL_INLINE 
bool RegularExpression::operator >= (const RegularExpression& regular_expression) const
{
  return (pattern_ >= regular_expression.pattern_);
}

BALL_INLINE 
bool RegularExpression::operator > (const RegularExpression& regular_expression) const
{
  return (pattern_ > regular_expression.pattern_);
}

BALL_INLINE 
bool RegularExpression::isValid() const
{
  return (valid_pattern_ == true && pattern_.isValid());
}
