16. Data Driven API Style
// flat c-style
func(obj, a, b, c);
!
// object-orient style
obj.func(a, b, c);
!
// data-driven function with parameters
send(func, a, b, c);
!
//data-driven function with a dictionary
send(func, dict(arg1 = a, arg2 = b, arg3 = c));
17. Data Driven API Style
class Stack
{
public:
Stack();
Result Command(const std::string &command, const
ArgList *args);
};
18. Data Driven API Style 語
s = new Stack();
if (s)
{
s->Command(Push, ArgList().Add(value, 10));
s->Command(Push, ArgList().Add(value, 3));
Stack::Result r = s->Command(IsEmpty);
while (!r.convertToBool())
{
s->Command(Pop);
r = s->Command(IsEmpty);
}
delete s;
}
Tip: QT QVariant, Boost any, Union, void*, 煙 伎
螳覲 朱誤磯ゼ 伎
19. Data Driven API Style ろ
危
# Input file for data driven Stack API
Push value:10
Push value:3
Pop
Pop