tests,base: Added GTests for base/match.cc
[gem5.git] / src / base / match.hh
index 6e1f03b80425426d1e3cb96b06591b20b707772f..7f610236d2d6bd8feb54f8cb2e16b775bc41053f 100644 (file)
@@ -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
 #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:
@@ -47,8 +62,10 @@ class ObjectMatch
   public:
     ObjectMatch();
     ObjectMatch(const std::string &expression);
+    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);