OMNeT++ Simulation Library  5.6.1
cmatchexpression.h
1 //==========================================================================
2 // CMATCHEXPRESSION.H - part of
3 // OMNeT++/OMNEST
4 // Discrete System Simulation in C++
5 //
6 //==========================================================================
7 
8 /*--------------------------------------------------------------*
9  Copyright (C) 2006-2017 OpenSim Ltd.
10 
11  This file is distributed WITHOUT ANY WARRANTY. See the file
12  `license' for details on this and other legal matters.
13 *--------------------------------------------------------------*/
14 
15 
16 #ifndef __OMNETPP_CMATCHEXPRESSION_H
17 #define __OMNETPP_CMATCHEXPRESSION_H
18 
19 #include <string>
20 #include "simkerneldefs.h"
21 
22 namespace omnetpp {
23 
24 namespace common { class MatchExpression; };
25 
26 
57 class SIM_API cMatchExpression
58 {
59  public:
64  class SIM_API Matchable
65  {
66  public:
71  virtual const char *getAsString() const = 0;
72 
78  virtual const char *getAsString(const char *attribute) const = 0;
79 
83  virtual ~Matchable() {}
84  };
85 
86  private:
87  omnetpp::common::MatchExpression *impl;
88 
89  public:
94 
98  cMatchExpression(const char *pattern, bool dottedpath, bool fullstring, bool casesensitive);
99 
103  ~cMatchExpression();
104 
110  void setPattern(const char *pattern, bool dottedpath, bool fullstring, bool casesensitive);
111 
116  bool matches(const Matchable *object);
117 };
118 
119 
125 {
126  private:
127  std::string str;
128  public:
129  cMatchableString(const char *s) {str = s;}
130  virtual const char *getAsString() const override {return str.c_str();}
131  virtual const char *getAsString(const char *attribute) const override {return nullptr;}
132 };
133 
134 } // namespace omnetpp
135 
136 
137 #endif
138 
139 
Objects to be matched must implement this interface.
Definition: cmatchexpression.h:64
virtual ~Matchable()
Definition: cmatchexpression.h:83
virtual const char * getAsString(const char *attribute) const override
Definition: cmatchexpression.h:131
virtual const char * getAsString() const override
Definition: cmatchexpression.h:130
Wrapper to make a string matchable with cMatchExpression.
Definition: cmatchexpression.h:124
Definition: cabstracthistogram.h:21
Decides whether an object matches an expression.
Definition: cmatchexpression.h:57