libart-paperback 0.1.0-a.1.20260122225059.e5fea306241a
PDF (1.4) library for C++
dictionary.hxx
1#ifndef art__paperback__carousel__dictionary_hxx_
2#define art__paperback__carousel__dictionary_hxx_
3
4#include <art/paperback/types.hxx>
5#include <art/paperback/forward.hxx>
6
7#include <art/paperback/carousel/name.hxx>
8#include <art/paperback/carousel/object-model.hxx>
9
11{
12
13 /// Represents a COS dictionary.
14 ///
17 {
18 public:
19 /// Iterator type.
20 ///
21 using iterator = typename map<Name, Object>::iterator;
22
23 /// Immutable iterator type.
24 ///
25 using const_iterator = typename map<Name, Object>::const_iterator;
26
27 /// Constructor.
28 ///
29 Dictionary();
30
31 /// Constructor.
32 ///
33 explicit
34 Dictionary(map<Name, Object>);
35
36 /// Constructor.
37 ///
38 Dictionary(Dictionary const&);
39
40 /// Constructor.
41 ///
43
44 /// Destructor.
45 ///
46 ~Dictionary() noexcept;
47
48 /// Get the size of the dictionary.
49 ///
50 size_t
51 size() const;
52
53 /// Check if the dictionary is empty.
54 ////
55 bool
56 empty() const;
57
58 /// Check if the dictionary contains a key.
59 ///
60 bool
61 contains(Name const&);
62
63 /// Access entry.
64 ///
65 Object&
66 at(Name const&);
67
68 /// Access entry.
69 ///
70 Object const&
71 at(Name const&) const;
72
73 /// Get begin iterator.
74 ///
76 begin();
77
78 /// Get begin iterator.
79 ///
81 begin() const;
82
83 /// Get begin iterator.
84 ///
86 cbegin() const;
87
88 /// Get past-the-end iterator.
89 ///
91 end();
92
93 /// Get past-the-end iterator.
94 ///
96 end() const;
97
98 /// Get past-the-end iterator.
99 ///
101 cend() const;
102
103 /// Insert entry into dictionary.
104 ///
105 void
106 insert(Name const&, Object);
107
108 /// Remove entry from dictionary.
109 ///
110 void
111 erase(Name const&);
112
113 /// Assignment.
114 ///
116 operator=(Dictionary const&);
117
118 /// Assignment.
119 ///
121 operator=(Dictionary&&);
122
123 /// Comparison.
124 ///
125 bool
126 operator==(Dictionary const&) const;
127
128 /// Comparison.
129 ///
130 bool
131 operator!=(Dictionary const&) const;
132
133 protected:
134 void
135 attach_children(Object_model::Owner&) override;
136
137 private:
138 map<Name, Object> _data;
139
140 };
141
142} // namespace Art::Paperback::Carousel
143
144#endif
size_t size() const
Get the size of the dictionary.
Definition dictionary.cxx:34
Dictionary()
Constructor.
Definition dictionary.cxx:10
iterator end()
Get past-the-end iterator.
Definition dictionary.cxx:90
typename map< Name, Object >::const_iterator const_iterator
Immutable iterator type.
Definition dictionary.hxx:25
void insert(Name const &, Object)
Insert entry into dictionary.
Definition dictionary.cxx:111
~Dictionary() noexcept
Destructor.
Definition dictionary.cxx:29
bool contains(Name const &)
Check if the dictionary contains a key.
Definition dictionary.cxx:48
const_iterator cbegin() const
Get begin iterator.
Definition dictionary.cxx:83
iterator begin()
Get begin iterator.
Definition dictionary.cxx:69
const_iterator cend() const
Get past-the-end iterator.
Definition dictionary.cxx:104
Object & at(Name const &)
Access entry.
Definition dictionary.cxx:55
typename map< Name, Object >::iterator iterator
Iterator type.
Definition dictionary.hxx:21
void erase(Name const &)
Remove entry from dictionary.
Definition dictionary.cxx:128
bool empty() const
Check if the dictionary is empty. /.
Definition dictionary.cxx:41
void attach_children(Object_model::Owner &) override
Attach any children.
Definition dictionary.cxx:176
Represents a COS name.
Definition name.hxx:16
Base class for value types.
Definition object-model.hxx:295
Represents a COS-file object.
Definition object.hxx:16
COS object model namespace.
Definition object-model.cxx:8
COS file format implementation namespace.
Definition array.cxx:6