]>
git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/thrift/lib/cpp/test/GenericHelpers.h
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
20 #ifndef _THRIFT_TEST_GENERICHELPERS_H_
21 #define _THRIFT_TEST_GENERICHELPERS_H_ 1
23 #include <thrift/protocol/TProtocol.h>
25 #include <thrift/Thrift.h>
27 /* ClassName Helper for cleaner exceptions */
31 static const char* getName() {
32 return "Unknown type";
37 const char* ClassNames::getName
<int8_t>() {
41 const char* ClassNames::getName
<int16_t>() {
45 const char* ClassNames::getName
<int32_t>() {
49 const char* ClassNames::getName
<int64_t>() {
53 const char* ClassNames::getName
<double>() {
57 const char* ClassNames::getName
<std::string
>() {
61 /* Generic Protocol I/O function for tests */
66 static uint32_t write(std::shared_ptr
<apache::thrift::protocol::TProtocol
> proto
, const int8_t& val
) {
67 return proto
->writeByte(val
);
70 static uint32_t write(std::shared_ptr
<apache::thrift::protocol::TProtocol
> proto
, const int16_t& val
) {
71 return proto
->writeI16(val
);
74 static uint32_t write(std::shared_ptr
<apache::thrift::protocol::TProtocol
> proto
, const int32_t& val
) {
75 return proto
->writeI32(val
);
78 static uint32_t write(std::shared_ptr
<apache::thrift::protocol::TProtocol
> proto
, const double& val
) {
79 return proto
->writeDouble(val
);
82 static uint32_t write(std::shared_ptr
<apache::thrift::protocol::TProtocol
> proto
, const int64_t& val
) {
83 return proto
->writeI64(val
);
86 static uint32_t write(std::shared_ptr
<apache::thrift::protocol::TProtocol
> proto
, const std::string
& val
) {
87 return proto
->writeString(val
);
92 static uint32_t read(std::shared_ptr
<apache::thrift::protocol::TProtocol
> proto
, int8_t& val
) { return proto
->readByte(val
); }
94 static uint32_t read(std::shared_ptr
<apache::thrift::protocol::TProtocol
> proto
, int16_t& val
) { return proto
->readI16(val
); }
96 static uint32_t read(std::shared_ptr
<apache::thrift::protocol::TProtocol
> proto
, int32_t& val
) { return proto
->readI32(val
); }
98 static uint32_t read(std::shared_ptr
<apache::thrift::protocol::TProtocol
> proto
, int64_t& val
) { return proto
->readI64(val
); }
100 static uint32_t read(std::shared_ptr
<apache::thrift::protocol::TProtocol
> proto
, double& val
) { return proto
->readDouble(val
); }
102 static uint32_t read(std::shared_ptr
<apache::thrift::protocol::TProtocol
> proto
, std::string
& val
) {
103 return proto
->readString(val
);