icinga2/base/utility.h

54 lines
890 B
C++

#ifndef UTILITY_H
#define UTILITY_H
namespace icinga
{
/**
* Utility
*
* Utility functions.
*/
class I2_BASE_API Utility
{
private:
static bool m_SSLInitialized;
Utility(void);
static void InitializeOpenSSL(void);
public:
/**
* GetTypeName
*
* Returns the type name of an object (using RTTI).
*/
template<class T>
static string GetTypeName(const T& value)
{
string klass = typeid(value).name();
#ifdef HAVE_GCC_ABI_DEMANGLE
int status;
char *realname = abi::__cxa_demangle(klass.c_str(), 0, 0, &status);
if (realname != NULL) {
klass = string(realname);
free(realname);
}
#endif /* HAVE_GCC_ABI_DEMANGLE */
return klass;
}
static void Daemonize(void);
static shared_ptr<SSL_CTX> MakeSSLContext(string pubkey, string privkey, string cakey);
static string GetCertificateCN(const shared_ptr<X509>& certificate);
};
}
#endif /* UTILITY_H */