 + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-  *
-- * Unless required by applicable law or agreed to in writing,
-- * software distributed under the License is distributed on an
-- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-- * KIND, either express or implied. See the License for the
-- * specific language governing permissions and limitations
-- * under the License.
-  */
- 
- #include <iostream>
++ *
++ */
++
++#include <iostream>
 +#include <memory>
 +#include <string>
- 
--#include <thrift/protocol/TBinaryProtocol.h>
--#include <thrift/transport/TSocket.h>
--#include <thrift/transport/TTransportUtils.h>
--
--#include "../gen-cpp/Calculator.h"
++
 +#include <grpc++/grpc++.h>
- 
--using namespace std;
--using namespace apache::thrift;
--using namespace apache::thrift::protocol;
--using namespace apache::thrift::transport;
++
 +#include "gen-cpp/Greeter.grpc.thrift.h"
- 
--using namespace tutorial;
--using namespace shared;
++
 +using grpc::Channel;
 +using grpc::ClientContext;
 +using grpc::Status;
 +using test::Greeter;
 +using namespace test;
- 
--int main() {
--  boost::shared_ptr<TTransport> socket(new TSocket("localhost", 9090));
--  boost::shared_ptr<TTransport> transport(new TBufferedTransport(socket));
--  boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
--  CalculatorClient client(protocol);
++
 +class GreeterClient {
 + public:
 +  GreeterClient(std::shared_ptr<Channel> channel)
 +      : stub_(Greeter::NewStub(channel)) {}
- 
--  try {
--    transport->open();
-+  // Assambles the client's payload, sends it and presents the response back
++
++  // Assembles the client's payload, sends it and presents the response back
 +  // from the server.
 +  std::string SayHello(const std::string& user) {
 +    // Data we are sending to the server.
 +    Greeter::SayHelloReq req;
 +    req.request.name = user;
- 
--    client.ping();
--    cout << "ping()" << endl;
++
 +    // Container for the data we expect from the server.
 +    Greeter::SayHelloResp reply;
- 
--    cout << "1 + 1 = " << client.add(1, 1) << endl;
++
 +    // Context for the client. It could be used to convey extra information to
 +    // the server and/or tweak certain RPC behaviors.
 +    ClientContext context;
- 
--    Work work;
--    work.op = Operation::DIVIDE;
--    work.num1 = 1;
--    work.num2 = 0;
++
 +    // The actual RPC.
 +    Status status = stub_->SayHello(&context, req, &reply);
- 
--    try {
--      client.calculate(1, work);
--      cout << "Whoa? We can divide by zero!" << endl;
--    } catch (InvalidOperation& io) {
--      cout << "InvalidOperation: " << io.why << endl;
--      // or using generated operator<<: cout << io << endl;
--      // or by using std::exception native method what(): cout << io.what() << endl;
++
 +    // Act upon its status.
 +    if (status.ok()) {
 +      return reply.success.message;
 +    } else {
 +      return "RPC failed";
-     }
-+  }
- 
--    work.op = Operation::SUBTRACT;
--    work.num1 = 15;
--    work.num2 = 10;
--    int32_t diff = client.calculate(1, work);
--    cout << "15 - 10 = " << diff << endl;
++    }
++  }
++
 + private:
 +  std::unique_ptr<Greeter::Stub> stub_;
 +};
- 
--    // Note that C++ uses return by reference for complex types to avoid
--    // costly copy construction
--    SharedStruct ss;
--    client.getStruct(ss, 1);
--    cout << "Received log: " << ss << endl;
++
 +int main() {
 +  // Instantiate the client. It requires a channel, out of which the actual RPCs
 +  // are created. This channel models a connection to an endpoint (in this case,

+
+    }
+
+    if (extends_service != nullptr) {
+      vector<t_function*> functions = extends_service->get_functions();
+      vector<t_function*>::iterator f_iter;
+      for (f_iter = functions.begin(); f_iter != functions.end(); ++f_iter) {

 
   t_service* extends_service = tservice->get_extends();
-  if (extends_service != NULL) {
+  if (extends_service) {
     f_header_ << "#include \"" << get_include_prefix(*(extends_service->get_program()))
-              << extends_service->get_name() << ".h\"" << endl;
+              << extends_service->get_name() << ".grpc.thrift.h\"" << endl;
