Enable traits if and only if some macros are defined

This commit is contained in:
Double Sine 2019-01-15 12:40:55 +08:00
parent 0c0925b8a6
commit 6722fbd562
No known key found for this signature in database
GPG Key ID: 44460E4F43EA8633
3 changed files with 21 additions and 5 deletions

View File

@ -1,6 +1,7 @@
#pragma once
#include "ResourceGuard.hpp"
#include <capstone/capstone.h>
#if defined(CAPSTONE_ENGINE_H)
struct CapstoneHandleTraits {
using HandleType = csh;
@ -10,3 +11,5 @@ struct CapstoneHandleTraits {
}
};
#endif

View File

@ -1,8 +1,7 @@
#pragma once
#include "ResourceGuard.hpp"
#include <openssl/bio.h>
#include <openssl/bn.h>
#include <openssl/rsa.h>
#if defined(HEADER_BIO_H)
struct OpensslBIOTraits {
using HandleType = BIO*;
@ -10,21 +9,32 @@ struct OpensslBIOTraits {
static constexpr auto& Releasor = BIO_free;
};
struct OpensslBIOChainTraits {
using HandleType = BIO*;
static inline const HandleType InvalidValue = nullptr;
static constexpr auto& Releasor = BIO_free_all;
};
#endif
#if defined(HEADER_BN_H)
struct OpensslBNTraits {
using HandleType = BIGNUM*;
static inline const HandleType InvalidValue = nullptr;
static constexpr auto& Releasor = BN_free;
};
#endif
#if defined(HEADER_RSA_H)
struct OpensslRSATraits {
using HandleType = RSA*;
static inline const HandleType InvalidValue = nullptr;
static constexpr auto& Releasor = RSA_free;
};
#endif

View File

@ -1,6 +1,7 @@
#pragma once
#include "ResourceGuard.hpp"
#include <windows.h>
#if defined(_WINDOWS_)
struct GenericHandleTraits {
using HandleType = HANDLE;
@ -20,3 +21,5 @@ struct MapViewTraits {
static constexpr auto& Releasor = UnmapViewOfFile;
};
#endif