Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-17 08:35:04

0001 /*
0002  * Licensed to the Apache Software Foundation (ASF) under one
0003  * or more contributor license agreements. See the NOTICE file
0004  * distributed with this work for additional information
0005  * regarding copyright ownership. The ASF licenses this file
0006  * to you under the Apache License, Version 2.0 (the
0007  * "License"); you may not use this file except in compliance
0008  * with the License. You may obtain a copy of the License at
0009  *
0010  *   http://www.apache.org/licenses/LICENSE-2.0
0011  *
0012  * Unless required by applicable law or agreed to in writing,
0013  * software distributed under the License is distributed on an
0014  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
0015  * KIND, either express or implied. See the License for the
0016  * specific language governing permissions and limitations
0017  * under the License.
0018  */
0019 
0020 #ifndef _THRIFT_OUTPUT_H_
0021 #define _THRIFT_OUTPUT_H_ 1
0022 
0023 #include <thrift/thrift_export.h>
0024 
0025 namespace apache {
0026 namespace thrift {
0027 
0028 class TOutput {
0029 public:
0030   TOutput();
0031 
0032   inline void setOutputFunction(void (*function)(const char*)) { f_ = function; }
0033 
0034   inline void operator()(const char* message) { f_(message); }
0035 
0036   // It is important to have a const char* overload here instead of
0037   // just the string version, otherwise errno could be corrupted
0038   // if there is some problem allocating memory when constructing
0039   // the string.
0040   void perror(const char* message, int errno_copy);
0041   inline void perror(const std::string& message, int errno_copy) {
0042     perror(message.c_str(), errno_copy);
0043   }
0044 
0045   void printf(const char* message, ...);
0046 
0047   static void errorTimeWrapper(const char* msg);
0048 
0049   /** Just like strerror_r but returns a C++ string object. */
0050   static std::string strerror_s(int errno_copy);
0051 
0052 private:
0053   void (*f_)(const char*);
0054 };
0055 
0056 THRIFT_EXPORT extern TOutput GlobalOutput;
0057 }
0058 } // namespace apache::thrift
0059 
0060 #endif //_THRIFT_OUTPUT_H_