summaryrefslogtreecommitdiff
path: root/src/base/match.hh
diff options
context:
space:
mode:
authorBobby R. Bruce <bbruce@ucdavis.edu>2019-11-01 12:44:08 -0700
committerBobby R. Bruce <bbruce@ucdavis.edu>2019-11-07 18:34:01 +0000
commit434047e2c3200b6b249c206fb2a4a306225b473e (patch)
treefe6915415462000ddf3c93f2cd767a4308aba7ba /src/base/match.hh
parentf41045ef75a391286c32069c8474fb2a0cc66f72 (diff)
downloadgem5-434047e2c3200b6b249c206fb2a4a306225b473e.tar.xz
tests,base: Added GTests for base/match.cc
In order to aid testing the method "match.getExpressions()" has been added. Change-Id: I11acf9bed286ee2809dfa3d05ef573dea85eb786 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22503 Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Jason Lowe-Power <jason@lowepower.com> Tested-by: kokoro <noreply+kokoro@google.com>
Diffstat (limited to 'src/base/match.hh')
-rw-r--r--src/base/match.hh16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/base/match.hh b/src/base/match.hh
index 3ef4c8192..7f610236d 100644
--- a/src/base/match.hh
+++ b/src/base/match.hh
@@ -1,4 +1,5 @@
/*
+ * Copyright (c) 2019 The Regents of the University of California
* Copyright (c) 2004-2005 The Regents of The University of Michigan
* All rights reserved.
*
@@ -26,6 +27,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Authors: Nathan Binkert
+ Bobby R. Bruce
*/
/* @file
@@ -38,6 +40,19 @@
#include <string>
#include <vector>
+/**
+ * ObjectMatch contains a vector of expressions. ObjectMatch can then be
+ * queried, via ObjectMatch.match(std::string), to check if a string matches
+ * any expressions in the vector.
+ *
+ * Expressions in ObjectMatch take the form "<token1>.<token2>.<token3>"; a
+ * series of expected tokens separated by a period. The input string takes the
+ * form "<value1>.<value2>.<value3>". In this case, the input string matches
+ * the expression if <value1> == <token1> && <token2> == <value2>
+ * && <value3> == <token3>. A token may be a wildcard character, "*", which
+ * will match to any value in that position (inclusive of no value at that
+ * location).
+ */
class ObjectMatch
{
protected:
@@ -50,6 +65,7 @@ class ObjectMatch
void add(const ObjectMatch &other);
void setExpression(const std::string &expression);
void setExpression(const std::vector<std::string> &expression);
+ std::vector<std::vector<std::string> > getExpressions();
bool match(const std::string &name) const
{
return tokens.empty() ? false : domatch(name);