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

Thrift/cpp: Allow alternate classes to be used for

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 0.9
    • 0.9
    • C++ - Library
    • None

    Description

      From 826d3646f47cb856f22a10087350f551bfc8b834 Mon Sep 17 00:00:00 2001
      From: David Reiss <dreiss@fb.com>
      Date: Fri, 10 Sep 2010 04:03:48 +0000
      Subject: [PATCH 09/12] Thrift/cpp: Allow alternate classes to be used for
      Thrift strings

      Summary:

      The goal of this diff is to allow Thrift strings to be used without
      depending on std::string, since it looks like we're starting to move
      away from std::string instead of moving to a better implementation.

      The challenge here is the protocol read code. Structs normally pass
      std::string references to TProtocol::readString, which then populates
      the string with the appropriate data. However, this can't be done with
      an arbitrary class. TProtocol::readString cannot be a template function
      because it is virtual. One option would be to make
      TProtocol::readString take a shim object with virtual members for
      populating the actual string. Another would be to require services that
      use nonstandard string classes to only use template-style Thrift code.
      This diff does the latter.

      • Recognize templates=only as a generator option to skip the generic
        process function implementations (actually just the pointers).
      • Recognize "cpp.type" as a type annotation on strings to force the C++
        type used to represent them.
      • Make TBinaryProtocol::readString a template method.

      Test Plan:

      • Ran the server under valgrind and called both methods.

      Attachments

        1. 0009-Thrift-cpp-Allow-alternate-classes-to-be-used-for-Th.patch
          5 kB
          Dave Watson
        2. thrift-1567-on-trunk.txt
          5 kB
          Todd Lipcon
        3. thrift-types-demo.patch
          6 kB
          David Reiss

        Activity

          People

            dreiss David Reiss
            davejwatson@fb Dave Watson
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: