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::statement {
12 
13 namespace comment {
14 enum class Separator { After, BeforeAndAfter, Before };
15 } // namespace comment
16 
18 class Comment : public NodeBase, public hilti::trait::isStatement {
19 public:
20  Comment(std::string comment, comment::Separator separator = comment::Separator::Before,
21  const Meta& /* m */ = Meta())
22  : _comment(std::move(comment)), _separator(separator) {}
23 
24  auto comment() const { return _comment; }
25  auto separator() const { return _separator; }
26 
27  bool operator==(const Comment& other) const { return comment() == other.comment(); }
28 
30  auto isEqual(const Statement& other) const { return node::isEqual(this, other); }
31 
33  auto properties() const { return node::Properties{{"comment", _comment}}; }
34 
35 private:
36  std::string _comment;
37  comment::Separator _separator;
38 };
39 
40 } // namespace hilti::statement
Definition: comment.h:18
auto isEqual(const Statement &other) const
Definition: comment.h:30
Definition: meta.h:19
Definition: statement.h:14
auto properties() const
Definition: comment.h:33
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:98
Definition: node.h:360