aboutsummaryrefslogtreecommitdiff
path: root/app/source/Cplt/Model/Workflow/Values/List.hpp
blob: cc8e06148d38bd721284e34b63d8ab9e1cbf9381 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#pragma once

#include <Cplt/Model/Workflow/Value.hpp>

#include <memory>
#include <vector>

class ListValue : public BaseValue
{
public:
	class Iterator
	{
	private:
		std::vector<std::unique_ptr<BaseValue>>::iterator mIter;

	public:
		BaseValue* operator*() const;
		BaseValue* operator->() const;

		Iterator& operator++();
		Iterator operator++(int) const;
		Iterator& operator--();
		Iterator operator--(int) const;

		friend bool operator==(const Iterator& a, const Iterator& b);

	private:
		friend class ListValue;
		Iterator(decltype(mIter) iter);
	};

private:
	std::vector<std::unique_ptr<BaseValue>> mElements;

public:
	static bool IsInstance(const BaseValue* value);
	ListValue();

	int GetCount() const;
	BaseValue* GetElement(int i) const;

	void Append(std::unique_ptr<BaseValue> element);
	void Insert(int i, std::unique_ptr<BaseValue> element);
	void Insert(Iterator iter, std::unique_ptr<BaseValue> element);
	void Remove(int i);
	void Remove(Iterator iter);

	Iterator begin();
	Iterator end();
};