Coverage Report

Created: 2026-06-08 07:05

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/thrift/lib/cpp/src/thrift/TOutput.h
Line
Count
Source
1
/*
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
9
 *
10
 *   http://www.apache.org/licenses/LICENSE-2.0
11
 *
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
17
 * under the License.
18
 */
19
20
#ifndef _THRIFT_OUTPUT_H_
21
#define _THRIFT_OUTPUT_H_ 1
22
23
namespace apache {
24
namespace thrift {
25
26
class TOutput {
27
public:
28
  TOutput();
29
30
0
  inline void setOutputFunction(void (*function)(const char*)) { f_ = function; }
31
32
0
  inline void operator()(const char* message) { f_(message); }
33
34
  // It is important to have a const char* overload here instead of
35
  // just the string version, otherwise errno could be corrupted
36
  // if there is some problem allocating memory when constructing
37
  // the string.
38
  void perror(const char* message, int errno_copy);
39
0
  inline void perror(const std::string& message, int errno_copy) {
40
0
    perror(message.c_str(), errno_copy);
41
0
  }
42
43
  void printf(const char* message, ...);
44
45
  static void errorTimeWrapper(const char* msg);
46
47
  /** Just like strerror_r but returns a C++ string object. */
48
  static std::string strerror_s(int errno_copy);
49
50
  /** Get a singleton instance of the global TOutput object used by
51
   * the library internally.  */
52
  static TOutput& instance();
53
54
private:
55
  void (*f_)(const char*);
56
};
57
}
58
} // namespace apache::thrift
59
60
#endif //_THRIFT_OUTPUT_H_