我有以下代码:
Array
(
Array
(
[ShowFare] => Array
(
[id] => 21
[press_release_id] => 14
[category] => 0
[title] => pr
[image_name] => 1486719733.jpg
[crop_image] => 1486719729.jpg
[is_default] => 0
[is_active] => 0
[created] => 2017-02-10 09:42:13
[created_by] => 0
[modified] => 2017-02-10 09:42:13
[modified_by] => 0
[deleted] => 0000-00-00 00:00:00
[deleted_by] => 0
)
[PressRelease] => Array
(
[id] =>
[title] =>
)
)
Array
(
[ShowFare] => Array
(
[id] => 22
[press_release_id] => 7
[category] => 0
[title] => abcd
[image_name] => 1486721484.jpg
[crop_image] => 1486721481.jpg
[is_default] => 0
[is_active] => 0
[created] => 2017-02-10 10:11:24
[created_by] => 0
[modified] => 2017-02-10 10:11:24
[modified_by] => 0
[deleted] => 0000-00-00 00:00:00
[deleted_by] => 0
)
[PressRelease] => Array
(
[id] => 7
[title] => ht48 hours, 04 March 2016
)
)
)
我想要以下格式的上述结果:
template <typename F>
class FunctorVisitor : public Visitor
{
public:
explicit FunctorVisitor (F& f) : f(f) {}
virtual void visit(Node& n) override { f(n);}
virtual void visit(ANode& n) override { f(n);}
virtual void visit(BNode& n) override { f(n);}
virtual void visit(CNode& n) override { f(n);}
virtual void visit(SubBNode& n) override { f(n);}
private:
F& f;
};
class CountVisitor
{
public:
void operator() (const Node& n) const {
cout << __PRETTY_FUNCTION__ << "\t\tDefault" << endl;
}
void operator() (const BNode& n) {
count++;
cout << __PRETTY_FUNCTION__ << "\t\tSPECIAL" << endl;
}
int count = 0;
void print() const {
cout << "CountVisitor Found Bs: "<< count << endl;
}
};
这可能吗?
提前致谢...