是否有工具可以为结构或类自动生成 ostream << 运算符?
输入(取自One Debug-Print 函数以统治它们):
typedef struct ReqCntrlT /* Request control record */
{
int connectionID;
int dbApplID;
char appDescr[MAX_APPDSCR];
int reqID;
int resubmitFlag;
unsigned int resubmitNo;
char VCIver[MAX_VCIVER];
int loginID;
} ReqCntrlT;
输出:
std::ostream& operator <<(std::ostream& os, const ReqCntrlT& r)
{
os << "reqControl { "
<< "\n\tconnectionID: " << r.connectionID
<< "\n\tdbApplID: " << r.dbApplID
<< "\n\tappDescr: " << r.appDescr
<< "\n\treqID: " << r.reqID
<< "\n\tresubmitFlag: " << r.resubmitFlag
<< "\n\tresubmitNo: " << r.resubmitNo
<< "\n\tVCIver: " << r.VCIver
<< "\n\tloginID: " << r.loginID
<< "\n}";
return os;
}
任何工具都可以,首选 Python / Ruby 脚本。