Home > Mobile >  Want to realize the toString method in the c + + each base class, convenient to print each member va
Want to realize the toString method in the c + + each base class, convenient to print each member va

Time:12-06

Want to achieve in the c + + base classes each toString method, convenient log print each member variable values, but his hand writing class member variables too much too much too difficult, I want to a way of thinking is to use the script to automatically generate the toString method, is the class files, use the script to read in, and then identify each class, find a member variable, in the script then write the toString method, write back to the class file, main is to identify classes and member variables, and difficult to deal with custom types, the great god have similar implementation approach or a similar project reference, even the variables Set with the get method to achieve the best

CodePudding user response:

If we can only hope the value you want recorded in the log, don't use the toString method, as long as you use qDebug () will print you want to record to the log data, program boot runtime USES qInstallMessageHandler detailed log (output) can

CodePudding user response:

reference 1st floor sonicss response:
if we can only hope the value you want recorded in the log, not the toString method, as long as you use qDebug () will print you want to record to the log data, the program will then run on using qInstallMessageHandler detailed log (output) can
is the debug line, now hope every base as the parameter data member variables of the class are playing out, one by one manually parameters write too hard, a class a class nested when Ken can have hundreds of parameters, so I hope each class generated toString method, member variable names and values in the toString method as the key - value output in the form of a string, then print only the toString method is ok, but I have more lazy, don't want to write the toString method one by one, to see what tools can generate, or a similar script can
  •  Tags:  
  • Qt
  • Related