summaryrefslogtreecommitdiff
path: root/src/nodes
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-06-26 19:48:02 +0300
committerAndrei Karas <akaras@inbox.ru>2015-06-26 19:48:45 +0300
commitfec7d220fe6981088659033a3678c93c0b85ee68 (patch)
tree8c4166b7d6939e66fb85e458083b3f20029d988a /src/nodes
parent2850bd01b539f9d64c1c487cf4c899e3b9b7f5a2 (diff)
downloadparanucker-fec7d220fe6981088659033a3678c93c0b85ee68.tar.gz
paranucker-fec7d220fe6981088659033a3678c93c0b85ee68.tar.bz2
paranucker-fec7d220fe6981088659033a3678c93c0b85ee68.tar.xz
paranucker-fec7d220fe6981088659033a3678c93c0b85ee68.zip
Overload compare operators between pointer to Node and tree_code.
Diffstat (limited to 'src/nodes')
-rw-r--r--src/nodes/base/node.cpp30
-rw-r--r--src/nodes/base/node.h4
2 files changed, 34 insertions, 0 deletions
diff --git a/src/nodes/base/node.cpp b/src/nodes/base/node.cpp
new file mode 100644
index 0000000..b26dfb1
--- /dev/null
+++ b/src/nodes/base/node.cpp
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2015 Andrei Karas
+ *
+ * This file is part of AstDumper.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "nodes/base/node.h"
+
+bool operator ==(const Node *const node, const tree_code &code)
+{
+ return node && node->nodeType == code;
+}
+
+bool operator !=(const Node *const node, const tree_code &code)
+{
+ return !node || node->nodeType != code;
+}
diff --git a/src/nodes/base/node.h b/src/nodes/base/node.h
index e8d89ce..83b4314 100644
--- a/src/nodes/base/node.h
+++ b/src/nodes/base/node.h
@@ -80,4 +80,8 @@ struct Node
bool complete;
};
+bool operator ==(const Node *const node, const tree_code &code);
+
+bool operator !=(const Node *const node, const tree_code &code);
+
#endif // NODES_BASE_NODE_H