chsvlib
chsv helper source code
Chusov Namespace Reference

Basic chsvlib namespace. More...

Namespaces

 Exceptions
 A namespace for chsvlib generic exception classes and for special helper function.
 
 ExecutionControl
 A namespace of execution control facilities.
 
 Math
 A namespace containing mathematical functions and components.
 
 Memory
 A namespace of functions and components used to work with memory.
 
 String
 A namespace of string manipulation functions and classes.
 
 Win32
 Axillary chsvlib elements simplifying calls to Win32 API.
 

Classes

struct  IErrorInfo
 An interface that must be implemented by any class implementing an object to hold error information processed by the SetLastChsvErrorInformation and GetLastChsvErrorInfo. More...
 
class  chsvlib_general_category_t
 A class of general chsvlib error category, which is introduced to conform std::system_error requirements. More...
 
struct  chsvtag_HCHSVLIST
 
struct  chsvtag_HCHSVMAP
 
struct  identity
 
struct  is_swappable_with
 C++14 compliant implementation of std::is_swappable_with from <type_traits> of C++17. More...
 
struct  is_nothrow_swappable_with
 C++14 compliant implementation of std::is_nothrow_swappable_with from <type_traits> of C++17. More...
 
struct  is_swappable
 C++14 compliant implementation of std::is_swappable from <type_traits> of C++17. More...
 
struct  is_nothrow_swappable
 C++14 compliant implementation of std::is_swappable from <type_traits> of C++17. More...
 
struct  integral_sequence
 A type used to unpack tuples and pass its elements as a sequence of parameters via std::get <ind>(tuple_object)... . The type can be obtained at compile time using the integral_sequence_maker metafunction. More...
 
struct  integral_sequence_maker
 For a given size provides a type member "type" specifying an integral sequence (inclusively starting from 0 to the sequence_size - 1) of the integral_sequence type. Used to sequentially extract parameters of a variadic template like std::tuple during a function call. More...
 
struct  function_traits
 Provides traits of a Callable type: return type, parameter types, and a number of parameters. More...
 
struct  is_reference_wrapper
 Checks whether a type T is an std::reference_wrapper object. Inherits from the resulting std::integral_constant instantiation. More...
 
struct  is_equality_comparable
 Checks whether a type T satisfies the EqualityComparable requirements. More...
 
struct  is_testable_by_negation
 Checks whether a type T supports an unary negation operator, that is whether for an object T x an expression !x would be well-formed and convertible to bool. More...
 
struct  iteratable_type_traits
 If the specified type is iteratable, the class inherits members of std::iterator_traits specialized for the iterator of the specified type. More...
 
struct  is_iteratable_type
 Checks whether a given type is iteratable. More...
 

Typedefs

typedef std::int32_t chsverror_t
 A type alias for chsvlib error codes.
 
typedef unsigned long chsv_syserror_t
 A type alias resolving to a platform-defined integral type of system errors.
 
typedef void(* security_constraint_violation_procedure) (const char *file, unsigned line, const char *func)
 A type alias for a pointer to a procedure used to react upon a runtime constraint violation as defined in the ISO-IEC TR 24731-1 specification. More...
 
typedef bool(* LPLISTELEMENTFUNCTION) (void *lpListElement, void *lpArg)
 A client callback function used in the function ListApplyFuncToElements() as a procedure over each element of the list. More...
 
typedef int(* PMAPCOMPAREFUNC) (const void *pLeft, std::size_t cbLeft, const void *pRight, std::size_t cbRight) NOEXCEPT_CPP17
 A pointer to a compare function implementing a binary predicate over data in buffers pointed by the function parameters. More...
 
typedef bool(* PMAPELEMENTFUNCTION) (const void *pKey, std::size_t cbKey, void *pValue, std::size_t cbValue, void *lpArg) NOEXCEPT_CPP17
 A client callback function used in the MapApplyFuncToElements function as a procedure over each element of the map. More...
 
template<class T >
using identity_t = typename identity< T >::type
 Introduces type dependency to prohibit template argument deduction. More...
 
template<class... Ts>
using void_t = void
 

Enumerations

enum  OnErrorInfoFailture { ERROR_INFO_INIT_FAILED }
 The constant ERROR_INFO_INIT_FAILED is used as a marker for constructors of the CErrorInfoImpl template class parameter of the SetLastChsvErrorInformation function. More...
 
enum class  chsvlib_error {
  out_of_memory = (signed int) CHSVERROR_OUTOFMEMORY , invalid_parameter = (signed int) CHSVERROR_INVALID_PARAMETER , insufficient_buffer = (signed int) CHSVERROR_INSUFFICIENT_BUFFER , out_of_range = (signed int) CHSVERROR_OUT_OF_RANGE ,
  initialization_failure = (signed int) CHSVERROR_INITIALIZATION_FAILURE , not_initialized = (signed int) CHSVERROR_NOT_INITIALIZED , already_initialized = (signed int) CHSVERROR_ALREADY_INITIALIZED , invalid_version = (signed int) CHSVERROR_INVALID_VERSION ,
  entity_not_found = (signed int) CHSVERROR_NOT_FOUND , entity_already_exists = (signed int) CHSVERROR_ALREADY_EXISTS , invalid_resource = (signed int) CHSVERROR_INVALID_RESOURCE , access_denied = (signed int) CHSVERROR_ACCESS_DENIED ,
  storage_is_full = (signed int) CHSVERROR_STORAGE_FULL , invalid_char_sequence = (signed int) CHSVERROR_INVALID_CHAR_SEQUENCE , operation_cancelled = (signed int) CHSVERROR_OPERATION_CANCELLED , name_too_long = (signed int) CHSVERROR_NAME_TOO_LONG ,
  deadlock = (signed int) CHSVERROR_DEADLOCK , timeout = (signed int) CHSVERROR_TIMEOUT , owner_dead = (signed int) CHSVERROR_OWNER_IS_DEAD , operation_not_supported = (signed int) CHSVERROR_NOT_SUPPORTED ,
  arithmetic_overflow = (signed int) CHSVERROR_ARITHMETIC_OVERFLOW , stack_overflow = (signed int) CHSVERROR_STACK_OVERFLOW , underlying_platform_error = (signed int) CHSVERROR_PLATFORM_ERROR , program_logic_error = (signed int) CHSVERROR_LOGIC_ERROR
}
 A strongly typed enumeration with values equal to existing chsvlib error codes. . More...
 

Functions

errno_t Win32ErrorToPosixError (unsigned long nError) noexcept
 Translates a Windows system error code to a POSIX error code. . More...
 
chsverror_t Win32ErrorToChsvError (unsigned long nError) noexcept
 Translates a Windows system error code to the corresponding chsvlib error code. More...
 
chsverror_t PosixErrorToChsvError (errno_t nError) noexcept
 Translates a POSIX error code to the corresponding chsvlib error code. More...
 
chsverror_t SystemErrorToChsvError (chsv_syserror_t err)
 Delegates a call to a platform-dependent function which translates a system error to a corresponding chsvlib error code in a portable way. More...
 
chsv_syserror_t GetLastSystemError ()
 Returns a platform-specific last-error code, i.e. Windows error on Windows (delegates a call to GetLastError) and POSIX error on Linux (see errno). . More...
 
errno_t GetLastSystemErrorAsPosixCode ()
 Returns a platform-specific last-error code represented in POSIX error code space. More...
 
chsverror_t CHSV_MAKE_CHSV_ERROR (unsigned short nSpecCode)
 The function creating chsvlib error code from the general facility. More...
 
const wchar_t * ChsvErrorDescriptionW (chsverror_t nErrorCode, unsigned long nReserved) noexcept
 Returns a wide string description on the specified chsvlib error code. More...
 
const char * ChsvErrorDescriptionA (chsverror_t nErrorCode, unsigned long nReserved) noexcept
 Returns an multi-byte string description on the specified chsvlib error code. More...
 
template<class char_type >
const char_type * ChsvErrorDescription (chsverror_t nErrorCode, unsigned long nReserved=0) noexcept
 Returns an string description on the specified chsvlib error code. More...
 
void SetLastChsvError (chsverror_t nError) noexcept
 Sets the specified chsvlib code as a thread specific last error code. More...
 
chsverror_t GetLastChsvError () noexcept
 Returns the last thread specific chsvlib error code. More...
 
void SetLastChsvErrorInfo (chsverror_t nError, const void *pExtraInfo, std::size_t cbExtraInfo) noexcept
 Sets the a thread specific last error code along with additional data that is supposed to provide extra information about the error. More...
 
const CHSV_ERROR_INFOGetLastChsvErrorInfo () noexcept
 Returns a pointer to the CHSV_ERROR_INFO structure containing definition of the last chsvlib error code. More...
 
void security_constraint_assertion_proc (const char *file, unsigned line, const char *func) noexcept
 Upon a call, if NDEBUG macro is not defined, prints out a message composed from two strings, and an integer, and calls std::abort. If NDEBUG is defined, the function does nothing. More...
 
void security_constraint_verification_proc (const char *file, unsigned line, const char *func) noexcept
 Upon a call prints out a message composed from two strings, and an integer, and calls std::abort. More...
 
security_constraint_violation_procedure set_thread_security_constraint_violation_procedure (security_constraint_violation_procedure proc) noexcept
 Sets a procedure called when a security violation defined by ISO-IEC TR 24731-1 is detected via verify_security_constraint. More...
 
template<class CErrorInfoImpl >
void SetLastChsvErrorInformation (unsigned long nError, const CErrorInfoImpl &refErrorInfo) noexcept
 The function setting the last chsvlib error code and its description. More...
 
template<class CErrorInfoImpl >
CErrorInfoImpl GetLastChsvErrorInformation ()
 Returns the last extra error description as specified by a call to SetLastChsvErrorInfo(unsigned long nError, const CErrorInfoImpl& refErrorInfo) NOTHROW. More...
 
void SetLastChsvErrorWC (chsverror_t nChsvError) noexcept
 Sets last chsvlib error code together with win32 error code and C error code. The last two codes are set to ERROR_SUCCESS and 0 respectively. More...
 
void SetLastChsvErrorInfoWC (chsverror_t nChsvError, unsigned long nWin32Error, errno_t nCError) noexcept
 Sets last chsvlib error code together with win32 error code and C error code. More...
 
unsigned long GetLastChsvErrorWin32 () noexcept
 Returns last Windows error code. More...
 
errno_t GetLastChsvErrorC () noexcept
 Returns last C error code. More...
 
const std::error_category & chsvlib_general_category () noexcept
 Returns a reference to a general error category to generate std::system_error exceptions based on chsvlib error codes.
 
std::error_condition make_error_condition (chsvlib_error err)
 Creates and returns a new std::error_condition based on a value of chsvlib_error enumeration type. . More...
 
std::error_code make_error_code (chsvlib_error err)
 Creates and returns an error code object in the form of the standard std::error_code class based on the specified value of the chsvlib_error enumeration type. . More...
 
EXTERN_C HCHSVLIST CreateList () noexcept
 Creates a binary growing list. More...
 
EXTERN_C bool CloseList (HCHSVLIST hList) noexcept
 Closes the list and frees occupied resources. More...
 
EXTERN_C bool ListPushBackValueByPtr (HCHSVLIST hList, void *lpVal) noexcept
 Inserts a pointer to the end of the list without copying any pointed data. More...
 
EXTERN_C bool ListPushFrontValueByPtr (HCHSVLIST hList, void *lpVal) noexcept
 Inserts a pointer to the beginning of the list without copying any pointed data. More...
 
EXTERN_C bool ListPushBackValueByValue (HCHSVLIST hList, const void *lpVal, std::size_t nValueSize) noexcept
 Creates the last element of the list and copies data into its buffers. More...
 
EXTERN_C bool ListPushFrontValueByValue (HCHSVLIST hList, const void *lpVal, std::size_t nValueSize) noexcept
 Creates the first element of the list and copies data into its buffers. More...
 
EXTERN_C void * ListFrontData (HCHSVLIST hList) noexcept
 Returns a pointer to data at the beginning of the list. More...
 
EXTERN_C void * ListBackData (HCHSVLIST hList) noexcept
 Returns a pointer to data at the end of the list. More...
 
EXTERN_C bool ListPopFront (HCHSVLIST hList) noexcept
 Removes the first element of the list and frees occupied resources. More...
 
EXTERN_C bool ListPopBack (HCHSVLIST hList) noexcept
 Removes the last element of the list and frees occupied resources. More...
 
EXTERN_C std::size_t ListGetSize (HCHSVLIST hList) noexcept
 Returns a number of elements in the list. More...
 
EXTERN_C HCHSVLISTITERATOR ListBegin (HCHSVLIST hList) noexcept
 Returns a handle to the iterator bound with the first element of the list. More...
 
EXTERN_C HCHSVLISTITERATOR ListEnd (HCHSVLIST hList) noexcept
 Returns a handle to the iterator bound with the last element of the list. More...
 
EXTERN_C HCHSVLISTITERATOR ListIterPrev (HCHSVLISTITERATOR hListIterator) noexcept
 Returns a handle to the iterator bound with the element located before the element bound with the specified iterator. More...
 
EXTERN_C HCHSVLISTITERATOR ListIterNext (HCHSVLISTITERATOR hListIterator) noexcept
 Returns a handle to the iterator bound with the element located after the element bound with the specified iterator. More...
 
EXTERN_C void * ListGetDataFromIter (HCHSVLISTITERATOR hListIterator) noexcept
 Returns a pointer to data bound with the specified iterator. More...
 
EXTERN_C std::size_t ListGetDataSizeFromIter (HCHSVLISTITERATOR hListIterator) noexcept
 Returns a size of the data bound with the specified iterator. More...
 
EXTERN_C bool ListIterSetValueByPtr (HCHSVLISTITERATOR hListIterator, void *pData) noexcept
 Replaces data of an element bound with the specified iterator by a new pointer without any copying operations. More...
 
EXTERN_C bool ListIterSetValueByValue (HCHSVLISTITERATOR hListIterator, const void *pData, std::size_t nDataSize) noexcept
 Replaces data of an element bound with the specified iterator by contents of a pointer with per byte copying operation. More...
 
EXTERN_C bool ListInsertValueAfterIterByPtr (HCHSVLISTITERATOR hListIterator, void *lpData) noexcept
 Creates a new list element with by-pointer insertion to the position after the one specified by the iterator. More...
 
EXTERN_C bool ListInsertValueBeforeIterByPtr (HCHSVLISTITERATOR hListIterator, void *lpData) noexcept
 Creates a new list element with by-pointer insertion to the position before the one specified by the iterator. More...
 
EXTERN_C bool ListInsertValueAfterIterByValue (HCHSVLISTITERATOR hListIterator, const void *lpData, std::size_t nDataSize) noexcept
 Creates a new list element to the position after the one specified by the iterator copying the specified content to the internal buffers. More...
 
EXTERN_C bool ListInsertValueBeforeIterByValue (HCHSVLISTITERATOR hListIterator, void *lpData, std::size_t nDataSize) noexcept
 Creates a new list element to the position before the one specified by the iterator copying the specified content to the internal buffers. More...
 
EXTERN_C bool ListPopElementByIter (HCHSVLISTITERATOR hListIterator) noexcept
 Removes the element identified by the iterator from the list. More...
 
EXTERN_C bool ListApplyFuncToElements (HCHSVLIST hList, LPLISTELEMENTFUNCTION lpfnForEach, void *lpArg)
 Executes the specified callback function over each element of the list. More...
 
EXTERN_C HCHSVMAP CreateMapEx (PMAPCOMPAREFUNC pfnCompare, bool fMultimap) noexcept
 Creates an instance of a map or a multimap. More...
 
EXTERN_C HCHSVMAP CreateMap () noexcept
 Creates a map with the default ordering towards growth of keys with the requirement for the keys to be unique. More...
 
EXTERN_C HCHSVMAP CreateMultimapEx (PMAPCOMPAREFUNC pfnCompare) noexcept
 Creates a multimap with the specified ordering predicate. More...
 
EXTERN_C HCHSVMAP CreateMultimap () noexcept
 Creates a multimap with the default ordering of map elements towards growth of their keys . More...
 
EXTERN_C bool CloseMap (HCHSVMAP hMap) noexcept
 Closes an instance of a map or a multimap freeing occupied resources. More...
 
EXTERN_C bool MapInsert (HCHSVMAP hMap, const void *pKey, std::size_t cbKey, const void *pValue, std::size_t cbValue) noexcept
 Inserts a new element by value to the specified map. The data in the parameter is copied into the internal buffers bound to elements. More...
 
EXTERN_C bool MapInsertByPtr (HCHSVMAP hMap, const void *pKey, std::size_t cbKey, void *pValue) noexcept
 Inserts a new element by pointer. Only the pointers to the key and value data are stored, pointed memory is neither managed or freed by the map. More...
 
EXTERN_C HCHSVMAPITERATOR MapFind (HCHSVMAP hMap, const void *pKey, std::size_t cbKey) noexcept
 The function returns an iterator bound with an element identified by the key. In a case of the multimap with multiple elements of the same key requested by the call, the iterator of the first of them is returned. See remarks. More...
 
EXTERN_C HCHSVMAPITERATOR MapBegin (HCHSVMAP hMap) noexcept
 The function returns an iterator bound with the first map element. More...
 
EXTERN_C HCHSVMAPITERATOR MapEnd (HCHSVMAP hMap) noexcept
 The function returns an iterator bound with the last existing map element. More...
 
EXTERN_C HCHSVMAPITERATOR MapIterPrev (HCHSVMAPITERATOR hMapIter) noexcept
 The function returns an iterator preceding the specified one or NULL if there are no preceding elements. More...
 
EXTERN_C HCHSVMAPITERATOR MapIterNext (HCHSVMAPITERATOR hMapIter) noexcept
 The function returns an iterator following the specified one or NULL if there are no following elements. More...
 
EXTERN_C bool MapErase (HCHSVMAP hMap, HCHSVMAPITERATOR hWhere) noexcept
 The function removes an element specified by the iterator from the map. More...
 
EXTERN_C std::size_t MapGetSize (HCHSVMAP hMap) noexcept
 The function returns a number of elements the map contains. More...
 
EXTERN_C const void * MapGetKeyFromIter (HCHSVMAPITERATOR hMapIter) noexcept
 The function returns a pointer to key data of the specified element. More...
 
EXTERN_C void * MapGetDataFromIter (HCHSVMAPITERATOR hMapIter) noexcept
 The function returns a pointer to value data of the specified element. More...
 
EXTERN_C std::size_t MapGetKeySizeFromIter (HCHSVMAPITERATOR hMapIter) noexcept
 The function returns a length, in bytes, of the key of the specified element. More...
 
EXTERN_C std::size_t MapGetDataSizeFromIter (HCHSVMAPITERATOR hMapIter) noexcept
 The function returns a length, in bytes, of value data of the specified element inserted by value (with copying) or zero if the element has been inserted by pointer. More...
 
EXTERN_C bool MapApplyFuncToElements (HCHSVMAP hMap, PMAPELEMENTFUNCTION lpfnCallback, void *lpCallbackArg)
 The function implements calling the specified callback function called over each element of the map. More...
 
template<class F , class... ArgTypes>
auto invoke (F &&f, ArgTypes &&... args) noexcept(noexcept(Implementation::INVOKE(std::forward< F >(f), std::forward< ArgTypes >(args)...))) -> decltype(Implementation::INVOKE(std::forward< F >(f), std::forward< ArgTypes >(args)...))
 Invokes a Callable object with a given set of arguments. Implements behaviour of the C++17 std::invoke function via C++11. More...
 
template<class To , class From >
constexpr bool cast_overflows (From val) noexcept
 Checks whether conversion of the parameter to the given type would overflow. More...
 
template<class T >
constexpr auto to_signed (T val)
 Attempts to converts an integral to its signed form without losing information and throws an exception, if that is not possible. More...
 
unsigned long long get_x86_cpu_info () noexcept
 Returns a bit mask indicating a support by the current processor of various Intel x86 and Intel x86-64 CPU extensions. More...
 
int gmtime (const std::time_t *restrict tp, std::tm *restrict pResult) noexcept
 Converts time passed since the epoch on the target machine and specified as a time_t variable into calendar UTC time expressed by an object of the type tm. More...
 
int localtime (const time_t *restrict tp, struct tm *restrict pResult) noexcept
 Converts time passed since the epoch on the target machine and specified as a time_t variable into local calendar time expressed by an object of the type tm. More...
 
std::chrono::system_clock::duration local_zone_get ()
 Returns the local time zone expressed as time duration relative to UTC time. More...
 
HRESULT Win32DlgErrorToWin32Error (DWORD dwCommDlgExtendedError) noexcept
 Translates a Windows dialogue error code to the corresponding Windows system error code. More...
 
chsverror_t Win32DlgErrorToChsvError (DWORD dwCommDlgExtendedError) noexcept
 Translates a Windows dialogue error code to the corresponding chsvlib error code. More...
 

Variables

template<class T , class U >
constexpr bool is_swappable_with_v
 C++14 compliant implementation of std::is_swappable_with_v from <type_traits> of C++17. More...
 
template<class T , class U >
constexpr bool is_nothrow_swappable_with_v
 C++14 compliant implementation of std::is_nothrow_swappable_with_v from <type_traits> of C++17. More...
 
template<class T >
constexpr bool is_swappable_v
 C++14 compliant implementation of std::is_swappable from <type_traits> of C++17. More...
 
template<class T >
constexpr bool is_nothrow_swappable_v
 C++14 compliant implementation of std::is_nothrow_swappable_v from <type_traits> of C++17. More...
 
template<class T >
constexpr bool is_iteratable_type_v = is_iteratable_type<T>::value
 Resolves to true, if a given type is iteratable, and to false otherwise. More...
 

Detailed Description

Basic chsvlib namespace.

DOXYGEN.