GiNaC  1.8.0
wildcard.h
Go to the documentation of this file.
1 
5 /*
6  * GiNaC Copyright (C) 1999-2020 Johannes Gutenberg University Mainz, Germany
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 #ifndef GINAC_WILDCARD_H
24 #define GINAC_WILDCARD_H
25 
26 #include "ex.h"
27 #include "archive.h"
28 
29 namespace GiNaC {
30 
33 class wildcard : public basic
34 {
36 
37  // other constructors
38 public:
40  wildcard(unsigned label);
41 
42  // functions overriding virtual functions from base classes
43 public:
44  bool match(const ex & pattern, exmap& repl_lst) const override;
45 
47  void archive(archive_node& n) const override;
49  void read_archive(const archive_node& n, lst& syms) override;
50 protected:
51  unsigned calchash() const override;
52 
53  // non-virtual functions in this class
54 public:
55  unsigned get_label() const {return label;}
56 
57 protected:
58  void do_print(const print_context & c, unsigned level) const;
59  void do_print_tree(const print_tree & c, unsigned level) const;
60  void do_print_python_repr(const print_python_repr & c, unsigned level) const;
61 
62  // member variables
63 private:
64  unsigned label;
65 };
67 
68 
69 // utility functions
70 
72 inline ex wild(unsigned label = 0)
73 {
74  return wildcard(label);
75 }
76 
78 bool haswild(const ex & x);
79 
80 } // namespace GiNaC
81 
82 #endif // ndef GINAC_WILDCARD_H
exset syms
Definition: factor.cpp:2434
wildcard(unsigned label)
Construct wildcard with specified label.
Definition: wildcard.cpp:50
void read_archive(const archive_node &n, lst &syms) override
Read (a.k.a.
Definition: wildcard.cpp:59
This class acts as a wildcard for subs(), match(), has() and find().
Definition: wildcard.h:33
Definition: add.cpp:38
unsigned calchash() const override
Compute the hash value of an object and if it makes sense to store it in the objects status_flags...
Definition: wildcard.cpp:105
Archiving of GiNaC expressions.
void do_print_python_repr(const print_python_repr &c, unsigned level) const
Definition: wildcard.cpp:100
This class is the ABC (abstract base class) of GiNaC's class hierarchy.
Definition: basic.h:104
Context for python-parsable output.
Definition: print.h:138
void archive(archive_node &n) const override
Save (a.k.a.
Definition: wildcard.cpp:67
ex x
Definition: factor.cpp:1641
void do_print(const print_context &c, unsigned level) const
Definition: wildcard.cpp:88
void do_print_tree(const print_tree &c, unsigned level) const
Definition: wildcard.cpp:93
bool haswild(const ex &x)
Check whether x has a wildcard anywhere as a subexpression.
Definition: wildcard.cpp:124
unsigned get_label() const
Definition: wildcard.h:55
unsigned label
Label used to distinguish different wildcards.
Definition: wildcard.h:64
std::map< ex, ex, ex_is_less > exmap
Definition: basic.h:50
size_t n
Definition: factor.cpp:1463
Interface to GiNaC&#39;s light-weight expression handles.
Base class for print_contexts.
Definition: print.h:102
ex wild(unsigned label=0)
Create a wildcard object with the specified label.
Definition: wildcard.h:72
This class stores all properties needed to record/retrieve the state of one object of class basic (or...
Definition: archive.h:48
Lightweight wrapper for GiNaC&#39;s symbolic objects.
Definition: ex.h:72
Wrapper template for making GiNaC classes out of STL containers.
Definition: container.h:73
#define GINAC_DECLARE_REGISTERED_CLASS(classname, supername)
Macro for inclusion in the declaration of each registered class.
Definition: registrar.h:153
bool match(const ex &pattern, exmap &repl_lst) const override
Check whether the expression matches a given pattern.
Definition: wildcard.cpp:116
GINAC_DECLARE_UNARCHIVER(add)
size_t c
Definition: factor.cpp:770
Context for tree-like output for debugging.
Definition: print.h:146

This page is part of the GiNaC developer's reference. It was generated automatically by doxygen. For an introduction, see the tutorial.