aboutsummaryrefslogtreecommitdiff
path: root/core/src/Model/Workflow/Nodes/TextNodes.hpp
blob: 278db3254593b9aeee842333169115c365b0f7cc (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 "Model/Workflow/Workflow.hpp"

#include <cstddef>
#include <memory>
#include <variant>
#include <vector>

class TextFormatterNode : public WorkflowNode {
public:
	enum ArgumentType {
		NumericArgument,
		TextArgument,
		DateTimeArgument,
	};

private:
	class Impl;

	struct Argument {
		ArgumentType ArgumentType;
		int PinIdx;
	};
	using Element = std::variant<std::string, Argument>;

	std::vector<Element> mElements;
	int mMinOutputChars;

public:
	static BaseValue::Kind ArgumentTypeToValueKind(ArgumentType arg);
	static bool IsInstance(const WorkflowNode* node);
	TextFormatterNode();

	int GetElementCount() const;
	const Element& GetElement(int idx) const;

	void SetElement(int idx, std::string text);
	void SetElement(int idx, ArgumentType argument);
	void InsertElement(int idx, std::string text);
	void InsertElement(int idx, ArgumentType argument);
	void AppendElement(std::string text);
	void AppendElement(ArgumentType argument);
	void RemoveElement(int idx);

	virtual void Evaluate(WorkflowEvaluationContext& ctx) override;

private:
	void PreRemoveElement(int idx);
};