Spicy
comment.h
1 // Copyright (c) 2020-2021 by the Zeek Project. See LICENSE for details.
2 
3 #pragma once
4 
5 #include <string>
6 #include <utility>
7 
8 #include <hilti/ast/expression.h>
9 #include <hilti/ast/statement.h>
10 
11 namespace hilti {
12 namespace statement {
13 
14 namespace comment {
15 enum class Separator { After, BeforeAndAfter, Before };
16 } // namespace comment
17 
19 class Comment : public NodeBase, public hilti::trait::isStatement {
20 public:
21  Comment(std::string comment, comment::Separator separator = comment::Separator::Before,
22  const Meta& /* m */ = Meta())
23  : _comment(std::move(comment)), _separator(separator) {}
24 
25  auto comment() const { return _comment; }
26  auto separator() const { return _separator; }
27 
28  bool operator==(const Comment& other) const { return comment() == other.comment(); }
29 
31  auto isEqual(const Statement& other) const { return node::isEqual(this, other); }
32 
34  auto properties() const { return node::Properties{{"comment", _comment}}; }
35 
36 private:
37  std::string _comment;
38  comment::Separator _separator;
39 };
40 
41 } // namespace statement
42 } // namespace hilti
Definition: comment.h:19
auto isEqual(const Statement &other) const
Definition: comment.h:31
Definition: meta.h:18
Definition: statement.h:14
auto properties() const
Definition: comment.h:34
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:83
Definition: node.h:318