minor fixes

This commit is contained in:
fluxgen 2003-06-13 11:43:46 +00:00
parent 6add92330b
commit cb14466431
2 changed files with 19 additions and 11 deletions

View file

@ -20,7 +20,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: RegExp.cc,v 1.1 2003/06/12 15:12:19 rathnor Exp $ // $Id: RegExp.cc,v 1.2 2003/06/13 11:43:46 fluxgen Exp $
#include "RegExp.hh" #include "RegExp.hh"
@ -81,10 +81,10 @@ RegExp::~RegExp() {
#endif // USE_REGEXP #endif // USE_REGEXP
} }
bool RegExp::match(const std::string &str) { bool RegExp::match(const std::string &str) const {
#ifdef USE_REGEXP #ifdef USE_REGEXP
if (m_regex) if (m_regex)
return (regexec(m_regex, str.c_str(), 0, 0, 0) == 0); return regexec(m_regex, str.c_str(), 0, 0, 0) == 0;
else else
return false; return false;
#else // notdef USE_REGEXP #else // notdef USE_REGEXP
@ -92,3 +92,11 @@ bool RegExp::match(const std::string &str) {
#endif // USE_REGEXP #endif // USE_REGEXP
} }
bool RegExp::error() const {
#ifdef USE_REGEXP
return m_regex == 0;
#else
return return m_str == "";
#endif // USE_REGEXP
}

View file

@ -21,12 +21,16 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// $Id: RegExp.hh,v 1.1 2003/06/12 15:12:19 rathnor Exp $ // $Id: RegExp.hh,v 1.2 2003/06/13 11:43:46 fluxgen Exp $
#ifndef REGEXP_HH #ifndef REGEXP_HH
#define REGEXP_HH #define REGEXP_HH
#include "NotCopyable.hh"
#ifdef HAVE_CONFIG_H
#include "config.h" #include "config.h"
#endif // HAVE_CONFIG_H
#include <string> #include <string>
@ -41,18 +45,14 @@
class WinClient; class WinClient;
class RegExp { class RegExp:private FbTk::NotCopyable {
public: public:
RegExp(const std::string &str, bool full_match = true); RegExp(const std::string &str, bool full_match = true);
~RegExp(); ~RegExp();
bool match(const std::string &str); bool match(const std::string &str) const;
#ifdef USE_REGEXP bool error() const;
inline bool error() { return m_regex == 0; }
#else // notdef USE_REGEXP
inline bool error() { return m_str == ""; }
#endif // USE_REGEXP
private: private:
#ifdef USE_REGEXP #ifdef USE_REGEXP