OpendTect  6.6
globexpr.h
Go to the documentation of this file.
1 #pragma once
2 
3 /*
4 ________________________________________________________________________
5 
6  (C) dGB Beheer B.V.; (LICENSE) http://opendtect.org/OpendTect_license.txt
7  Author: A.H. Bril
8  Date: 15-1-2001
9  RCS: $Id$
10 ________________________________________________________________________
11 
12 */
13 
14 #include "basicmod.h"
15 #include "bufstring.h"
16 
26 {
27 public:
28 
29  GlobExpr( const char* s=nullptr, bool casesens=true )
30  : expr_(""), errmsg_(nullptr), ci_(!casesens)
31  { set(s); }
32  GlobExpr( const GlobExpr& ge )
33  : expr_(ge.expr_), errmsg_(nullptr), ci_(ge.ci_) {}
34  GlobExpr& operator=( const GlobExpr& ge )
35  {
36  expr_ = ge.expr_;
37  errmsg_ = nullptr;
38  ci_ = ge.ci_;
39  return *this;
40  }
41  bool operator==( const GlobExpr& ge ) const
42  {
43  return expr_ == ge.expr_ && ci_ == ge.ci_;
44  }
45 
46  void setCaseInSensitive( bool yn=true ) { ci_ = yn; }
47 
48  void set(const char*);
49  inline operator const char*() const
50  { return expr_; }
51 
52  inline bool matches( const char* t ) const
53  { return matches( expr_, t,
54  const_cast<const char*&>(errmsg_), ci_ ); }
55  const char* expressionFailMessage() const { return errmsg_; }
57 
58  static bool matches(const char* expression,const char* txt,
59  const char*& errmsg_if_expression_is_incorrect,
60  bool caseinsens);
61 
62 protected:
63 
65  const char* errmsg_;
66  bool ci_;
67 
68  static bool starMatches(const char*,const char*,const char*&,bool);
69 };
70 
71 
GlobExpr::GlobExpr
GlobExpr(const char *s=nullptr, bool casesens=true)
Definition: globexpr.h:29
GlobExpr::starMatches
static bool starMatches(const char *, const char *, const char *&, bool)
GlobExpr
Glob-expression matching like UNIX shells.
Definition: globexpr.h:26
mExpClass
#define mExpClass(module)
Definition: commondefs.h:177
bufstring.h
GlobExpr::operator=
GlobExpr & operator=(const GlobExpr &ge)
Definition: globexpr.h:34
GlobExpr::expressionFailMessage
const char * expressionFailMessage() const
Normally null, only filled if invalid expression.
Definition: globexpr.h:55
GlobExpr::matches
bool matches(const char *t) const
Definition: globexpr.h:52
GlobExpr::matches
static bool matches(const char *expression, const char *txt, const char *&errmsg_if_expression_is_incorrect, bool caseinsens)
GlobExpr::GlobExpr
GlobExpr(const GlobExpr &ge)
Definition: globexpr.h:32
GlobExpr::set
void set(const char *)
GlobExpr::expr_
BufferString expr_
Definition: globexpr.h:64
Conv::set
void set(T &_to, const F &fr)
template based type conversion
Definition: convert.h:27
BufferString
OD::String with its own variable length buffer. The buffer has a guaranteed minimum size.
Definition: bufstring.h:40
GlobExpr::operator==
bool operator==(const GlobExpr &ge) const
Definition: globexpr.h:41
MPE::errmsg_
BufferString errmsg_
Definition: horizontracker.h:118
GlobExpr::ci_
bool ci_
Definition: globexpr.h:66
GlobExpr::errmsg_
const char * errmsg_
Definition: globexpr.h:65
GlobExpr::setCaseInSensitive
void setCaseInSensitive(bool yn=true)
Definition: globexpr.h:46

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B.V. 1995-2021