Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-2067

Thrift objects should have a default string representation

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 0.9.2
    • Labels:
      None

      Description

      Just like thrift objects implement a custom toString in Java, there should be an inline friend function that writes a text representation of the struct to a std::ostream. Probably makes sense for the text representation to be similar to C++:

      class MyThriftClass {
          friend std::ostream& operator<<(std::ostream& o, MyThriftClass) {
              o << "MyThriftClass[";
              o << "field1=" << field1;
              if (__isset.field2) {
                   o << ", field2=" << field2;
              }
              o << ", list1=" << apache::thrift::util::to_string(list1);
              return o << "]";
          }
          // ...
      }
      

      There will also probably be a util.h file to include that implements generic template to_string for lists, maps, & sets.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                hcorg Konrad Grochowski
                Reporter:
                vlovich Vitali Lovich
              • Votes:
                1 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: