cmatchexpression.h Source File

API: cmatchexpression.h Source File
API
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#include "cobject.h" // noncopyable
22
23namespace omnetpp {
24
25namespace common { class MatchExpression; };
26
27
55class SIM_API cMatchExpression : public noncopyable
56{
57 public:
62 class SIM_API Matchable
63 {
64 public:
69 virtual const char *getAsString() const = 0;
70
76 virtual const char *getAsString(const char *attribute) const = 0;
77
81 virtual ~Matchable() {}
82 };
83
84 private:
85 omnetpp::common::MatchExpression *impl;
86
87 public:
92
96 cMatchExpression(const char *pattern, bool dottedpath, bool fullstring, bool casesensitive);
97
101 cMatchExpression(cMatchExpression&& other) : impl(other.impl) {other.impl = nullptr;}
102
107
113 void setPattern(const char *pattern, bool dottedpath, bool fullstring, bool casesensitive);
114
119 bool matches(const Matchable *object) const;
120};
121
122
127class SIM_API cMatchableString : public cMatchExpression::Matchable
128{
129 private:
130 std::string str;
131 public:
132 cMatchableString(const char *s) {str = s;}
133 virtual const char *getAsString() const override {return str.c_str();}
134 virtual const char *getAsString(const char *attribute) const override {return nullptr;}
135};
136
137} // namespace omnetpp
138
139
140#endif
141
142
Objects to be matched must implement this interface.
Definition cmatchexpression.h:63
virtual const char * getAsString() const =0
virtual ~Matchable()
Definition cmatchexpression.h:81
virtual const char * getAsString(const char *attribute) const =0
cMatchExpression(cMatchExpression &&other)
Definition cmatchexpression.h:101
bool matches(const Matchable *object) const
void setPattern(const char *pattern, bool dottedpath, bool fullstring, bool casesensitive)
cMatchExpression(const char *pattern, bool dottedpath, bool fullstring, bool casesensitive)
virtual const char * getAsString() const override
Definition cmatchexpression.h:133
virtual const char * getAsString(const char *attribute) const override
Definition cmatchexpression.h:134