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 <cmake.h>
#include <RX.h> #include <RX.h>
#include <stdlib.h> #include <cstdlib>
#include <string.h> #include <cstring>
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
RX::RX () RX::RX ()
: _compiled (false)
, _pattern ("")
, _case_sensitive (false)
{ {
} }
@@ -51,8 +48,8 @@ RX::RX (
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
RX::RX (const RX& other) RX::RX (const RX& other)
{ {
_compiled = false; _compiled = false;
_pattern = other._pattern; _pattern = other._pattern;
_case_sensitive = other._case_sensitive; _case_sensitive = other._case_sensitive;
} }
@@ -66,12 +63,9 @@ RX::~RX ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
RX& RX::operator= (const RX& other) RX& RX::operator= (const RX& other)
{ {
if (this != &other) _compiled = false;
{ _pattern = other._pattern;
_compiled = false; _case_sensitive = other._case_sensitive;
_pattern = other._pattern;
_case_sensitive = other._case_sensitive;
}
return *this; return *this;
} }
@@ -107,7 +101,7 @@ bool RX::match (const std::string& in)
if (! _compiled) if (! _compiled)
compile (); 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 (); void compile ();
private: private:
bool _compiled; bool _compiled {false};
std::string _pattern; std::string _pattern {};
bool _case_sensitive; bool _case_sensitive {false};
regex_t _regex; regex_t _regex;
}; };