RX: C++11

This commit is contained in:
Paul Beckingham 2016-02-03 19:26:52 -05:00
parent 073ff9032d
commit 4d2c97f2c3
2 changed files with 11 additions and 17 deletions

View file

@ -26,14 +26,11 @@
#include <cmake.h>
#include <RX.h>
#include <stdlib.h>
#include <string.h>
#include <cstdlib>
#include <cstring>
////////////////////////////////////////////////////////////////////////////////
RX::RX ()
: _compiled (false)
, _pattern ("")
, _case_sensitive (false)
{
}
@ -51,8 +48,8 @@ RX::RX (
////////////////////////////////////////////////////////////////////////////////
RX::RX (const RX& other)
{
_compiled = false;
_pattern = other._pattern;
_compiled = false;
_pattern = other._pattern;
_case_sensitive = other._case_sensitive;
}
@ -66,12 +63,9 @@ RX::~RX ()
////////////////////////////////////////////////////////////////////////////////
RX& RX::operator= (const RX& other)
{
if (this != &other)
{
_compiled = false;
_pattern = other._pattern;
_case_sensitive = other._case_sensitive;
}
_compiled = false;
_pattern = other._pattern;
_case_sensitive = other._case_sensitive;
return *this;
}
@ -107,7 +101,7 @@ bool RX::match (const std::string& in)
if (! _compiled)
compile ();
return regexec (&_regex, in.c_str (), 0, NULL, 0) == 0 ? true : false;
return regexec (&_regex, in.c_str (), 0, nullptr, 0) == 0 ? true : false;
}
////////////////////////////////////////////////////////////////////////////////

View file

@ -48,9 +48,9 @@ private:
void compile ();
private:
bool _compiled;
std::string _pattern;
bool _case_sensitive;
bool _compiled {false};
std::string _pattern {};
bool _case_sensitive {false};
regex_t _regex;
};