-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMappingCall.h
More file actions
60 lines (42 loc) · 1.19 KB
/
MappingCall.h
File metadata and controls
60 lines (42 loc) · 1.19 KB
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
#ifndef MAPPINGCALL_H
#define MAPPINGCALL_H
#include <memory>
#include <vector>
#include "Expression.h"
class MappingCall : public Expression
{
std::wstring record;
std::shared_ptr<Expression> expr1, expr2;
public:
MappingCall(std::wstring record, std::shared_ptr<Expression> expr1, std::shared_ptr<Expression> expr2)
: record(record), expr1(expr1), expr2(expr2)
{
}
virtual picojson::value asJson(std::shared_ptr<Substitution> subs, bool forConditionSection) const
{
/*
"Fn::FindInMap" : [ "Region2AZ", { "Ref" : "AWS::Region" }, "AZ" ]
*/
if (subs->HasMapping(record))
{
std::map<std::wstring, picojson::value> obj;
std::vector<picojson::value> arr;
arr.push_back(picojson::value(record));
arr.push_back(expr1->asJson(subs, forConditionSection));
arr.push_back(expr2->asJson(subs, forConditionSection));
obj[L"Fn::FindInMap"] = picojson::value(arr);
return picojson::value(obj);
}
std::wcerr << "No such mapping: " << record << std::endl;
exit(1);
}
virtual ExpressionForm getForm() const
{
return MEMBER_CALL;
}
virtual std::wstring getType(std::shared_ptr<Substitution> subs) const
{
return L"string";
}
};
#endif // MAPPINGCALL_H