Is there a tool to auto-generate the ostream << operator for a struct or class?
Input (taken from One Debug-Print function to rule them all):
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;
Output:
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;
}
Any tool would be fine, Python / Ruby scripts would be preferred.