#include <cstddef>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <exception>
#include <stdexcept>
#include <string>
#include <ios>
#include <new>
#include <typeinfo>
#include <limits>
#include <array>
#include <initializer_list>
#include <type_traits>
Classes | |
class | PLMD::Plumed::add_buffer_to< T > |
class | PLMD::Plumed::CString |
class | PLMD::Plumed::Exception |
Base class used to rethrow PLUMED exceptions. More... | |
class | PLMD::Plumed::ExceptionDebug |
Used to rethrow a PLMD::ExceptionDebug. More... | |
class | PLMD::Plumed::ExceptionError |
Used to rethrow a PLMD::ExceptionError. More... | |
class | PLMD::Plumed::ExceptionTypeError |
Thrown when a wrong pointer is passed to the PLUMED interface. More... | |
class | PLMD::Plumed::finalize_plumed_error |
Internal class to simplify plumed_error finalization. More... | |
struct | PLMD::wrapper::has_size_and_data< T, typename > |
Primary template, assumes T does not have both size() and data() methods. More... | |
struct | PLMD::wrapper::has_size_and_data< T, void_t< decltype(std::declval< T >().size()), decltype(std::declval< T >().data())> > |
Specialization for types T that do have both size() and data() methods. More... | |
class | PLMD::Plumed::Invalid |
Thrown when trying to access an invalid plumed object. More... | |
struct | PLMD::wrapper::is_custom_array< T > |
Primary template, assumes T is not a custom structure. More... | |
struct | PLMD::wrapper::is_custom_array< std::array< T, N > > |
Template specialization for std::array. More... | |
struct | PLMD::wrapper::is_custom_array< T[N]> |
Template specialization for C arrays. More... | |
class | PLMD::Plumed::LeptonException |
Class used to rethrow Lepton exceptions. More... | |
struct | PLMD::wrapper::make_void< Ts > |
This is to replace c++17 std::void_t. More... | |
class | PLMD::Plumed |
C++ wrapper for plumed. More... | |
struct | plumed |
Main plumed object. More... | |
struct | plumed_error |
Small structure that is only defined locally to retrieve errors. More... | |
struct | plumed_error_filesystem_path |
struct | plumed_nothrow_handler |
struct | plumed_safeptr |
Structure holding a typesafe pointer. More... | |
class | PLMD::Plumed::rethrow_nested |
Internal class used by exception_dispatch. More... | |
class | PLMD::Plumed::rethrow_not_nested |
Internal class used by exception_dispatch. More... | |
class | PLMD::Plumed::SafePtr |
Small class that wraps plumed_safeptr in order to make its initialization easier. More... | |
struct | PLMD::Plumed::SizeLike |
Small structure used to pass elements of a shape initializer_list. More... | |
Namespaces | |
PLMD | |
PLMD::wrapper | |
We use a separate namespace here instead of hiding these classes in the Plumed class, because some of these structs might be specialized by the user. | |
Typedefs | |
typedef struct plumed_error | plumed_error |
Small structure that is only defined locally to retrieve errors. More... | |
typedef struct plumed_error_filesystem_path | plumed_error_filesystem_path |
template<typename... Ts> | |
using | PLMD::wrapper::void_t = typename make_void< Ts... >::type |
Functions | |
template<typename T , typename std::enable_if< wrapper::is_custom_array< typename std::remove_reference< T >::type >::value, int >::type = 0> | |
wrapper::is_custom_array< T >::value_type * | PLMD::wrapper::custom_array_cast (T *val) |
Cast a pointer to a custom_array to a pointer of its value_type. More... | |
template<typename T , typename std::enable_if< wrapper::is_custom_array< typename std::remove_reference< T >::type >::value, int >::type = 0> | |
std::size_t | PLMD::wrapper::custom_array_size () |
Report the size of a custom_array. More... | |
void | plumed_cmd_safe (plumed p, const char *key, plumed_safeptr) |
void | plumed_cmd_safe_nothrow (plumed p, const char *key, plumed_safeptr, plumed_nothrow_handler nothrow) |
plumed | plumed_create_dlopen2 (const char *path, int mode) |
Constructor from path. More... | |
plumed | plumed_create_dlsym (void *dlhandle) |
Constructor from dlopen handle. More... | |
__PLUMED_WRAPPER_STATIC_INLINE void | plumed_error_finalize (plumed_error error) noexcept |
Finalize error - should be called when an error is raised to avoid leaks. More... | |
__PLUMED_WRAPPER_STATIC_INLINE void | plumed_error_init (plumed_error *error) noexcept |
Initialize error (for internal usage) More... | |
__PLUMED_WRAPPER_STATIC_INLINE void | plumed_error_merge_with_nested (plumed_error *error) noexcept |
Merge with nested exceptions. More... | |
__PLUMED_WRAPPER_STATIC_INLINE void | plumed_error_recursive_merge (plumed_error *error, char *buffer, const char *join, __PLUMED_WRAPPER_STD size_t *len) noexcept |
Recursive merge (for internal usage) More... | |
__PLUMED_WRAPPER_CXX_NORETURN __PLUMED_WRAPPER_STATIC_INLINE void | plumed_error_rethrow (plumed_error h) |
Rethrow error (calling abort) More... | |
__PLUMED_WRAPPER_STATIC_INLINE void | plumed_error_set (void *ptr, int code, const char *what, const void *opt) noexcept |
Callback (for internal usage) More... | |
__PLUMED_WRAPPER_STATIC_INLINE void | plumed_error_set_bad_alloc (plumed_error *error) |
Set error to bad_alloc (for internal usage). More... | |
const __PLUMED_WRAPPER_STATIC_INLINE char * | plumed_error_what (plumed_error error) noexcept |
Access message - more robust than directly accessing what ptr, for future extensibility. More... | |
void | plumed_free (void *ptr) |
This is an internal tool, to make sure that all free calls inside the plumed library refer to the same implementation. More... | |
void * | plumed_malloc (__PLUMED_WRAPPER_STD size_t size) |
This is an internal tool, to make sure that all malloc calls inside the plumed library refer to the same implementation. More... | |
static __PLUMED_WRAPPER_ANONYMOUS_BEGIN bool | PLMD::PlumedGetenvExceptionsDebug () noexcept |
Retrieve PLUMED_EXCEPTIONS_DEBUG (internal utility). More... | |
template<> | |
std::size_t | PLMD::wrapper::size (const std::string &obj) |
Specialization for std::string, which returns size()+1, which includes the terminating null character. More... | |
template<typename T > | |
std::size_t | PLMD::wrapper::size (const T &obj) |
Generic utility to retrieve the size of a container. More... | |
#define __PLUMED_WRAPPER_ANONYMOUS_BEGIN |
#define __PLUMED_WRAPPER_ANONYMOUS_END |
#define __PLUMED_WRAPPER_C_BEGIN __PLUMED_WRAPPER_EXTERN_C_BEGIN extern |
#define __PLUMED_WRAPPER_C_END __PLUMED_WRAPPER_EXTERN_C_END |
#define __PLUMED_WRAPPER_C_TYPESAFE 0 |
#define __PLUMED_WRAPPER_CXX 1 |
#define __PLUMED_WRAPPER_CXX_ANONYMOUS_NAMESPACE 0 |
#define __PLUMED_WRAPPER_CXX_ANONYMOUS_NAMESPACE_PLMD_EXCEPTIONS 0 |
#define __PLUMED_WRAPPER_CXX_BIND_C 1 |
#define __PLUMED_WRAPPER_CXX_DEFAULT_INVALID 0 |
#define __PLUMED_WRAPPER_CXX_DETECT_SHAPES_STRICT 0 |
#define __PLUMED_WRAPPER_CXX_ENABLE_NESTED_EXCEPTIONS 1 |
#define __PLUMED_WRAPPER_CXX_EXCEPTION_BUFFER 512 |
#define __PLUMED_WRAPPER_CXX_EXPLICIT explicit |
#define __PLUMED_WRAPPER_CXX_LONGLONG 1 |
#define __PLUMED_WRAPPER_CXX_NOEXCEPT noexcept |
#define __PLUMED_WRAPPER_CXX_NORETURN [[ noreturn ]] |
#define __PLUMED_WRAPPER_CXX_NULLPTR nullptr |
#define __PLUMED_WRAPPER_CXX_OVERRIDE override |
#define __PLUMED_WRAPPER_CXX_POLYMORPHIC 1 |
#define __PLUMED_WRAPPER_CXX_STD 1 |
#define __PLUMED_WRAPPER_ENABLE_RTLD_DEEPBIND 1 |
#define __PLUMED_WRAPPER_EXTERN 1 |
#define __PLUMED_WRAPPER_EXTERN_C_BEGIN extern "C" { |
#define __PLUMED_WRAPPER_EXTERN_C_END } |
#define __PLUMED_WRAPPER_GLOBAL 1 |
#define __PLUMED_WRAPPER_IMPLEMENTATION_ 0 |
#define __PLUMED_WRAPPER_INTERNALS_BEGIN __PLUMED_WRAPPER_EXTERN_C_BEGIN static |
#define __PLUMED_WRAPPER_INTERNALS_END __PLUMED_WRAPPER_EXTERN_C_END |
#define __PLUMED_WRAPPER_LIBCXX11 0 |
#define __PLUMED_WRAPPER_LIBCXX17 0 |
#define __PLUMED_WRAPPER_REDEFINE_CMD ::PLMD::Plumed::plumed_cmd_cxx |
#define __PLUMED_WRAPPER_REDEFINE_ERROR_RETHROW ::PLMD::Plumed::plumed_error_rethrow_cxx |
#define __PLUMED_WRAPPER_REDEFINE_GCMD ::PLMD::Plumed::plumed_gcmd_cxx |
#define __PLUMED_WRAPPER_REINTERPRET_CAST | ( | to, | |
what | |||
) | reinterpret_cast<to>(what) |
#define __PLUMED_WRAPPER_SAFEPTR | ( | type, | |
code, | |||
size | |||
) |
Macro that uses __PLUMED_WRAPPER_SAFEPTR_INNER to generate constructors with all possible pointer-const combinations.
#define __PLUMED_WRAPPER_SAFEPTR_EMPTY | ( | type, | |
code | |||
) | __PLUMED_WRAPPER_SAFEPTR(type,code,0) |
Macro that generates the constructors from empy types (those of which sizeof cannot be computed)
#define __PLUMED_WRAPPER_SAFEPTR_INNER | ( | type_, | |
flags_ | |||
) |
Macro that generate a constructor with given type and flags.
#define __PLUMED_WRAPPER_SAFEPTR_SIZED | ( | type, | |
code | |||
) |
Macro that generates the constructors from sized types (those of which sizeof can be computed).
In addition to generating constructors with all pointer types, it generates a constructor to allow pass-by-value
#define __PLUMED_WRAPPER_STATIC_CAST | ( | to, | |
what | |||
) | static_cast<to>(what) |
#define __PLUMED_WRAPPER_STATIC_INLINE static inline |
#define __PLUMED_WRAPPER_STD ::std:: |
#define plumed_error_rethrow __PLUMED_WRAPPER_REDEFINE_ERROR_RETHROW |
|
related |
Small structure that is only defined locally to retrieve errors.
It is supposed to be used in the C11/C++ plumed_cmd interface as follows:
plumed p; plumed_error error; p=plumed_create(); plumed_cmd(p,"setNatoms",10,&error); if(error.code) { fprintf(errors,"%d\n",error.code); plumed_error_finalize(error); // make sure the error object is finalized! } // if no error was raised (error.code==0), it is not necessary to call plumed_error_finalize. // but doing it is harmless // no need to initialize error, it is written in the plumed_cmd function plumed_cmd(p,"init",&error); if(error.code) { fprintf(errors,"%d\n",error.code); plumed_error_finalize(error); // make sure the error object is finalized! }
The layout of this structure is subject to change, thus all the functions manipulating it are defined as inline/static functions. In the future, we might reach some form of ABI stability, and these functions might be moved below to the implementation file.
Notice that there is a macro plumed_error() defined in the PLUMED source code (at tools/Exception.h). There is no conflict with this type since C preprocessor distinguishes macros and function-like macros.
typedef struct plumed_error_filesystem_path plumed_error_filesystem_path |
void plumed_cmd_safe | ( | plumed | p, |
const char * | key, | ||
plumed_safeptr | |||
) |
void plumed_cmd_safe_nothrow | ( | plumed | p, |
const char * | key, | ||
plumed_safeptr | , | ||
plumed_nothrow_handler | nothrow | ||
) |
plumed plumed_create_dlopen2 | ( | const char * | path, |
int | mode | ||
) |
Constructor from path.
Available as of PLUMED 2.5
Same as plumed_create_dlopen, but also allows to specify the mode for dlopen.
plumed plumed_create_dlsym | ( | void * | dlhandle | ) |
Constructor from dlopen handle.
Available as of PLUMED 2.8
Same as plumed_create_dlopen, but it acts on an already loaded library. This allows to separate the library loading from the construction of the plumed object. By using this function, the caller takes the responsibility to later use dlclose on this handle.
|
noexcept |
Finalize error - should be called when an error is raised to avoid leaks.
|
noexcept |
Initialize error (for internal usage)
|
noexcept |
Merge with nested exceptions.
|
noexcept |
Recursive merge (for internal usage)
__PLUMED_WRAPPER_CXX_NORETURN __PLUMED_WRAPPER_STATIC_INLINE void plumed_error_rethrow | ( | plumed_error | h | ) |
Rethrow error (calling abort)
|
noexcept |
Callback (for internal usage)
__PLUMED_WRAPPER_STATIC_INLINE void plumed_error_set_bad_alloc | ( | plumed_error * | error | ) |
Set error to bad_alloc (for internal usage).
At variance with plumed_error_init, it also finalizes the error, possibly deallocating any buffer.
|
noexcept |
Access message - more robust than directly accessing what ptr, for future extensibility.
void plumed_free | ( | void * | ptr | ) |
This is an internal tool, to make sure that all free calls inside the plumed library refer to the same implementation.
When compiling with __PLUMED_WRAPPER_DEBUG_REFCOUNT=1 it is possible to log allocations and deallocations, so as to debug the wrappers.
void* plumed_malloc | ( | __PLUMED_WRAPPER_STD size_t | size | ) |
This is an internal tool, to make sure that all malloc calls inside the plumed library refer to the same implementation.
When compiling with __PLUMED_WRAPPER_DEBUG_REFCOUNT=1 it is possible to log allocations and deallocations, so as to debug the wrappers.
Hosted by GitHub | 1.8.17 |