Spicy
stream.h
1 // Copyright (c) 2020-2021 by the Zeek Project. See LICENSE for details.
2 
3 #pragma once
4 
5 #include <utility>
6 
7 #include <hilti/ast/type.h>
8 #include <hilti/ast/types/integer.h>
9 
10 namespace hilti {
11 namespace type {
12 
13 namespace stream {
14 
16 class Iterator : public TypeBase,
22 public:
23  Iterator(Meta m = Meta()) : TypeBase(std::move(m)) {}
24 
25  bool operator==(const Iterator& /* other */) const { return true; }
26 
28  auto isEqual(const Type& other) const { return node::isEqual(this, other); }
30  Type dereferencedType() const;
32  auto properties() const { return node::Properties{}; }
33 };
34 
37 public:
38  View(Meta m = Meta());
39 
40  bool operator==(const View& /* other */) const { return true; }
41 
43  auto isEqual(const Type& other) const { return node::isEqual(this, other); }
45  Type elementType() const { return type::UnsignedInteger(8); }
47  Type iteratorType(bool /* const_ */) const { return stream::Iterator(meta()); }
49  auto properties() const { return node::Properties{}; }
50 };
51 
52 } // namespace stream
53 
55 class Stream : public TypeBase,
61 public:
62  Stream(Meta m = Meta()) : TypeBase(std::move(m)) {}
63 
64  bool operator==(const Stream& /* other */) const { return true; }
65 
67  auto isEqual(const Type& other) const { return node::isEqual(this, other); }
69  Type elementType() const { return type::UnsignedInteger(8); }
70 
72  Type iteratorType(bool /* const_ */) const { return stream::Iterator(meta()); }
74  Type viewType() const { return stream::View(meta()); }
76  auto properties() const { return node::Properties{}; }
77 
78 private:
79  std::optional<Node> _etype;
80 };
81 
82 namespace detail::stream {
83 inline Node element_type = Node(type::UnsignedInteger(8, Location()));
84 } // namespace detail::stream
85 
87 inline stream::View::View(Meta m) : TypeBase({type::Stream()}, std::move(m)) {}
88 
89 } // namespace type
90 
91 } // namespace hilti
auto isEqual(const Type &other) const
Definition: stream.h:43
auto properties() const
Definition: stream.h:76
Definition: type.h:26
auto isEqual(const Type &other) const
Definition: stream.h:28
Definition: stream.h:55
Definition: type.h:27
Definition: meta.h:18
Definition: integer.h:53
Definition: type.h:32
Definition: stream.h:16
Definition: type.h:25
Type iteratorType(bool) const
Definition: stream.h:72
auto isEqual(const Type &other) const
Definition: stream.h:67
Type elementType() const
Definition: stream.h:45
std::map< std::string, node::detail::PropertyValue > Properties
Definition: node.h:83
Type dereferencedType() const
Definition: stream.h:86
Type iteratorType(bool) const
Definition: stream.h:47
Definition: stream.h:36
Definition: type.h:152
Definition: type.h:33
Definition: node.h:97
Definition: type.h:23
Definition: location.h:17
auto properties() const
Definition: stream.h:32
auto properties() const
Definition: stream.h:49
auto & meta() const
Definition: node.h:449
Type viewType() const
Definition: stream.h:74
Type elementType() const
Definition: stream.h:69