This repository has been archived by the owner on Dec 12, 2023. It is now read-only.
/
easytorq.h
executable file
·86 lines (72 loc) · 2.16 KB
/
easytorq.h
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#if ! defined EASYTORQ_H
#define EASYTORQ_H
#include <stdexcept>
#include <string>
#include <vector>
#include <map>
#include "utf8support.h"
#include "interpreter.h"
namespace easytorq {
class RuntimeError : public std::runtime_error {
public:
RuntimeError(const std::string &causeStr)
: std::runtime_error(causeStr)
{
}
};
class ParseError : public RuntimeError {
public:
ParseError(const std::string &causeStr)
: RuntimeError(causeStr)
{
}
};
class InterpretationError : public RuntimeError {
public:
InterpretationError(const std::string &causeStr)
: RuntimeError(causeStr)
{
}
};
class Tree {
private:
text::TokenSequence text;
public:
Tree(const std::string &utf8str);
const text::TokenSequence *refText() const;
text::TokenSequence *refText();
};
class Pattern {
private:
Interpreter interp;
std:: vector<MYWCHAR_T> varName;
long cutoffValue;
public:
Pattern(const std::string &patternStr); // throws ParseError
void setCutoffValue(long newValue);
void apply(Tree *pTree) const; // throws InterpretationError
};
class FormatterBase {
public:
virtual ~FormatterBase() { }
public:
virtual void addNodeFlatten(const std::string &nodeName) = 0;
virtual void addNodeNone(const std::string &nodeName) = 0;
virtual void addNodeTerminate(const std::string &nodeName) = 0;
virtual void addNodeReplace(const std::string &nodeName, const std::string &newName) = 0;
virtual void addNodeFormat(const std::string &nodeName, const std::string &openStr, const std::string &closeStr) = 0;
virtual std::string format(const Tree &tree) const = 0;
};
class CngFormatter : public FormatterBase {
private:
std::map<std::vector<MYWCHAR_T>, text::Helper::NodeFormat> nodeFormats;
public:
void addNodeFlatten(const std::string &nodeName);
void addNodeNone(const std::string &nodeName);
void addNodeTerminate(const std::string &nodeName);
void addNodeReplace(const std::string &nodeName, const std::string &newName);
void addNodeFormat(const std::string &nodeName, const std::string &openStr, const std::string &closeStr);
std::string format(const Tree &tree) const;
};
};
#endif // EASYTORQ_H