aboutsummaryrefslogtreecommitdiff
path: root/core/src/Model/Workflow/Nodes/TextNodes.hpp
blob: c33854cc1e98a3f5555953eb51347c337db1e313 (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
51
52
53
#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 Type;
		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);
};